diff options
Diffstat (limited to 'cpufreq/src/cpufreq-applet.c')
-rw-r--r-- | cpufreq/src/cpufreq-applet.c | 104 |
1 files changed, 1 insertions, 103 deletions
diff --git a/cpufreq/src/cpufreq-applet.c b/cpufreq/src/cpufreq-applet.c index 629a8333..4600caec 100644 --- a/cpufreq/src/cpufreq-applet.c +++ b/cpufreq/src/cpufreq-applet.c @@ -39,11 +39,6 @@ #include "cpufreq-monitor-factory.h" #include "cpufreq-utils.h" -#if GTK_CHECK_VERSION (3, 0, 0) -#define gtk_vbox_new(X,Y) gtk_box_new(GTK_ORIENTATION_VERTICAL,Y) -#define gtk_hbox_new(X,Y) gtk_box_new(GTK_ORIENTATION_HORIZONTAL,Y) -#endif - struct _CPUFreqApplet { MatePanelApplet base; @@ -107,14 +102,9 @@ static gboolean cpufreq_applet_key_press (GtkWidget *widget, GdkEventKey *event); static void cpufreq_applet_size_allocate (GtkWidget *widget, GtkAllocation *allocation); -#if GTK_CHECK_VERSION (3, 0, 0) static void cpufreq_applet_get_preferred_width (GtkWidget *widget, gint *minimum_width, gint *natural_width); -#else -static void cpufreq_applet_size_request (GtkWidget *widget, - GtkRequisition *requisition); -#endif static void cpufreq_applet_change_orient (MatePanelApplet *pa, MatePanelAppletOrient orient); static gboolean cpufreq_applet_factory (CPUFreqApplet *applet, @@ -231,11 +221,7 @@ cpufreq_applet_class_init (CPUFreqAppletClass *klass) gobject_class->dispose = cpufreq_applet_dispose; widget_class->size_allocate = cpufreq_applet_size_allocate; -#if GTK_CHECK_VERSION (3, 0, 0) widget_class->get_preferred_width = cpufreq_applet_get_preferred_width; -#else - widget_class->size_request = cpufreq_applet_size_request; -#endif widget_class->button_press_event = cpufreq_applet_button_press; widget_class->key_press_event = cpufreq_applet_key_press; @@ -317,11 +303,7 @@ cpufreq_applet_get_max_label_width (CPUFreqApplet *applet) available_freqs = cpufreq_monitor_get_available_frequencies (applet->monitor); while (available_freqs) { GtkWidget *label; -#if GTK_CHECK_VERSION (3, 0, 0) gint label_width; -#else - GtkRequisition req; -#endif const gchar *text; gchar *freq_text; gint freq; @@ -331,14 +313,8 @@ cpufreq_applet_get_max_label_width (CPUFreqApplet *applet) freq_text = cpufreq_utils_get_frequency_label (freq); label = gtk_label_new (freq_text); -#if GTK_CHECK_VERSION (3, 0, 0) gtk_widget_get_preferred_width (applet->label, &label_width, NULL); width = MAX (width, label_width); -#endif -#if !GTK_CHECK_VERSION (3, 0, 0) - gtk_widget_size_request (label, &req); - width = MAX (width, req.width); -#endif g_free (freq_text); gtk_widget_destroy (label); @@ -355,23 +331,14 @@ static gint cpufreq_applet_get_max_perc_width (CPUFreqApplet *applet) { GtkWidget *label; -#if GTK_CHECK_VERSION (3, 0, 0) gint width; -#else - GtkRequisition req; -#endif if (applet->max_perc_width > 0) return applet->max_perc_width; label = gtk_label_new ("100%"); -#if GTK_CHECK_VERSION (3, 0, 0) gtk_widget_get_preferred_width (applet->label, &width,&width); applet->max_perc_width = width +20; /*for some reason width always comes up 2 characters*/ -#else - gtk_widget_size_request (label, &req); - applet->max_perc_width = req.width; -#endif gtk_widget_destroy (label); return applet->max_perc_width; @@ -381,45 +348,24 @@ static gint cpufreq_applet_get_max_unit_width (CPUFreqApplet *applet) { GtkWidget *label; -#if !GTK_CHECK_VERSION (3, 0, 0) - GtkRequisition req; -#endif gint w1, w2; if (applet->max_unit_width > 0) return applet->max_unit_width; label = gtk_label_new ("GHz"); -#if GTK_CHECK_VERSION (3, 0, 0) gtk_widget_get_preferred_width (applet->label, &w1, NULL); -#else - gtk_widget_size_request (label, &req); - w1 = req.width; -#endif gtk_label_set_text (GTK_LABEL (label), "MHz"); -#if GTK_CHECK_VERSION (3, 0, 0) gtk_widget_get_preferred_width (applet->label, &w2, NULL); -#else - gtk_widget_size_request (label, &req); - w2 = req.width; -#endif gtk_widget_destroy (label); -#if GTK_CHECK_VERSION (3, 0, 0) applet->max_unit_width = MAX (w1, w2)-1; -#else - applet->max_unit_width = MAX (w1, w2); -#endif return applet->max_unit_width; } static void -#if GTK_CHECK_VERSION (3, 0, 0) cpufreq_applet_get_preferred_width (GtkWidget *widget, gint *minimum_width, gint *natural_width) -#else -cpufreq_applet_size_request (GtkWidget *widget, GtkRequisition *requisition) -#endif { CPUFreqApplet *applet; gint labels_width = 0; @@ -427,10 +373,6 @@ cpufreq_applet_size_request (GtkWidget *widget, GtkRequisition *requisition) applet = CPUFREQ_APPLET (widget); -#if !GTK_CHECK_VERSION (3, 0, 0) - GTK_WIDGET_CLASS (cpufreq_applet_parent_class)->size_request (widget, requisition); -#endif - if (applet->orient == MATE_PANEL_APPLET_ORIENT_LEFT || applet->orient == MATE_PANEL_APPLET_ORIENT_RIGHT) return; @@ -449,30 +391,17 @@ cpufreq_applet_size_request (GtkWidget *widget, GtkRequisition *requisition) } if (applet->show_icon) { -#if GTK_CHECK_VERSION (3, 0, 0) gint icon_width; gtk_widget_get_preferred_width (applet->icon, &icon_width, NULL); width = gtk_orientable_get_orientation (GTK_ORIENTABLE (applet->box)) == GTK_ORIENTATION_HORIZONTAL ? labels_width + icon_width + 2 : MAX (labels_width, icon_width + 2); -#else - GtkRequisition req; - - gtk_widget_size_request (applet->icon, &req); - width = GTK_IS_HBOX (applet->box) ? - labels_width + req.width + 2 : - MAX (labels_width, req.width + 2); -#endif } else { width = labels_width; } -#if GTK_CHECK_VERSION (3, 0, 0) *minimum_width = *natural_width = width; -#else - requisition->width = width; -#endif } static void @@ -490,11 +419,7 @@ cpufreq_applet_popup_position_menu (GtkMenu *menu, widget = GTK_WIDGET (gdata); -#if GTK_CHECK_VERSION (3, 0, 0) gtk_widget_get_preferred_size (GTK_WIDGET (menu), &requisition, NULL); -#else - gtk_widget_size_request (GTK_WIDGET (menu), &requisition); -#endif gdk_window_get_origin (gtk_widget_get_window (widget), &menu_xpos, &menu_ypos); @@ -524,11 +449,7 @@ cpufreq_applet_popup_position_menu (GtkMenu *menu, *x = menu_xpos; *y = menu_ypos; -#if GTK_CHECK_VERSION (3, 0, 0) if (push_in) *push_in = FALSE; /*fix bottom panel menu rendering in gtk3*/ -#else - *push_in = TRUE; -#endif } static void @@ -551,7 +472,6 @@ cpufreq_applet_menu_popup (CPUFreqApplet *applet, if (!menu) return; -#if GTK_CHECK_VERSION (3, 0, 0) /*Set up theme and transparency support*/ GtkWidget *toplevel = gtk_widget_get_toplevel (menu); /* Fix any failures of compiz/other wm's to communicate with gtk for transparency */ @@ -563,7 +483,7 @@ cpufreq_applet_menu_popup (CPUFreqApplet *applet, context = gtk_widget_get_style_context (GTK_WIDGET(toplevel)); gtk_style_context_add_class(context,"gnome-panel-menu-bar"); gtk_style_context_add_class(context,"mate-panel-menu-bar"); -#endif + gtk_menu_popup (GTK_MENU (menu), NULL, NULL, cpufreq_applet_popup_position_menu, (gpointer) applet, @@ -910,11 +830,7 @@ cpufreq_applet_get_widget_size (CPUFreqApplet *applet, if (!gtk_widget_get_visible (widget)) return 0; -#if GTK_CHECK_VERSION (3, 0, 0) gtk_widget_get_preferred_size (widget, &req, NULL); -#else - gtk_widget_size_request (widget, &req); -#endif switch (applet->orient) { case MATE_PANEL_APPLET_ORIENT_LEFT: @@ -977,7 +893,6 @@ cpufreq_applet_refresh (CPUFreqApplet *applet) } if (horizontal) { -#if GTK_CHECK_VERSION (3, 0, 0) applet->labels_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); if ((label_size + pixmap_size) <= panel_size) applet->box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); @@ -993,23 +908,6 @@ cpufreq_applet_refresh (CPUFreqApplet *applet) } else { applet->box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); applet->labels_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); -#else - applet->labels_box = gtk_hbox_new (FALSE, 2); - if ((label_size + pixmap_size) <= panel_size) - applet->box = gtk_vbox_new (FALSE, 2); - else - applet->box = gtk_hbox_new (FALSE, 2); - } else { - if (total_size <= panel_size) { - applet->box = gtk_hbox_new (FALSE, 2); - applet->labels_box = gtk_hbox_new (FALSE, 2); - } else if ((label_size + unit_label_size) <= (panel_size - size_step)) { - applet->box = gtk_vbox_new (FALSE, 2); - applet->labels_box = gtk_hbox_new (FALSE, 2); - } else { - applet->box = gtk_vbox_new (FALSE, 2); - applet->labels_box = gtk_vbox_new (FALSE, 2); -#endif } } |