- Switch from deprecated GtkCombo to GtkComboBox (new since GTK+ 2.4)

This commit is contained in:
Stefan Gehn 2008-09-30 16:50:17 +00:00
parent 2ac45ba0de
commit 2119506e02
4 changed files with 120 additions and 132 deletions

View File

@ -22,35 +22,23 @@
#include "gkrellm.h"
#include "gkrellm-private.h"
#ifdef WIN32
#if defined(WIN32)
#define DEFAULT_CLOCK_FORMAT \
"%#I:%M <span foreground=\"$A\"><small>%S</small></span>"
#define ALT1_CLOCK_FORMAT \
"%#I:%M <span foreground=\"$A\"><small>%p</small></span>"
#define ALT2_CLOCK_FORMAT \
"%#H:%M <span foreground=\"$A\"><small>%S</small></span>"
#define DEFAULT_CAL_FORMAT \
"%a <span foreground=\"$A\"><big><big>%#d</big></big></span> %b"
#define ALT1_CAL_FORMAT \
"<big>%a %b <span foreground=\"$A\">%#d</span></big>"
#define ALT2_CAL_FORMAT \
"%a <span foreground=\"cyan2\"><span font_desc=\"16.5\"><i>%#d</i></span></span> %b"
#define DEFAULT_CLOCK_FORMAT "%#I:%M <span foreground=\"$A\"><small>%S</small></span>"
#define ALT1_CLOCK_FORMAT "%#I:%M <span foreground=\"$A\"><small>%p</small></span>"
#define ALT2_CLOCK_FORMAT "%#H:%M <span foreground=\"$A\"><small>%S</small></span>"
#define DEFAULT_CAL_FORMAT "%a <span foreground=\"$A\"><big><big>%#d</big></big></span> %b"
#define ALT1_CAL_FORMAT "<big>%a %b <span foreground=\"$A\">%#d</span></big>"
#define ALT2_CAL_FORMAT "%a <span foreground=\"cyan2\"><span font_desc=\"16.5\"><i>%#d</i></span></span> %b"
#else
#define DEFAULT_CLOCK_FORMAT \
"%l:%M <span foreground=\"$A\"><small>%S</small></span>"
#define ALT1_CLOCK_FORMAT \
"%l:%M <span foreground=\"$A\"><small>%p</small></span>"
#define ALT2_CLOCK_FORMAT \
"%k:%M <span foreground=\"$A\"><small>%S</small></span>"
#define DEFAULT_CAL_FORMAT \
"%a <span foreground=\"$A\"><big><big>%e</big></big></span> %b"
#define ALT1_CAL_FORMAT \
"<big>%a %b <span foreground=\"$A\">%e</span></big>"
#define ALT2_CAL_FORMAT \
"%a <span foreground=\"cyan2\"><span font_desc=\"16.5\"><i>%e</i></span></span> %b"
#define DEFAULT_CLOCK_FORMAT "%l:%M <span foreground=\"$A\"><small>%S</small></span>"
#define ALT1_CLOCK_FORMAT "%l:%M <span foreground=\"$A\"><small>%p</small></span>"
#define ALT2_CLOCK_FORMAT "%k:%M <span foreground=\"$A\"><small>%S</small></span>"
#define DEFAULT_CAL_FORMAT "%a <span foreground=\"$A\"><big><big>%e</big></big></span> %b"
#define ALT1_CAL_FORMAT "<big>%a %b <span foreground=\"$A\">%e</span></big>"
#define ALT2_CAL_FORMAT "%a <span foreground=\"cyan2\"><span font_desc=\"16.5\"><i>%e</i></span></span> %b"
#endif
@ -572,8 +560,8 @@ static GtkWidget *cal_launch_entry,
*cal_enable_button,
*loop_chime_button;
static GtkWidget *cal_format_combo,
*clock_format_combo;
static GtkWidget *cal_format_combo_box,
*clock_format_combo_box;
static void
@ -626,10 +614,10 @@ static void
cal_format_cb(GtkWidget *widget, gpointer data)
{
gchar *s, *check;
GtkWidget *entry;
s = gtk_combo_box_get_active_text(GTK_COMBO_BOX(cal_format_combo));
if (s == NULL)
return;
entry = gtk_bin_get_child(GTK_BIN(cal_format_combo_box));
s = gkrellm_gtk_entry_get_text(&entry);
check = strftime_format(s, cal_alt_color_string);
@ -653,8 +641,10 @@ static void
clock_format_cb(GtkWidget *widget, gpointer data)
{
gchar *s, *check;
GtkWidget *entry;
s = gtk_combo_box_get_active_text(GTK_COMBO_BOX(clock_format_combo));
entry = gtk_bin_get_child(GTK_BIN(clock_format_combo_box));
s = gkrellm_gtk_entry_get_text(&entry);
check = strftime_format(s, clock_alt_color_string);
@ -717,14 +707,14 @@ create_clock_tab(GtkWidget *tab_vbox)
gtk_box_pack_start(GTK_BOX(vbox1), hbox, FALSE, FALSE, 6);
label = gtk_label_new(_("Display format string:"));
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 2);
cal_format_combo = gtk_combo_box_entry_new_text();
gtk_box_pack_start(GTK_BOX(vbox1), cal_format_combo, TRUE, TRUE, 0);
gtk_combo_box_append_text(GTK_COMBO_BOX(cal_format_combo), cal_format);
gtk_combo_box_append_text(GTK_COMBO_BOX(cal_format_combo), DEFAULT_CAL_FORMAT);
gtk_combo_box_append_text(GTK_COMBO_BOX(cal_format_combo), ALT1_CAL_FORMAT);
gtk_combo_box_append_text(GTK_COMBO_BOX(cal_format_combo), ALT2_CAL_FORMAT);
gtk_combo_box_set_active(GTK_COMBO_BOX(cal_format_combo), 0);
g_signal_connect(G_OBJECT(GTK_COMBO_BOX(cal_format_combo)), "changed",
cal_format_combo_box = gtk_combo_box_entry_new_text();
gtk_box_pack_start(GTK_BOX(vbox1), cal_format_combo_box, TRUE, TRUE, 0);
gtk_combo_box_append_text(GTK_COMBO_BOX(cal_format_combo_box), cal_format);
gtk_combo_box_append_text(GTK_COMBO_BOX(cal_format_combo_box), DEFAULT_CAL_FORMAT);
gtk_combo_box_append_text(GTK_COMBO_BOX(cal_format_combo_box), ALT1_CAL_FORMAT);
gtk_combo_box_append_text(GTK_COMBO_BOX(cal_format_combo_box), ALT2_CAL_FORMAT);
gtk_combo_box_set_active(GTK_COMBO_BOX(cal_format_combo_box), 0);
g_signal_connect(G_OBJECT(GTK_COMBO_BOX(cal_format_combo_box)), "changed",
G_CALLBACK(cal_format_cb), NULL);
vbox1 = gkrellm_gtk_category_vbox(vbox, _("Clock"), 4, 0, TRUE);
@ -736,14 +726,14 @@ create_clock_tab(GtkWidget *tab_vbox)
gtk_box_pack_start(GTK_BOX(vbox1), hbox, FALSE, FALSE, 6);
label = gtk_label_new(_("Display format string:"));
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 2);
clock_format_combo = gtk_combo_box_entry_new_text();
gtk_box_pack_start(GTK_BOX(vbox1), clock_format_combo, TRUE, TRUE, 0);
gtk_combo_box_append_text(GTK_COMBO_BOX(clock_format_combo), clock_format);
gtk_combo_box_append_text(GTK_COMBO_BOX(clock_format_combo), DEFAULT_CLOCK_FORMAT);
gtk_combo_box_append_text(GTK_COMBO_BOX(clock_format_combo), ALT1_CLOCK_FORMAT);
gtk_combo_box_append_text(GTK_COMBO_BOX(clock_format_combo), ALT2_CLOCK_FORMAT);
gtk_combo_box_set_active(GTK_COMBO_BOX(clock_format_combo), 0);
g_signal_connect(G_OBJECT(GTK_COMBO_BOX(clock_format_combo)), "changed",
clock_format_combo_box = gtk_combo_box_entry_new_text();
gtk_box_pack_start(GTK_BOX(vbox1), clock_format_combo_box, TRUE, TRUE, 0);
gtk_combo_box_append_text(GTK_COMBO_BOX(clock_format_combo_box), clock_format);
gtk_combo_box_append_text(GTK_COMBO_BOX(clock_format_combo_box), DEFAULT_CLOCK_FORMAT);
gtk_combo_box_append_text(GTK_COMBO_BOX(clock_format_combo_box), ALT1_CLOCK_FORMAT);
gtk_combo_box_append_text(GTK_COMBO_BOX(clock_format_combo_box), ALT2_CLOCK_FORMAT);
gtk_combo_box_set_active(GTK_COMBO_BOX(clock_format_combo_box), 0);
g_signal_connect(G_OBJECT(GTK_COMBO_BOX(clock_format_combo_box)), "changed",
G_CALLBACK(clock_format_cb), NULL);
/* -- Setup tab */

View File

@ -24,7 +24,9 @@
#include "gkrellm-sysdeps.h"
#define DEFAULT_DATA_FORMAT ("$t - $f free")
#define DEFAULT_DATA_FORMAT (_("$t - $f free"))
#define ALT1_DATA_FORMAT (_("$t - $u used"))
#define ALT2_DATA_FORMAT (_("$t - $U"))
/* Values for force_fs_check */
@ -1495,7 +1497,7 @@ static GtkTreeSelection *selection;
static GtkWidget
*label_entry,
*dir_combo,
*dir_combo_box,
*mount_entry,
*umount_entry,
*mounting_button,
@ -1508,7 +1510,7 @@ static GtkWidget
static GtkWidget *alert_button;
static GtkWidget *data_format_combo;
static GtkWidget *data_format_combo_box;
static gboolean (*original_row_drop_possible)();
@ -1666,14 +1668,17 @@ cb_alert_config(GkrellmAlert *ap, FSmon *fs)
| fstab entries and accordingly set sensitivity of the mounting_button.
*/
static void
cb_combo_changed(GtkWidget *widget)
cb_combo_changed(GtkComboBox *widget, gpointer user_data)
{
Mount *m;
gchar *s;
GtkWidget *entry;
if (!mounting_supported || _GK.client_mode)
return;
s = gkrellm_gtk_entry_get_text(&(GTK_COMBO(dir_combo)->entry));
entry = gtk_bin_get_child(GTK_BIN(dir_combo_box));
s = gkrellm_gtk_entry_get_text(&entry);
m = in_fstab_list(s);
if (m && (fstab_user_permission(m) || uid == 0))
{
@ -1765,7 +1770,7 @@ static void
reset_entries(gboolean level0)
{
gtk_entry_set_text(GTK_ENTRY(label_entry), "");
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(dir_combo)->entry), "");
gtk_combo_box_set_active(GTK_COMBO_BOX(dir_combo_box), -1);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(secondary_button), level0);
if (mounting_button)
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mounting_button),FALSE);
@ -1857,8 +1862,8 @@ cb_tree_selection_changed(GtkTreeSelection *selection, gpointer data)
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(secondary_button),
secondary);
gtk_entry_set_text(GTK_ENTRY(label_entry), fs->label);
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(dir_combo)->entry),
fs->mount.directory);
gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(dir_combo_box))),
fs->mount.directory);
if (show_button)
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(show_button),
fs->show_if_mounted);
@ -1980,8 +1985,9 @@ add_cb(GtkWidget *widget)
label = gkrellm_gtk_entry_get_text(&label_entry);
gkrellm_locale_dup_string(&fs->label, label, &fs->label_shadow);
fs->mount.directory =
g_strdup(gkrellm_gtk_entry_get_text(&(GTK_COMBO(dir_combo)->entry)));
fs->mount.directory = gtk_combo_box_get_active_text(
GTK_COMBO_BOX(dir_combo_box));
if (show_button)
fs->show_if_mounted = GTK_TOGGLE_BUTTON(show_button)->active;
if (mounting_button)
@ -2102,8 +2108,10 @@ cb_data_format(GtkWidget *widget, gpointer data)
GkrellmDecal *d;
gchar *s, buf[256];
gint h_data, h_label;
GtkWidget *entry;
s = gkrellm_gtk_entry_get_text(&(GTK_COMBO(data_format_combo)->entry));
entry = gtk_bin_get_child(GTK_BIN(data_format_combo_box));
s = gkrellm_gtk_entry_get_text(&entry);
/* In case Pango markup tags, don't accept line unless valid markup.
| Ie, markup like <span ...> xxx </span> or <b> xxx </b>
@ -2243,7 +2251,7 @@ create_fs_panels_page(GtkWidget *vbox)
GtkWidget *scrolled;
GtkTreeModel *model;
GtkCellRenderer *renderer;
GList *list, *combo_list;
GList *list;
hbox = gtk_hbox_new(FALSE, 0);
@ -2268,18 +2276,16 @@ create_fs_panels_page(GtkWidget *vbox)
#endif
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2,
GTK_SHRINK, GTK_SHRINK, 2, 1);
dir_combo = gtk_combo_new();
gtk_table_attach_defaults(GTK_TABLE(table), dir_combo, 1, 2, 1, 2);
combo_list = NULL;
dir_combo_box = gtk_combo_box_entry_new_text();
gtk_table_attach_defaults(GTK_TABLE(table), dir_combo_box, 1, 2, 1, 2);
for (list = fstab_list; list; list = list->next)
combo_list = g_list_append(combo_list,
((Mount *)list->data)->directory);
gtk_combo_set_popdown_strings( GTK_COMBO(dir_combo), combo_list);
gtk_combo_set_case_sensitive(GTK_COMBO(dir_combo), TRUE);
g_list_free(combo_list);
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(dir_combo)->entry), "");
g_signal_connect(G_OBJECT(GTK_COMBO(dir_combo)->entry),
"changed", GTK_SIGNAL_FUNC (cb_combo_changed), NULL);
{
gtk_combo_box_append_text(GTK_COMBO_BOX(dir_combo_box),
((Mount *)list->data)->directory);
}
gtk_combo_box_set_active(GTK_COMBO_BOX(dir_combo_box), -1);
g_signal_connect(G_OBJECT(GTK_COMBO_BOX(dir_combo_box)),
"changed", G_CALLBACK(cb_combo_changed), NULL);
vbox1 = gtk_vbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), vbox1, FALSE, FALSE, 0);
@ -2489,7 +2495,6 @@ fs_tab_create(GtkWidget *tab_vbox)
GtkWidget *tabs;
GtkWidget *vbox, *vbox1;
GtkWidget *text;
GList *list;
gint i;
row_reference = NULL;
@ -2543,19 +2548,14 @@ fs_tab_create(GtkWidget *tab_vbox)
vbox1 = gkrellm_gtk_category_vbox(vbox,
_("Format String for Panel Labels"),
4, 0, TRUE);
data_format_combo = gtk_combo_new();
gtk_box_pack_start(GTK_BOX(vbox1), data_format_combo, FALSE, FALSE, 2);
list = NULL;
list = g_list_append(list, data_format);
list = g_list_append(list, DEFAULT_DATA_FORMAT);
list = g_list_append(list, _("$t - $u used"));
list = g_list_append(list, _("$t - $U"));
gtk_combo_set_popdown_strings(GTK_COMBO(data_format_combo), list);
gtk_combo_set_case_sensitive(GTK_COMBO(data_format_combo), TRUE);
g_list_free(list);
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(data_format_combo)->entry),
data_format);
g_signal_connect(G_OBJECT(GTK_COMBO(data_format_combo)->entry), "changed",
data_format_combo_box = gtk_combo_box_entry_new_text();
gtk_box_pack_start(GTK_BOX(vbox1), data_format_combo_box, FALSE, FALSE, 2);
gtk_combo_box_append_text(GTK_COMBO_BOX(data_format_combo_box), data_format);
gtk_combo_box_append_text(GTK_COMBO_BOX(data_format_combo_box), DEFAULT_DATA_FORMAT);
gtk_combo_box_append_text(GTK_COMBO_BOX(data_format_combo_box), ALT1_DATA_FORMAT);
gtk_combo_box_append_text(GTK_COMBO_BOX(data_format_combo_box), ALT2_DATA_FORMAT);
gtk_combo_box_set_active(GTK_COMBO_BOX(data_format_combo_box), 0);
g_signal_connect(G_OBJECT(GTK_COMBO_BOX(data_format_combo_box)), "changed",
G_CALLBACK(cb_data_format), NULL);
/* --Info tab */

View File

@ -1409,7 +1409,7 @@ static GtkWidget *launch_vbox;
static GtkWidget *data0_range_button,
*data1_range_button;
static GtkWidget *text_format_combo;
static GtkWidget *text_format_combo_box;
static void
@ -1757,8 +1757,10 @@ cb_text_format(GtkWidget *widget, gpointer data)
{
GList *list;
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);
for (list = inet_mon_list; list; list = list->next)
draw_inet_chart((InetMon *) list->data);
@ -2005,21 +2007,19 @@ create_inet_tab(GtkWidget *tab_vbox)
vbox1 = gkrellm_gtk_category_vbox(vbox,
_("Format String for Chart Labels"),
4, 0, TRUE);
text_format_combo = gtk_combo_new();
gtk_box_pack_start(GTK_BOX(vbox1), text_format_combo, FALSE, FALSE, 2);
list = NULL;
list = g_list_append(list, text_format);
list = g_list_append(list, DEFAULT_TEXT_FORMAT);
list = g_list_append(list,
"\\r\\f $M\\t$a\\f $l\\N$A\\f $L");
list = g_list_append(list,
"\\r\\f $M\\D1$a\\f $l\\D2$A\\f $L");
gtk_combo_set_popdown_strings(GTK_COMBO(text_format_combo), list);
gtk_combo_set_case_sensitive(GTK_COMBO(text_format_combo), TRUE);
g_list_free(list);
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(text_format_combo)->entry),
text_format_combo_box = gtk_combo_box_entry_new_text();
gtk_box_pack_start(GTK_BOX(vbox1), text_format_combo_box, FALSE, FALSE, 2);
gtk_combo_box_append_text(GTK_COMBO_BOX(text_format_combo_box),
text_format);
g_signal_connect(G_OBJECT(GTK_COMBO(text_format_combo)->entry), "changed",
gtk_combo_box_append_text(GTK_COMBO_BOX(text_format_combo_box),
DEFAULT_TEXT_FORMAT);
gtk_combo_box_append_text(GTK_COMBO_BOX(text_format_combo_box),
"\\r\\f $M\\t$a\\f $l\\N$A\\f $L");
gtk_combo_box_append_text(GTK_COMBO_BOX(text_format_combo_box),
"\\r\\f $M\\D1$a\\f $l\\D2$A\\f $L");
gtk_combo_box_set_active(GTK_COMBO_BOX(text_format_combo_box), 0);
g_signal_connect(G_OBJECT(GTK_COMBO_BOX(text_format_combo_box)), "changed",
G_CALLBACK(cb_text_format), NULL);
vbox1 = gkrellm_gtk_category_vbox(vbox,

View File

@ -756,7 +756,7 @@ load_proc_config(gchar *arg)
static GtkWidget *proc_launch_entry,
*proc_tooltip_entry;
static GtkWidget *text_format_combo;
static GtkWidget *text_format_combo_box;
static GtkWidget *load_alert_button,
*users_alert_button,
@ -802,9 +802,11 @@ cb_sensor_separate(GtkWidget *button, gpointer data)
static void
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);
new_text_format = TRUE;
refresh_proc_chart(proc.chart);
@ -894,7 +896,6 @@ static void
create_proc_tab(GtkWidget *tab_vbox)
{
GtkWidget *tabs, *table, *vbox, *vbox1, *hbox, *text, *label;
GList *list;
gint i;
tabs = gtk_notebook_new();
@ -947,20 +948,17 @@ create_proc_tab(GtkWidget *tab_vbox)
vbox1 = gkrellm_gtk_category_vbox(vbox,
_("Format String for Chart Labels"),
4, 0, TRUE);
text_format_combo = gtk_combo_new();
gtk_widget_set_size_request (GTK_WIDGET(text_format_combo), 350, -1);
gtk_box_pack_start(GTK_BOX(vbox1), text_format_combo, FALSE, FALSE, 2);
list = NULL;
list = g_list_append(list, text_format);
list = g_list_append(list, _(DEFAULT_TEXT_FORMAT));
list = g_list_append(list,
text_format_combo_box = gtk_combo_box_entry_new_text();
gtk_widget_set_size_request (GTK_WIDGET(text_format_combo_box), 350, -1);
gtk_box_pack_start(GTK_BOX(vbox1), text_format_combo_box, FALSE, FALSE, 2);
gtk_combo_box_append_text(GTK_COMBO_BOX(text_format_combo_box), text_format);
gtk_combo_box_append_text(GTK_COMBO_BOX(text_format_combo_box),
_(DEFAULT_TEXT_FORMAT));
gtk_combo_box_append_text(GTK_COMBO_BOX(text_format_combo_box),
_("\\f$L\\r\\f$F \\w88\\b\\p\\a$p\\f procs\\n\\e$u\\f users"));
gtk_combo_set_popdown_strings(GTK_COMBO(text_format_combo), list);
gtk_combo_set_case_sensitive(GTK_COMBO(text_format_combo), TRUE);
g_list_free(list);
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",
gtk_combo_box_set_active(GTK_COMBO_BOX(text_format_combo_box), 0);
g_signal_connect(G_OBJECT(GTK_COMBO_BOX(text_format_combo_box)), "changed",
G_CALLBACK(cb_text_format), NULL);
vbox1 = gkrellm_gtk_category_vbox(vbox,