updated on Thu Jan 19 20:01:47 UTC 2012
[aur-mirror.git] / netspeed-applet-fontsize / fontsize.patch
blob3dd51e7f16f1db372a956d2be3fd996c28a0ceee
1 diff -ru netspeed_applet-0.15.2/src/netspeed.c netspeed_applet-0.15.2.fontsize/src/netspeed.c
2 --- netspeed_applet-0.15.2/src/netspeed.c 2008-09-13 16:59:52.000000000 -0300
3 +++ netspeed_applet-0.15.2.fontsize/src/netspeed.c 2008-10-23 14:57:41.000000000 -0200
4 @@ -85,6 +85,7 @@
5 gboolean show_sum, show_bits;
6 gboolean change_icon, auto_change_device;
7 GdkColor in_color, out_color;
8 + int font_size;
9 int width;
11 GtkWidget *inbytes_text, *outbytes_text;
12 @@ -664,8 +665,11 @@
14 /* Refresh the text of the labels and tooltip */
15 if (applet->show_sum) {
16 + add_markup_size(&applet->devinfo.sum_rate, applet->font_size);
17 gtk_label_set_markup(GTK_LABEL(applet->sum_label), applet->devinfo.sum_rate);
18 } else {
19 + add_markup_size(&applet->devinfo.rx_rate, applet->font_size);
20 + add_markup_size(&applet->devinfo.tx_rate, applet->font_size);
21 gtk_label_set_markup(GTK_LABEL(applet->in_label), applet->devinfo.rx_rate);
22 gtk_label_set_markup(GTK_LABEL(applet->out_label), applet->devinfo.tx_rate);
24 @@ -891,6 +895,7 @@
25 return;
27 panel_applet_gconf_set_string(PANEL_APPLET(applet->applet), "device", applet->devinfo.name, NULL);
28 + panel_applet_gconf_set_int(PANEL_APPLET(applet->applet), "font_size", applet->font_size, NULL);
29 panel_applet_gconf_set_bool(PANEL_APPLET(applet->applet), "show_sum", applet->show_sum, NULL);
30 panel_applet_gconf_set_bool(PANEL_APPLET(applet->applet), "show_bits", applet->show_bits, NULL);
31 panel_applet_gconf_set_bool(PANEL_APPLET(applet->applet), "change_icon", applet->change_icon, NULL);
32 @@ -901,6 +906,15 @@
33 applet->settings = NULL;
36 +/* Set the font size to the new value
37 + */
38 +static void
39 +font_size_adjust_cb(GtkSpinButton *spinbutton, NetspeedApplet *applet)
41 + applet->font_size = gtk_spin_button_get_value_as_int(spinbutton);
42 + applet->width = 0;
45 /* Called when the showsum checkbutton is toggled...
47 static void
48 @@ -944,7 +958,12 @@
49 GtkWidget *category_header_label;
50 GtkWidget *network_device_hbox;
51 GtkWidget *network_device_label;
52 + GtkWidget *label_font_size_hbox;
53 + GtkWidget *label_font_size_hbox2;
54 + GtkWidget *label_font_size_label;
55 + GtkWidget *label_font_size_spinbutton;
56 GtkWidget *indent_label;
57 + GtkWidget *points_label;
58 GtkWidget *show_sum_checkbutton;
59 GtkWidget *show_bits_checkbutton;
60 GtkWidget *change_icon_checkbutton;
61 @@ -1033,6 +1052,31 @@
62 gtk_combo_box_set_active(GTK_COMBO_BOX(applet->network_device_combo), active);
63 g_object_set_data_full(G_OBJECT(applet->network_device_combo), "devices", devices, (GDestroyNotify)free_devices_list);
65 + label_font_size_hbox = gtk_hbox_new(FALSE, 6);
66 + gtk_box_pack_start(GTK_BOX(controls_vbox), label_font_size_hbox, TRUE, TRUE, 0);
68 + label_font_size_label = gtk_label_new_with_mnemonic(_("Label _font size:"));
69 + gtk_label_set_justify(GTK_LABEL(label_font_size_label), GTK_JUSTIFY_LEFT);
70 + gtk_misc_set_alignment(GTK_MISC(label_font_size_label), 0.0f, 0.5f);
71 + gtk_size_group_add_widget(category_label_size_group, label_font_size_label);
72 + gtk_box_pack_start(GTK_BOX(label_font_size_hbox), label_font_size_label, FALSE, FALSE, 0);
74 + label_font_size_hbox2 = gtk_hbox_new(FALSE, 6);
75 + gtk_box_pack_start(GTK_BOX(label_font_size_hbox), label_font_size_hbox2, TRUE, TRUE, 0);
77 + label_font_size_spinbutton = gtk_spin_button_new_with_range (5.0, 32.0, 1.0);
78 + gtk_spin_button_set_value(GTK_SPIN_BUTTON(label_font_size_spinbutton), (double) applet->font_size);
79 + gtk_spin_button_set_snap_to_ticks(GTK_SPIN_BUTTON(label_font_size_spinbutton), TRUE);
80 + gtk_spin_button_set_digits(GTK_SPIN_BUTTON (label_font_size_spinbutton), 0);
81 + gtk_label_set_mnemonic_widget(GTK_LABEL(label_font_size_label), label_font_size_spinbutton);
82 + gtk_box_pack_start(GTK_BOX(label_font_size_hbox2), label_font_size_spinbutton, TRUE, TRUE, 0);
84 + points_label = gtk_label_new(_("points"));
85 + gtk_label_set_justify(GTK_LABEL (points_label), GTK_JUSTIFY_LEFT);
86 + gtk_misc_set_alignment(GTK_MISC (points_label), 0.0f, 0.5f);
87 + gtk_size_group_add_widget(category_units_size_group, points_label);
88 + gtk_box_pack_start(GTK_BOX (label_font_size_hbox2), points_label, FALSE, FALSE, 0);
90 show_sum_checkbutton = gtk_check_button_new_with_mnemonic(_("Show _sum instead of in & out"));
91 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(show_sum_checkbutton), applet->show_sum);
92 gtk_box_pack_start(GTK_BOX(controls_vbox), show_sum_checkbutton, FALSE, FALSE, 0);
93 @@ -1048,6 +1092,9 @@
94 g_signal_connect(G_OBJECT (applet->network_device_combo), "changed",
95 G_CALLBACK(device_change_cb), (gpointer)applet);
97 + g_signal_connect(G_OBJECT (label_font_size_spinbutton), "value-changed",
98 + G_CALLBACK(font_size_adjust_cb), (gpointer)applet);
100 g_signal_connect(G_OBJECT (show_sum_checkbutton), "toggled",
101 G_CALLBACK(showsum_change_cb), (gpointer)applet);
103 @@ -1343,6 +1390,30 @@
107 +/* Tries to get the desktop font size out of gconf
108 + * database
109 + */
110 +static int
111 +get_default_font_size(void)
113 + int ret = 12;
114 + char *buf, *ptr;
116 + GConfClient *client = NULL;
117 + client = gconf_client_get_default();
118 + if (!client)
119 + return 12;
120 + buf = gconf_client_get_string(client, "/desktop/gnome/interface/font_name", NULL);
121 + if (!buf)
122 + return 12;
123 + ptr = strrchr(buf, ' ');
124 + if (ptr)
125 + sscanf(ptr, "%d", &ret);
126 + g_free(buf);
128 + return ret;
131 static gboolean
132 applet_button_press(GtkWidget *widget, GdkEventButton *event, NetspeedApplet *applet)
134 @@ -1526,6 +1597,7 @@
135 applet->show_sum = FALSE;
136 applet->show_bits = FALSE;
137 applet->change_icon = TRUE;
138 + applet->font_size = -1;
139 applet->auto_change_device = TRUE;
141 /* Set the default colors of the graph
142 @@ -1553,6 +1625,9 @@
143 applet->show_bits = panel_applet_gconf_get_bool(applet_widget, "show_bits", NULL);
144 applet->change_icon = panel_applet_gconf_get_bool(applet_widget, "change_icon", NULL);
145 applet->auto_change_device = panel_applet_gconf_get_bool(applet_widget, "auto_change_device", NULL);
146 + applet->font_size = panel_applet_gconf_get_int(applet_widget, "font_size", NULL);
147 + if (!applet->font_size)
148 + applet->font_size = -1;
150 tmp = panel_applet_gconf_get_string(applet_widget, "device", NULL);
151 if (tmp && strcmp(tmp, ""))
152 @@ -1587,6 +1662,9 @@
156 + if (applet->font_size < 1)
157 + applet->font_size = get_default_font_size();
159 if (!applet->devinfo.name) {
160 GList *ptr, *devices = get_available_devices();
161 ptr = devices;