diff options
Diffstat (limited to 'filter')
-rw-r--r-- | filter/ChangeLog | 10 | ||||
-rw-r--r-- | filter/filter-datespec.c | 49 | ||||
-rw-r--r-- | filter/filter-option.c | 57 | ||||
-rw-r--r-- | filter/filter-rule.c | 80 | ||||
-rw-r--r-- | filter/filter.glade | 171 |
5 files changed, 124 insertions, 243 deletions
diff --git a/filter/ChangeLog b/filter/ChangeLog index a30463deb5..656210ddce 100644 --- a/filter/ChangeLog +++ b/filter/ChangeLog @@ -1,3 +1,13 @@ +2009-04-24 Milan Crha <mcrha@redhat.com> + + ** Fix for bug #572348 + + * filter.glade: + * filter-datespec.c: + * filter-rule.c: + * filter-option.c: + Remove deprecated Gtk+ symbols. + 2009-01-11 Tor Lillqvist <tml@novell.com> * filter-option.c (get_dynamic_options): Add cast to avoid diff --git a/filter/filter-datespec.c b/filter/filter-datespec.c index 82b0e08197..599681c4d4 100644 --- a/filter/filter-datespec.c +++ b/filter/filter-datespec.c @@ -95,7 +95,7 @@ static const timespan timespans[] = { struct _FilterDatespecPrivate { GtkWidget *label_button; - GtkWidget *notebook_type, *option_type, *calendar_specify, *spin_relative, *option_relative, *option_past_future; + GtkWidget *notebook_type, *combobox_type, *calendar_specify, *spin_relative, *combobox_relative, *combobox_past_future; FilterDatespec_type type; int span; }; @@ -385,49 +385,39 @@ set_values (FilterDatespec *fds) case FDST_X_AGO: p->span = get_best_span(fds->value); gtk_spin_button_set_value((GtkSpinButton*)p->spin_relative, fds->value/timespans[p->span].seconds); - gtk_option_menu_set_history((GtkOptionMenu*)p->option_relative, p->span); - gtk_option_menu_set_history((GtkOptionMenu*)p->option_past_future, 0); + gtk_combo_box_set_active (GTK_COMBO_BOX (p->combobox_relative), p->span); + gtk_combo_box_set_active (GTK_COMBO_BOX (p->combobox_past_future), 0); break; case FDST_X_FUTURE: p->span = get_best_span(fds->value); gtk_spin_button_set_value((GtkSpinButton*)p->spin_relative, fds->value/timespans[p->span].seconds); - gtk_option_menu_set_history((GtkOptionMenu*)p->option_relative, p->span); - gtk_option_menu_set_history((GtkOptionMenu*)p->option_past_future, 1); + gtk_combo_box_set_active (GTK_COMBO_BOX (p->combobox_relative), p->span); + gtk_combo_box_set_active (GTK_COMBO_BOX (p->combobox_past_future), 1); break; } gtk_notebook_set_current_page ((GtkNotebook*) p->notebook_type, note_type); - gtk_option_menu_set_history ((GtkOptionMenu*) p->option_type, note_type); + gtk_combo_box_set_active (GTK_COMBO_BOX (p->combobox_type), note_type); } static void -set_option_type (GtkMenu *menu, FilterDatespec *fds) +set_combobox_type (GtkComboBox *combobox, FilterDatespec *fds) { - GtkWidget *w; - - /* ugh, no other way to 'get_history' */ - w = gtk_menu_get_active (menu); - fds->priv->type = g_list_index (GTK_MENU_SHELL (menu)->children, w); + fds->priv->type = gtk_combo_box_get_active (combobox); gtk_notebook_set_current_page ((GtkNotebook*) fds->priv->notebook_type, fds->priv->type); } static void -set_option_relative (GtkMenu *menu, FilterDatespec *fds) +set_combobox_relative (GtkComboBox *combobox, FilterDatespec *fds) { - GtkWidget *w; - - w = gtk_menu_get_active (menu); - fds->priv->span = g_list_index (GTK_MENU_SHELL (menu)->children, w); + fds->priv->span = gtk_combo_box_get_active (combobox); } static void -set_option_past_future (GtkMenu *menu, FilterDatespec *fds) +set_combobox_past_future (GtkComboBox *combobox, FilterDatespec *fds) { - GtkWidget *w; - - w = gtk_menu_get_active (menu); - if(g_list_index (GTK_MENU_SHELL (menu)->children, w) == 0) + if (gtk_combo_box_get_active (combobox) == 0) fds->type = fds->priv->type = FDST_X_AGO; else fds->type = fds->priv->type = FDST_X_FUTURE; @@ -457,20 +447,17 @@ button_clicked (GtkButton *button, FilterDatespec *fds) gtk_dialog_set_has_separator (dialog, FALSE); p->notebook_type = glade_xml_get_widget (gui, "notebook_type"); - p->option_type = glade_xml_get_widget (gui, "option_type"); + p->combobox_type = glade_xml_get_widget (gui, "combobox_type"); p->calendar_specify = glade_xml_get_widget (gui, "calendar_specify"); p->spin_relative = glade_xml_get_widget (gui, "spin_relative"); - p->option_relative = glade_xml_get_widget (gui, "option_relative"); - p->option_past_future = glade_xml_get_widget (gui, "option_past_future"); + p->combobox_relative = glade_xml_get_widget (gui, "combobox_relative"); + p->combobox_past_future = glade_xml_get_widget (gui, "combobox_past_future"); set_values (fds); - g_signal_connect (GTK_OPTION_MENU (p->option_type)->menu, "deactivate", - G_CALLBACK (set_option_type), fds); - g_signal_connect (GTK_OPTION_MENU (p->option_relative)->menu, "deactivate", - G_CALLBACK (set_option_relative), fds); - g_signal_connect (GTK_OPTION_MENU (p->option_past_future)->menu, "deactivate", - G_CALLBACK (set_option_past_future), fds); + g_signal_connect (p->combobox_type, "changed", G_CALLBACK (set_combobox_type), fds); + g_signal_connect (p->combobox_relative, "changed", G_CALLBACK (set_combobox_relative), fds); + g_signal_connect (p->combobox_past_future, "changed", G_CALLBACK (set_combobox_past_future), fds); gtk_box_pack_start ((GtkBox *) dialog->vbox, toplevel, TRUE, TRUE, 3); diff --git a/filter/filter-option.c b/filter/filter-option.c index 7af511b543..2e76eca1c3 100644 --- a/filter/filter-option.c +++ b/filter/filter-option.c @@ -342,11 +342,34 @@ xml_decode (FilterElement *fe, xmlNodePtr node) } static void -option_changed (GtkWidget *widget, FilterElement *fe) +combobox_changed (GtkWidget *widget, FilterElement *fe) { FilterOption *fo = (FilterOption *)fe; - fo->current = g_object_get_data ((GObject *) widget, "option"); + fo->current = (struct _filter_option *) g_list_nth (fo->options, gtk_combo_box_get_active (GTK_COMBO_BOX (widget))); +} + +static GSList * +get_dynamic_options (FilterOption *fo) +{ + GModule *module; + GSList *(*get_func)(void); + GSList *res = NULL; + + if (!fo || !fo->dynamic_func) + return res; + + module = g_module_open (NULL, G_MODULE_BIND_LAZY); + + if (g_module_symbol (module, fo->dynamic_func, (gpointer) &get_func)) { + res = get_func (); + } else { + g_warning ("optionlist dynamic fill function '%s' not found", fo->dynamic_func); + } + + g_module_close (module); + + return res; } static GSList * @@ -376,10 +399,7 @@ static GtkWidget * get_widget (FilterElement *fe) { FilterOption *fo = (FilterOption *)fe; - GtkWidget *menu; - GtkWidget *omenu; - GtkWidget *item; - GtkWidget *first = NULL; + GtkWidget *combobox; GList *l; struct _filter_option *op; int index = 0, current = 0; @@ -436,35 +456,20 @@ get_widget (FilterElement *fe) g_list_free (old_ops); } - menu = gtk_menu_new (); + combobox = gtk_combo_box_new_text (); l = fo->options; while (l) { op = l->data; - item = gtk_menu_item_new_with_label (_(op->title)); - g_object_set_data ((GObject *) item, "option", op); - g_signal_connect (item, "activate", G_CALLBACK (option_changed), fe); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); - gtk_widget_show (item); - if (op == fo->current) { - current = index; - first = item; - } else if (!first) { - first = item; - } + gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _(op->title)); l = g_list_next (l); index++; } - omenu = gtk_option_menu_new (); - gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu); - - if (first) - g_signal_emit_by_name (first, "activate", fe); - - gtk_option_menu_set_history (GTK_OPTION_MENU (omenu), current); + g_signal_connect (combobox, "changed", G_CALLBACK (combobox_changed), fe); + gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), current); - return omenu; + return combobox; } static void diff --git a/filter/filter-rule.c b/filter/filter-rule.c index 9febe8d0ee..7972de13d0 100644 --- a/filter/filter-rule.c +++ b/filter/filter-rule.c @@ -605,13 +605,13 @@ build_code (FilterRule *fr, GString *out) static void fr_grouping_changed(GtkWidget *w, FilterRule *fr) { - fr->grouping = gtk_option_menu_get_history((GtkOptionMenu *)w); + fr->grouping = gtk_combo_box_get_active (GTK_COMBO_BOX (w)); } static void fr_threading_changed(GtkWidget *w, FilterRule *fr) { - fr->threading = gtk_option_menu_get_history((GtkOptionMenu *)w); + fr->threading = gtk_combo_box_get_active (GTK_COMBO_BOX (w)); } struct _part_data { @@ -622,11 +622,20 @@ struct _part_data { }; static void -option_activate (GtkMenuItem *item, struct _part_data *data) +part_combobox_changed (GtkComboBox *combobox, struct _part_data *data) { - FilterPart *part = g_object_get_data ((GObject *) item, "part"); + FilterPart *part = NULL; FilterPart *newpart; + int index, i; + + index = gtk_combo_box_get_active (combobox); + for (i = 0, part = rule_context_next_part (data->f, part); part && i < index; i++, part = rule_context_next_part (data->f, part)) { + /* traverse until reached index */ + } + g_return_if_fail (part != NULL); + g_return_if_fail (i == index); + /* dont update if we haven't changed */ if (!strcmp (part->title, data->part->title)) return; @@ -644,17 +653,13 @@ option_activate (GtkMenuItem *item, struct _part_data *data) data->partwidget = filter_part_get_widget (newpart); if (data->partwidget) gtk_box_pack_start (GTK_BOX (data->container), data->partwidget, TRUE, TRUE, 0); - - g_object_set_data ((GObject *) data->container, "part", newpart); } static GtkWidget * get_rule_part_widget (RuleContext *f, FilterPart *newpart, FilterRule *fr) { FilterPart *part = NULL; - GtkWidget *menu; - GtkWidget *item; - GtkWidget *omenu; + GtkWidget *combobox; GtkWidget *hbox; GtkWidget *p; int index = 0, current = 0; @@ -674,26 +679,23 @@ get_rule_part_widget (RuleContext *f, FilterPart *newpart, FilterRule *fr) data->partwidget = p; data->container = hbox; - menu = gtk_menu_new (); + combobox = gtk_combo_box_new_text (); + /* sigh, this is a little ugly */ while ((part = rule_context_next_part (f, part))) { - item = gtk_menu_item_new_with_label (_(part->title)); - g_object_set_data ((GObject *) item, "part", part); - g_signal_connect (item, "activate", G_CALLBACK (option_activate), data); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); - gtk_widget_show (item); + gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _(part->title)); + if (!strcmp (newpart->title, part->title)) current = index; index++; } - omenu = gtk_option_menu_new (); - gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu); - gtk_option_menu_set_history (GTK_OPTION_MENU (omenu), current); - gtk_widget_show (omenu); + gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), current); + g_signal_connect (combobox, "changed", G_CALLBACK (part_combobox_changed), data); + gtk_widget_show (combobox); - gtk_box_pack_start (GTK_BOX (hbox), omenu, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (hbox), combobox, FALSE, FALSE, 0); if (p) gtk_box_pack_start (GTK_BOX (hbox), p, TRUE, TRUE, 0); @@ -836,7 +838,7 @@ get_widget (FilterRule *fr, struct _RuleContext *f) { GtkWidget *hbox, *vbox, *parts, *inframe; GtkWidget *add, *label, *name, *w; - GtkWidget *omenu, *menu, *item; + GtkWidget *combobox; GtkWidget *scrolledwindow; GtkObject *hadj, *vadj; GList *l; @@ -920,48 +922,40 @@ get_widget (FilterRule *fr, struct _RuleContext *f) const char *thread_types[] = { N_("If all conditions are met"), N_("If any conditions are met") }; label = gtk_label_new_with_mnemonic (_("_Find items:")); - menu = gtk_menu_new (); + combobox = gtk_combo_box_new_text (); for (i=0;i<2;i++) { - item = gtk_menu_item_new_with_label(_(thread_types[i])); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - gtk_widget_show (item); + gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _(thread_types[i])); } - omenu = gtk_option_menu_new (); - gtk_label_set_mnemonic_widget ((GtkLabel *)label, omenu); - gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu); - gtk_option_menu_set_history (GTK_OPTION_MENU (omenu), fr->grouping); - gtk_widget_show (omenu); + gtk_label_set_mnemonic_widget ((GtkLabel *)label, combobox); + gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), fr->grouping); + gtk_widget_show (combobox); - gtk_box_pack_end (GTK_BOX (hbox), omenu, FALSE, FALSE, 0); + gtk_box_pack_end (GTK_BOX (hbox), combobox, FALSE, FALSE, 0); gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0); - g_signal_connect(omenu, "changed", G_CALLBACK(fr_grouping_changed), fr); + g_signal_connect (combobox, "changed", G_CALLBACK (fr_grouping_changed), fr); } if (f->flags & RULE_CONTEXT_THREADING) { const char *thread_types[] = { N_("None"), N_("All related"), N_("Replies"), N_("Replies and parents"), N_("No reply or parent") }; label = gtk_label_new_with_mnemonic (_("I_nclude threads")); - menu = gtk_menu_new (); + combobox = gtk_combo_box_new_text (); for (i=0;i<5;i++) { - item = gtk_menu_item_new_with_label(_(thread_types[i])); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - gtk_widget_show (item); + gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _(thread_types[i])); } - omenu = gtk_option_menu_new (); - gtk_label_set_mnemonic_widget ((GtkLabel *)label, omenu); - gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu); - gtk_option_menu_set_history (GTK_OPTION_MENU (omenu), fr->threading); - gtk_widget_show (omenu); + gtk_label_set_mnemonic_widget ((GtkLabel *)label, combobox); + gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), fr->threading); + gtk_widget_show (combobox); - gtk_box_pack_end (GTK_BOX (hbox), omenu, FALSE, FALSE, 0); + gtk_box_pack_end (GTK_BOX (hbox), combobox, FALSE, FALSE, 0); gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0); - g_signal_connect(omenu, "changed", G_CALLBACK(fr_threading_changed), fr); + g_signal_connect (combobox, "changed", G_CALLBACK (fr_threading_changed), fr); } gtk_box_pack_start (GTK_BOX (inframe), hbox, FALSE, FALSE, 3); diff --git a/filter/filter.glade b/filter/filter.glade index 3b43c26249..3773a234c1 100644 --- a/filter/filter.glade +++ b/filter/filter.glade @@ -6,7 +6,7 @@ <widget class="GtkWindow" id="rule-editor"> <property name="visible">True</property> - <property name="title" translatable="no">window1</property> + <property name="title">window1</property> <property name="type">GTK_WINDOW_TOPLEVEL</property> <property name="window_position">GTK_WIN_POS_NONE</property> <property name="modal">False</property> @@ -53,23 +53,11 @@ </child> <child> - <widget class="GtkOptionMenu" id="filter_source"> - <property name="can_focus">True</property> - <property name="history">0</property> - - <child internal-child="menu"> - <widget class="GtkMenu" id="convertwidget15"> - <property name="visible">True</property> - - <child> - <widget class="GtkMenuItem" id="convertwidget16"> - <property name="visible">True</property> - <property name="label" translatable="yes">Incoming</property> - <property name="use_underline">True</property> - </widget> - </child> - </widget> - </child> + <widget class="GtkComboBox" id="filter_source_combobox"> + <property name="visible">True</property> + <property name="items" translatable="yes">Incoming</property> + <property name="add_tearoffs">False</property> + <property name="focus_on_click">True</property> </widget> <packing> <property name="padding">0</property> @@ -298,7 +286,7 @@ <widget class="GtkWindow" id="filter_datespec_win"> <property name="border_width">6</property> <property name="visible">True</property> - <property name="title" translatable="no">window1</property> + <property name="title">window1</property> <property name="type">GTK_WINDOW_TOPLEVEL</property> <property name="window_position">GTK_WIN_POS_NONE</property> <property name="modal">False</property> @@ -351,40 +339,13 @@ </child> <child> - <widget class="GtkOptionMenu" id="option_type"> + <widget class="GtkComboBox" id="combobox_type"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="history">0</property> - - <child internal-child="menu"> - <widget class="GtkMenu" id="convertwidget19"> - <property name="visible">True</property> - - <child> - <widget class="GtkMenuItem" id="convertwidget20"> - <property name="visible">True</property> - <property name="label" translatable="yes">the current time</property> - <property name="use_underline">True</property> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id="convertwidget21"> - <property name="visible">True</property> - <property name="label" translatable="yes">the time you specify</property> - <property name="use_underline">True</property> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id="convertwidget22"> - <property name="visible">True</property> - <property name="label" translatable="yes">a time relative to the current time</property> - <property name="use_underline">True</property> - </widget> - </child> - </widget> - </child> + <property name="items" translatable="yes">the current time +the time you specify +a time relative to the current time</property> + <property name="add_tearoffs">False</property> + <property name="focus_on_click">True</property> </widget> <packing> <property name="padding">0</property> @@ -625,72 +586,17 @@ a time relative to when filtering occurs.</property> </child> <child> - <widget class="GtkOptionMenu" id="option_relative"> + <widget class="GtkComboBox" id="combobox_relative"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="history">0</property> - - <child internal-child="menu"> - <widget class="GtkMenu" id="convertwidget23"> - <property name="visible">True</property> - - <child> - <widget class="GtkMenuItem" id="convertwidget24"> - <property name="visible">True</property> - <property name="label" translatable="yes">seconds</property> - <property name="use_underline">True</property> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id="convertwidget25"> - <property name="visible">True</property> - <property name="label" translatable="yes">minutes</property> - <property name="use_underline">True</property> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id="convertwidget26"> - <property name="visible">True</property> - <property name="label" translatable="yes">hours</property> - <property name="use_underline">True</property> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id="convertwidget27"> - <property name="visible">True</property> - <property name="label" translatable="yes">days</property> - <property name="use_underline">True</property> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id="convertwidget28"> - <property name="visible">True</property> - <property name="label" translatable="yes">weeks</property> - <property name="use_underline">True</property> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id="convertwidget29"> - <property name="visible">True</property> - <property name="label" translatable="yes">months</property> - <property name="use_underline">True</property> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id="convertwidget30"> - <property name="visible">True</property> - <property name="label" translatable="yes">years</property> - <property name="use_underline">True</property> - </widget> - </child> - </widget> - </child> + <property name="items" translatable="yes">seconds +minutes +hours +days +weeks +months +years</property> + <property name="add_tearoffs">False</property> + <property name="focus_on_click">True</property> </widget> <packing> <property name="padding">0</property> @@ -700,33 +606,12 @@ a time relative to when filtering occurs.</property> </child> <child> - <widget class="GtkOptionMenu" id="option_past_future"> + <widget class="GtkComboBox" id="combobox_past_future"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="history">0</property> - - <child internal-child="menu"> - <widget class="GtkMenu" id="convertwidget31"> - <property name="visible">True</property> - - <child> - <widget class="GtkMenuItem" id="convertwidget32"> - <property name="visible">True</property> - <property name="label" translatable="yes">ago</property> - <property name="use_underline">True</property> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id="convertwidget33"> - <property name="visible">True</property> - <property name="label" translatable="yes">in the future</property> - <property name="use_underline">True</property> - </widget> - </child> - </widget> - </child> - + <property name="items" translatable="yes">ago +in the future</property> + <property name="add_tearoffs">False</property> + <property name="focus_on_click">True</property> </widget> <packing> <property name="padding">0</property> |