- mem.c: use GtkComboBox instead of deprecated GtkCombo

- net.c: use GtkComboBox instead of deprecated GtkCombo
This commit is contained in:
Stefan Gehn 2008-09-28 17:15:54 +00:00
parent c994994734
commit 5b78e499ca
2 changed files with 106 additions and 99 deletions

104
src/mem.c
View File

@ -1092,10 +1092,10 @@ static GtkWidget *mem_launch_entry,
*swap_launch_entry, *swap_launch_entry,
*swap_tooltip_entry; *swap_tooltip_entry;
static GtkWidget *mem_format_combo, static GtkWidget *mem_format_combo_box,
*swap_format_combo; *swap_format_combo_box;
static GtkWidget *text_format_combo; static GtkWidget *text_format_combo_box;
static GtkWidget *mem_alert_button, static GtkWidget *mem_alert_button,
*swap_alert_button; *swap_alert_button;
@ -1105,8 +1105,10 @@ static void
cb_text_format(GtkWidget *widget, gpointer data) cb_text_format(GtkWidget *widget, gpointer data)
{ {
gchar *s; gchar *s;
GtkWidget *entry;
s = gkrellm_gtk_entry_get_text(&(GTK_COMBO(text_format_combo)->entry)); entry = gtk_bin_get_child(GTK_BIN(text_format_combo_box));
s = gkrellm_gtk_entry_get_text(&entry);
gkrellm_locale_dup_string(&text_format, s, &text_format_locale); gkrellm_locale_dup_string(&text_format, s, &text_format_locale);
refresh_chart(&swap_chart); refresh_chart(&swap_chart);
} }
@ -1181,8 +1183,10 @@ static void
cb_mem_format(GtkWidget *widget, gpointer data) cb_mem_format(GtkWidget *widget, gpointer data)
{ {
gchar *s; gchar *s;
GtkWidget *entry;
s = gkrellm_gtk_entry_get_text(&(GTK_COMBO(mem_format_combo)->entry)); entry = gtk_bin_get_child(GTK_BIN(mem_format_combo_box));
s = gkrellm_gtk_entry_get_text(&entry);
/* In case Pango markup tags, don't accept line unless valid markup. /* In case Pango markup tags, don't accept line unless valid markup.
| Ie, markup like <span ...> xxx </span> or <b> xxx </b> | Ie, markup like <span ...> xxx </span> or <b> xxx </b>
@ -1201,8 +1205,10 @@ static void
cb_swap_format(GtkWidget *widget, gpointer data) cb_swap_format(GtkWidget *widget, gpointer data)
{ {
gchar *s; gchar *s;
GtkWidget *entry;
s = gkrellm_gtk_entry_get_text(&(GTK_COMBO(swap_format_combo)->entry)); entry = gtk_bin_get_child(GTK_BIN(swap_format_combo_box));
s = gkrellm_gtk_entry_get_text(&entry);
if ( strchr(s, '<') != NULL if ( strchr(s, '<') != NULL
&& !pango_parse_markup(s, -1, 0, NULL, NULL, NULL, NULL) && !pango_parse_markup(s, -1, 0, NULL, NULL, NULL, NULL)
@ -1279,7 +1285,6 @@ create_meminfo_tab(GtkWidget *tab_vbox)
GtkWidget *table; GtkWidget *table;
GtkWidget *hbox; GtkWidget *hbox;
GtkWidget *text, *label; GtkWidget *text, *label;
GList *list;
gint i; gint i;
tabs = gtk_notebook_new(); tabs = gtk_notebook_new();
@ -1331,23 +1336,23 @@ create_meminfo_tab(GtkWidget *tab_vbox)
vbox1 = gkrellm_gtk_category_vbox(vbox, vbox1 = gkrellm_gtk_category_vbox(vbox,
_("Format String for Chart Labels"), _("Format String for Chart Labels"),
4, 0, TRUE); 4, 0, TRUE);
text_format_combo = gtk_combo_new(); text_format_combo_box = gtk_combo_box_entry_new_text();
gtk_box_pack_start(GTK_BOX(vbox1), text_format_combo, FALSE, FALSE, 2); gtk_box_pack_start(GTK_BOX(vbox1), text_format_combo_box, FALSE, FALSE, 2);
list = NULL;
list = g_list_append(list, text_format); gtk_combo_box_append_text(GTK_COMBO_BOX(text_format_combo_box),
list = g_list_append(list, DEFAULT_TEXT_FORMAT); text_format);
list = g_list_append(list, "$T\\C\\f$M"); gtk_combo_box_append_text(GTK_COMBO_BOX(text_format_combo_box),
list = g_list_append(list, "\\c\\f$M\\b$T"); DEFAULT_TEXT_FORMAT);
list = g_list_append(list, gtk_combo_box_append_text(GTK_COMBO_BOX(text_format_combo_box),
"\\ww\\C\\f$M\\D2\\f\\ai\\.$i\\D1\\f\\ao\\.$o"); "$T\\C\\f$M");
list = g_list_append(list, gtk_combo_box_append_text(GTK_COMBO_BOX(text_format_combo_box),
"\\ww\\C\\f$M\\D3\\f\\ai\\.$i\\D0\\f\\ao\\.$o"); "\\c\\f$M\\b$T");
gtk_combo_set_popdown_strings(GTK_COMBO(text_format_combo), list); gtk_combo_box_append_text(GTK_COMBO_BOX(text_format_combo_box),
gtk_combo_set_case_sensitive(GTK_COMBO(text_format_combo), TRUE); "\\ww\\C\\f$M\\D2\\f\\ai\\.$i\\D1\\f\\ao\\.$o");
g_list_free(list); gtk_combo_box_append_text(GTK_COMBO_BOX(text_format_combo_box),
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(text_format_combo)->entry), "\\ww\\C\\f$M\\D3\\f\\ai\\.$i\\D0\\f\\ao\\.$o");
text_format); gtk_combo_box_set_active(GTK_COMBO_BOX(text_format_combo_box), 0);
g_signal_connect(G_OBJECT(GTK_COMBO(text_format_combo)->entry), "changed", g_signal_connect(G_OBJECT(GTK_COMBO_BOX(text_format_combo_box)), "changed",
G_CALLBACK(cb_text_format), NULL); G_CALLBACK(cb_text_format), NULL);
vbox1 = gkrellm_gtk_category_vbox(vbox, vbox1 = gkrellm_gtk_category_vbox(vbox,
@ -1355,20 +1360,21 @@ create_meminfo_tab(GtkWidget *tab_vbox)
4, 6, TRUE); 4, 6, TRUE);
hbox = gtk_hbox_new(FALSE, 0); hbox = gtk_hbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox1), hbox, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox1), hbox, FALSE, FALSE, 0);
mem_format_combo = gtk_combo_new(); mem_format_combo_box = gtk_combo_box_entry_new_text();
gtk_box_pack_start(GTK_BOX(hbox), mem_format_combo, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox), mem_format_combo_box, TRUE, TRUE, 0);
list = NULL; gtk_combo_box_append_text(GTK_COMBO_BOX(mem_format_combo_box),
list = g_list_append(list, mem.data_format); mem.data_format);
list = g_list_append(list, DEFAULT_FORMAT); gtk_combo_box_append_text(GTK_COMBO_BOX(mem_format_combo_box),
list = g_list_append(list, _("$t - $u used")); DEFAULT_FORMAT);
list = g_list_append(list, _("$t - $U")); gtk_combo_box_append_text(GTK_COMBO_BOX(mem_format_combo_box),
list = g_list_append(list, _("$t - $u used $s sh $b bf $c ca")); _("$t - $u used"));
gtk_combo_set_popdown_strings(GTK_COMBO(mem_format_combo), list); gtk_combo_box_append_text(GTK_COMBO_BOX(mem_format_combo_box),
gtk_combo_set_case_sensitive(GTK_COMBO(mem_format_combo), TRUE); _("$t - $U"));
g_list_free(list); gtk_combo_box_append_text(GTK_COMBO_BOX(mem_format_combo_box),
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(mem_format_combo)->entry), _("$t - $u used $s sh $b bf $c ca"));
gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(mem_format_combo_box))),
mem.data_format); mem.data_format);
g_signal_connect(G_OBJECT(GTK_COMBO(mem_format_combo)->entry), "changed", g_signal_connect(G_OBJECT(GTK_COMBO_BOX(mem_format_combo_box)), "changed",
G_CALLBACK(cb_mem_format), NULL); G_CALLBACK(cb_mem_format), NULL);
label = gtk_label_new(_("Mem")); label = gtk_label_new(_("Mem"));
gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
@ -1377,19 +1383,19 @@ create_meminfo_tab(GtkWidget *tab_vbox)
hbox = gtk_hbox_new(FALSE, 0); hbox = gtk_hbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox1), hbox, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox1), hbox, FALSE, FALSE, 0);
swap_format_combo = gtk_combo_new(); swap_format_combo_box = gtk_combo_box_entry_new_text();
gtk_box_pack_start(GTK_BOX(hbox), swap_format_combo, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox), swap_format_combo_box, TRUE, TRUE, 0);
list = NULL; gtk_combo_box_append_text(GTK_COMBO_BOX(swap_format_combo_box),
list = g_list_append(list, swap.data_format); swap.data_format);
list = g_list_append(list, DEFAULT_FORMAT); gtk_combo_box_append_text(GTK_COMBO_BOX(swap_format_combo_box),
list = g_list_append(list, _("$t - $u used")); DEFAULT_FORMAT);
list = g_list_append(list, _("$t - $U")); gtk_combo_box_append_text(GTK_COMBO_BOX(swap_format_combo_box),
gtk_combo_set_popdown_strings(GTK_COMBO(swap_format_combo), list); _("$t - $u used"));
gtk_combo_set_case_sensitive(GTK_COMBO(swap_format_combo), TRUE); gtk_combo_box_append_text(GTK_COMBO_BOX(swap_format_combo_box),
g_list_free(list); _("$t - $U"));
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(swap_format_combo)->entry), gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(swap_format_combo_box))),
swap.data_format); swap.data_format);
g_signal_connect(G_OBJECT(GTK_COMBO(swap_format_combo)->entry), "changed", g_signal_connect(G_OBJECT(GTK_COMBO_BOX(swap_format_combo_box)), "changed",
G_CALLBACK(cb_swap_format), NULL); G_CALLBACK(cb_swap_format), NULL);
label = gtk_label_new(_("Swap")); label = gtk_label_new(_("Swap"));
gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);

View File

@ -2550,8 +2550,8 @@ load_net_config(gchar *arg)
static GtkWidget *pon_entry, static GtkWidget *pon_entry,
*poff_entry, *poff_entry,
*timer_iface_combo, *timer_iface_combo_box,
*text_format_combo; *text_format_combo_box;
static GtkWidget *enable_net_timer_button; static GtkWidget *enable_net_timer_button;
static GtkWidget *net_timer_seconds_button; static GtkWidget *net_timer_seconds_button;
@ -2601,9 +2601,8 @@ cb_enable(GtkWidget *button, NetMon *net)
} }
} }
gtk_widget_set_sensitive(net->alert_button, net->enabled); gtk_widget_set_sensitive(net->alert_button, net->enabled);
if (net == net_timed && !net->enabled && timer_iface_combo) if (net == net_timed && !net->enabled && timer_iface_combo_box)
gtk_entry_set_text( gtk_combo_box_set_active(GTK_COMBO_BOX(timer_iface_combo_box), 0);
GTK_ENTRY(GTK_COMBO(timer_iface_combo)->entry), "none");
else else
sync_chart(net); sync_chart(net);
enable_in_progress = FALSE; enable_in_progress = FALSE;
@ -2624,8 +2623,10 @@ cb_text_format(GtkWidget *widget, gpointer data)
GList *list; GList *list;
NetMon *net; NetMon *net;
gchar *s; gchar *s;
GtkWidget *entry;
s = gkrellm_gtk_entry_get_text(&(GTK_COMBO(text_format_combo)->entry)); entry = gtk_bin_get_child(GTK_BIN(text_format_combo_box));
s = gkrellm_gtk_entry_get_text(&entry);
gkrellm_locale_dup_string(&text_format, s, &text_format_locale); gkrellm_locale_dup_string(&text_format, s, &text_format_locale);
for (list = net_mon_list; list; list = list->next) for (list = net_mon_list; list; list = list->next)
{ {
@ -2747,12 +2748,12 @@ cb_timer_enable(GtkWidget *button, gpointer data)
GTK_TOGGLE_BUTTON(enable_net_timer_button)->active, GTK_TOGGLE_BUTTON(enable_net_timer_button)->active,
&timer_button_enabled); &timer_button_enabled);
gtk_widget_set_sensitive(net_timer_seconds_button, timer_button_enabled); gtk_widget_set_sensitive(net_timer_seconds_button, timer_button_enabled);
if (timer_iface_combo) if (timer_iface_combo_box)
{ {
/* Reset to "none" combo box entry */
if (!timer_button_enabled) if (!timer_button_enabled)
gtk_entry_set_text( gtk_combo_box_set_active(GTK_COMBO_BOX(timer_iface_combo_box), 0);
GTK_ENTRY(GTK_COMBO(timer_iface_combo)->entry), "none"); gtk_widget_set_sensitive(timer_iface_combo_box, timer_button_enabled);
gtk_widget_set_sensitive(timer_iface_combo, timer_button_enabled);
} }
net_timer_visibility(); net_timer_visibility();
} }
@ -2770,9 +2771,11 @@ static void
cb_timer_iface(GtkWidget *widget, gpointer data) cb_timer_iface(GtkWidget *widget, gpointer data)
{ {
gchar *s; gchar *s;
GtkWidget *entry;
s = gkrellm_gtk_entry_get_text(&(GTK_COMBO(timer_iface_combo)->entry)); entry = gtk_bin_get_child(GTK_BIN(timer_iface_combo_box));
if (*s == '\0') s = gkrellm_gtk_entry_get_text(&entry);
if (*s == '\0' || strcmp(s, _("none")) == 0)
s = "none"; s = "none";
if (gkrellm_dup_string(&timer_button_iface, s)) if (gkrellm_dup_string(&timer_button_iface, s))
{ {
@ -2950,28 +2953,28 @@ create_net_tab(GtkWidget *tab_vbox)
timer_seconds, FALSE, FALSE, 0, timer_seconds, FALSE, FALSE, 0,
cb_timer_seconds, NULL, cb_timer_seconds, NULL,
_("Show seconds")); _("Show seconds"));
gtk_widget_set_sensitive(net_timer_seconds_button, timer_button_enabled);
hbox = gtk_hbox_new (FALSE, 3); hbox = gtk_hbox_new (FALSE, 3);
gtk_container_set_border_width(GTK_CONTAINER(hbox), 0); gtk_container_set_border_width(GTK_CONTAINER(hbox), 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 50); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 50);
if (!_GK.client_mode) if (!_GK.client_mode)
{ {
timer_iface_combo = gtk_combo_new(); timer_iface_combo_box = gtk_combo_box_entry_new_text();
gtk_box_pack_start(GTK_BOX(hbox), timer_iface_combo, FALSE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox), timer_iface_combo_box, TRUE, TRUE, 0);
list = NULL; gtk_widget_set_sensitive(timer_iface_combo_box, timer_button_enabled);
list = g_list_append(list, _("none")); gtk_combo_box_append_text(GTK_COMBO_BOX(timer_iface_combo_box),
_("none"));
for (tlist = timer_defaults_list; tlist; tlist = tlist->next) for (tlist = timer_defaults_list; tlist; tlist = tlist->next)
{ {
tt = (TimerType *) tlist->data; tt = (TimerType *) tlist->data;
list = g_list_append(list, tt->name); gtk_combo_box_append_text(GTK_COMBO_BOX(timer_iface_combo_box),
tt->name);
} }
gtk_combo_set_popdown_strings(GTK_COMBO(timer_iface_combo), list); gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(
gtk_combo_set_case_sensitive(GTK_COMBO(timer_iface_combo), TRUE); GTK_BIN(timer_iface_combo_box))), timer_button_iface);
g_list_free(list); g_signal_connect(G_OBJECT(timer_iface_combo_box), "changed",
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(timer_iface_combo)->entry), G_CALLBACK(cb_timer_iface), NULL);
timer_button_iface);
g_signal_connect(G_OBJECT(GTK_COMBO(timer_iface_combo)->entry),
"changed", G_CALLBACK(cb_timer_iface), NULL);
label = gtk_label_new(_("Interface to link to the timer button")); label = gtk_label_new(_("Interface to link to the timer button"));
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, TRUE, 0);
@ -3062,25 +3065,23 @@ create_net_tab(GtkWidget *tab_vbox)
vbox1 = gkrellm_gtk_category_vbox(vbox, vbox1 = gkrellm_gtk_category_vbox(vbox,
_("Format String for Chart Labels"), _("Format String for Chart Labels"),
4, 0, TRUE); 4, 0, TRUE);
text_format_combo = gtk_combo_new(); text_format_combo_box = gtk_combo_box_entry_new_text();
gtk_widget_set_size_request (GTK_WIDGET(text_format_combo), 300, -1); gtk_widget_set_size_request (GTK_WIDGET(text_format_combo_box), 300, -1);
gtk_box_pack_start(GTK_BOX(vbox1), text_format_combo, FALSE, FALSE, 2); gtk_box_pack_start(GTK_BOX(vbox1), text_format_combo_box, FALSE, FALSE, 2);
list = NULL; gtk_combo_box_append_text(GTK_COMBO_BOX(text_format_combo_box), text_format);
list = g_list_append(list, text_format); gtk_combo_box_append_text(GTK_COMBO_BOX(text_format_combo_box),
list = g_list_append(list, DEFAULT_TEXT_FORMAT); DEFAULT_TEXT_FORMAT);
list = g_list_append(list, "\\c\\f$M\\n$T\\b\\c\\f$L"); gtk_combo_box_append_text(GTK_COMBO_BOX(text_format_combo_box),
list = g_list_append(list, "\\c\\f$M\\n$T\\b\\c\\f$L");
gtk_combo_box_append_text(GTK_COMBO_BOX(text_format_combo_box),
_("\\f\\ww\\c\\f$M\\n\\f\\at\\.$t\\n\\f\\ar\\.$r\\b\\c\\f$L")); _("\\f\\ww\\c\\f$M\\n\\f\\at\\.$t\\n\\f\\ar\\.$r\\b\\c\\f$L"));
list = g_list_append(list, gtk_combo_box_append_text(GTK_COMBO_BOX(text_format_combo_box),
_("\\f\\ww\\c\\f$M\\n\\f\\at\\.$o\\n\\f\\ar\\.$i\\b\\c\\f$L")); _("\\f\\ww\\c\\f$M\\n\\f\\at\\.$o\\n\\f\\ar\\.$i\\b\\c\\f$L"));
list = g_list_append(list, gtk_combo_box_append_text(GTK_COMBO_BOX(text_format_combo_box),
_("\\f\\ww\\c\\f$M\\D2\\f\\ar\\.$r\\D1\\f\\at\\.$t\\b\\c\\f$L")); _("\\f\\ww\\c\\f$M\\D2\\f\\ar\\.$r\\D1\\f\\at\\.$t\\b\\c\\f$L"));
gtk_combo_set_popdown_strings(GTK_COMBO(text_format_combo), list); gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(text_format_combo_box))),
gtk_combo_set_case_sensitive(GTK_COMBO(text_format_combo), TRUE); text_format);
g_list_free(list); g_signal_connect(G_OBJECT(GTK_COMBO_BOX(text_format_combo_box)), "changed",
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(text_format_combo)->entry),
text_format);
g_signal_connect(G_OBJECT(GTK_COMBO(text_format_combo)->entry), "changed",
G_CALLBACK(cb_text_format), NULL); G_CALLBACK(cb_text_format), NULL);
gkrellm_gtk_spin_button(vbox, NULL, (gfloat) reset_mday, gkrellm_gtk_spin_button(vbox, NULL, (gfloat) reset_mday,