cpufreq_applet_size_request (GtkWidget *widget, GtkRequisition *requisition) #endif { CPUFreqApplet *applet; gint labels_width = 0; gint width; 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; if (applet->show_freq) { labels_width += cpufreq_applet_get_max_label_width (applet) + 2; } if (applet->show_perc) { labels_width += cpufreq_applet_get_max_perc_width (applet); } if (applet->show_unit) { labels_width += cpufreq_applet_get_max_unit_width (applet); } 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 cpufreq_applet_get_preferred_width (GtkWidget *widget, gint *minimum_width, gint *natural_width) { CPUFreqApplet *applet; gint labels_width = 0; gint width; applet = CPUFREQ_APPLET (widget); if (applet->orient == PANEL_APPLET_ORIENT_LEFT || applet->orient == PANEL_APPLET_ORIENT_RIGHT) return; if (applet->show_freq) { labels_width += cpufreq_applet_get_max_label_width (applet) + 2; } if (applet->show_perc) { labels_width += cpufreq_applet_get_max_perc_width (applet); } if (applet->show_unit) { labels_width += cpufreq_applet_get_max_unit_width (applet); } if (applet->show_icon) { 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 { width = labels_width; } *minimum_width = *natural_width = width; }
static void cpufreq_applet_size_request (GtkWidget *widget, GtkRequisition *requisition) { CPUFreqApplet *applet; gint labels_width = 0; gint width; applet = CPUFREQ_APPLET (widget); GTK_WIDGET_CLASS (cpufreq_applet_parent_class)->size_request (widget, requisition); if (applet->orient == MATE_PANEL_APPLET_ORIENT_LEFT || applet->orient == MATE_PANEL_APPLET_ORIENT_RIGHT) return; if (applet->show_freq) { labels_width += cpufreq_applet_get_max_label_width (applet) + 2; } if (applet->show_perc) { labels_width += cpufreq_applet_get_max_perc_width (applet); } if (applet->show_unit) { labels_width += cpufreq_applet_get_max_unit_width (applet); } if (applet->show_icon) { 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); } else { width = labels_width; } requisition->width = width; }