cpufreq: code cleanup
This commit is contained in:
parent
87ebf30512
commit
73f863e8e8
|
@ -92,7 +92,7 @@ static Cpufreq * _cpufreq_init(PanelAppletHelper * helper, GtkWidget ** widget)
|
||||||
GtkWidget * image;
|
GtkWidget * image;
|
||||||
GtkWidget * label;
|
GtkWidget * label;
|
||||||
char const * p;
|
char const * p;
|
||||||
#if defined(__APPLE__)
|
# if defined(__APPLE__)
|
||||||
int64_t i;
|
int64_t i;
|
||||||
int64_t imin;
|
int64_t imin;
|
||||||
int64_t imax;
|
int64_t imax;
|
||||||
|
@ -108,7 +108,7 @@ static Cpufreq * _cpufreq_init(PanelAppletHelper * helper, GtkWidget ** widget)
|
||||||
error_set("%s: %s", applet.name, _("No support detected"));
|
error_set("%s: %s", applet.name, _("No support detected"));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#else
|
# else
|
||||||
char freq[256];
|
char freq[256];
|
||||||
size_t freqsize = sizeof(freq);
|
size_t freqsize = sizeof(freq);
|
||||||
char const * q;
|
char const * q;
|
||||||
|
@ -133,10 +133,10 @@ static Cpufreq * _cpufreq_init(PanelAppletHelper * helper, GtkWidget ** widget)
|
||||||
error_set("%s: %s", applet.name, _("No support detected"));
|
error_set("%s: %s", applet.name, _("No support detected"));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif
|
# endif
|
||||||
#ifdef DEBUG
|
# ifdef DEBUG
|
||||||
fprintf(stderr, "DEBUG: %s() \"%s\"\n", __func__, p);
|
fprintf(stderr, "DEBUG: %s() \"%s\"\n", __func__, p);
|
||||||
#endif
|
# endif
|
||||||
if((cpufreq = malloc(sizeof(*cpufreq))) == NULL)
|
if((cpufreq = malloc(sizeof(*cpufreq))) == NULL)
|
||||||
{
|
{
|
||||||
error_set("%s: %s", applet.name, strerror(errno));
|
error_set("%s: %s", applet.name, strerror(errno));
|
||||||
|
@ -146,31 +146,31 @@ static Cpufreq * _cpufreq_init(PanelAppletHelper * helper, GtkWidget ** widget)
|
||||||
desc = pango_font_description_new();
|
desc = pango_font_description_new();
|
||||||
pango_font_description_set_family(desc, "Monospace");
|
pango_font_description_set_family(desc, "Monospace");
|
||||||
pango_font_description_set_weight(desc, PANGO_WEIGHT_BOLD);
|
pango_font_description_set_weight(desc, PANGO_WEIGHT_BOLD);
|
||||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
# if GTK_CHECK_VERSION(3, 0, 0)
|
||||||
cpufreq->hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
|
cpufreq->hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
|
||||||
#else
|
# else
|
||||||
cpufreq->hbox = gtk_hbox_new(FALSE, 4);
|
cpufreq->hbox = gtk_hbox_new(FALSE, 4);
|
||||||
#endif
|
# endif
|
||||||
image = gtk_image_new_from_icon_name(applet.icon,
|
image = gtk_image_new_from_icon_name(applet.icon,
|
||||||
panel_window_get_icon_size(helper->window));
|
panel_window_get_icon_size(helper->window));
|
||||||
gtk_box_pack_start(GTK_BOX(cpufreq->hbox), image, FALSE, TRUE, 0);
|
gtk_box_pack_start(GTK_BOX(cpufreq->hbox), image, FALSE, TRUE, 0);
|
||||||
#if defined(__APPLE__)
|
# if defined(__APPLE__)
|
||||||
cpufreq->max = imax / 1000000;
|
cpufreq->max = imax / 1000000;
|
||||||
cpufreq->min = imin / 1000000;
|
cpufreq->min = imin / 1000000;
|
||||||
#else
|
# else
|
||||||
cpufreq->max = atoll(freq);
|
cpufreq->max = atoll(freq);
|
||||||
cpufreq->min = (q = strrchr(freq, ' ')) != NULL ? atoll(q)
|
cpufreq->min = (q = strrchr(freq, ' ')) != NULL ? atoll(q)
|
||||||
: cpufreq->max;
|
: cpufreq->max;
|
||||||
#endif
|
# endif
|
||||||
cpufreq->current = -1;
|
cpufreq->current = -1;
|
||||||
cpufreq->step = 1;
|
cpufreq->step = 1;
|
||||||
cpufreq->name = p;
|
cpufreq->name = p;
|
||||||
cpufreq->label = gtk_label_new(" ");
|
cpufreq->label = gtk_label_new(" ");
|
||||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
# if GTK_CHECK_VERSION(3, 0, 0)
|
||||||
gtk_widget_override_font(cpufreq->label, desc);
|
gtk_widget_override_font(cpufreq->label, desc);
|
||||||
#else
|
# else
|
||||||
gtk_widget_modify_font(cpufreq->label, desc);
|
gtk_widget_modify_font(cpufreq->label, desc);
|
||||||
#endif
|
# endif
|
||||||
gtk_box_pack_start(GTK_BOX(cpufreq->hbox), cpufreq->label, FALSE, TRUE,
|
gtk_box_pack_start(GTK_BOX(cpufreq->hbox), cpufreq->label, FALSE, TRUE,
|
||||||
0);
|
0);
|
||||||
label = gtk_label_new(_("MHz"));
|
label = gtk_label_new(_("MHz"));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user