aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2002-12-13 08:32:28 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2002-12-13 08:32:28 +0800
commitdc41429125ddb873fda8a5eeb1691f104d5d88fd (patch)
treeed0b48d5e6a2d0f21e7e64df62879bc220eb9389
parent1229557d373b7bc0d14fb7d8d3a9aacafb2d567b (diff)
downloadgsoc2013-evolution-dc41429125ddb873fda8a5eeb1691f104d5d88fd.tar
gsoc2013-evolution-dc41429125ddb873fda8a5eeb1691f104d5d88fd.tar.gz
gsoc2013-evolution-dc41429125ddb873fda8a5eeb1691f104d5d88fd.tar.bz2
gsoc2013-evolution-dc41429125ddb873fda8a5eeb1691f104d5d88fd.tar.lz
gsoc2013-evolution-dc41429125ddb873fda8a5eeb1691f104d5d88fd.tar.xz
gsoc2013-evolution-dc41429125ddb873fda8a5eeb1691f104d5d88fd.tar.zst
gsoc2013-evolution-dc41429125ddb873fda8a5eeb1691f104d5d88fd.zip
New custom function for creating the source_list widget. (get_widget):
2002-12-12 Jeffrey Stedfast <fejj@ximian.com> * vfolder-rule.c (vfolder_editor_sourcelist_new): New custom function for creating the source_list widget. (get_widget): Removed the source_list creation code. * rule-editor.c (rule_editor_construct): Listen to row-activated for double-click events. Also, removed the model creation code out of here. (rule_editor_treeview_new): Moved the treeview and model creation code into here instead, and made the glade widgets into custom widgets. svn path=/trunk/; revision=19106
-rw-r--r--filter/ChangeLog13
-rw-r--r--filter/filter.glade48
-rw-r--r--filter/rule-editor.c107
-rw-r--r--filter/vfolder-rule.c52
4 files changed, 150 insertions, 70 deletions
diff --git a/filter/ChangeLog b/filter/ChangeLog
index 1f26d43331..0b3d43930e 100644
--- a/filter/ChangeLog
+++ b/filter/ChangeLog
@@ -1,3 +1,16 @@
+2002-12-12 Jeffrey Stedfast <fejj@ximian.com>
+
+ * vfolder-rule.c (vfolder_editor_sourcelist_new): New custom
+ function for creating the source_list widget.
+ (get_widget): Removed the source_list creation code.
+
+ * rule-editor.c (rule_editor_construct): Listen to row-activated
+ for double-click events. Also, removed the model creation code out
+ of here.
+ (rule_editor_treeview_new): Moved the treeview and model creation
+ code into here instead, and made the glade widgets into custom
+ widgets.
+
2002-11-26 Not Zed <NotZed@Ximian.com>
* vfolder-rule.c (get_widget): Add a textcellrenderer to display
diff --git a/filter/filter.glade b/filter/filter.glade
index 9bd4eaa72d..ff1927a7b7 100644
--- a/filter/filter.glade
+++ b/filter/filter.glade
@@ -113,17 +113,17 @@
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
- <widget class="GtkViewport" id="viewport1">
+ <widget class="GtkViewport" id="viewport5">
<property name="visible">True</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<child>
- <widget class="GtkTreeView" id="rule_list">
+ <widget class="Custom" id="rule_list">
<property name="visible">True</property>
- <property name="headers_visible">False</property>
- <property name="rules_hint">False</property>
- <property name="reorderable">True</property>
- <property name="enable_search">True</property>
+ <property name="creation_function">rule_editor_treeview_new</property>
+ <property name="int1">0</property>
+ <property name="int2">0</property>
+ <property name="last_modification_time">Thu, 12 Dec 2002 23:41:46 GMT</property>
</widget>
</child>
</widget>
@@ -323,17 +323,17 @@
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
- <widget class="GtkViewport" id="viewport2">
+ <widget class="GtkViewport" id="viewport7">
<property name="visible">True</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<child>
- <widget class="GtkTreeView" id="rule_list">
+ <widget class="Custom" id="rule_list">
<property name="visible">True</property>
- <property name="headers_visible">False</property>
- <property name="rules_hint">False</property>
- <property name="reorderable">True</property>
- <property name="enable_search">True</property>
+ <property name="creation_function">rule_editor_treeview_new</property>
+ <property name="int1">0</property>
+ <property name="int2">0</property>
+ <property name="last_modification_time">Fri, 13 Dec 2002 00:15:04 GMT</property>
</widget>
</child>
</widget>
@@ -602,17 +602,17 @@
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
- <widget class="GtkViewport" id="viewport3">
+ <widget class="GtkViewport" id="viewport8">
<property name="visible">True</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<child>
- <widget class="GtkTreeView" id="source_list">
+ <widget class="Custom" id="source_list">
<property name="visible">True</property>
- <property name="headers_visible">True</property>
- <property name="rules_hint">False</property>
- <property name="reorderable">False</property>
- <property name="enable_search">True</property>
+ <property name="creation_function">vfolder_editor_sourcelist_new</property>
+ <property name="int1">0</property>
+ <property name="int2">0</property>
+ <property name="last_modification_time">Fri, 13 Dec 2002 00:22:39 GMT</property>
</widget>
</child>
</widget>
@@ -774,17 +774,17 @@
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
- <widget class="GtkViewport" id="viewport4">
+ <widget class="GtkViewport" id="viewport6">
<property name="visible">True</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<child>
- <widget class="GtkTreeView" id="rule_list">
+ <widget class="Custom" id="rule_list">
<property name="visible">True</property>
- <property name="headers_visible">False</property>
- <property name="rules_hint">False</property>
- <property name="reorderable">True</property>
- <property name="enable_search">True</property>
+ <property name="creation_function">rule_editor_treeview_new</property>
+ <property name="int1">0</property>
+ <property name="int2">0</property>
+ <property name="last_modification_time">Thu, 12 Dec 2002 23:50:05 GMT</property>
</widget>
</child>
</widget>
diff --git a/filter/rule-editor.c b/filter/rule-editor.c
index f86c8718bc..3ea15d9d8b 100644
--- a/filter/rule-editor.c
+++ b/filter/rule-editor.c
@@ -311,7 +311,8 @@ edit_editor_response (GtkWidget *dialog, int button, RuleEditor *re)
rule = rule_context_find_rule (re->context, re->edit->name, re->edit->source);
if (rule != NULL && rule != re->current) {
- dialog = gtk_message_dialog_new ((GtkWindow *) dialog, GTK_DIALOG_DESTROY_WITH_PARENT,
+ dialog = gtk_message_dialog_new ((GtkWindow *) dialog,
+ GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
_("Rule name '%s' is not unique, choose another."),
re->edit->name);
@@ -331,7 +332,8 @@ edit_editor_response (GtkWidget *dialog, int button, RuleEditor *re)
gtk_list_store_set (re->model, &iter, 0, re->edit->name, -1);
- rule_editor_add_undo (re, RULE_EDITOR_LOG_EDIT, filter_rule_clone (re->current), pos, 0);
+ rule_editor_add_undo (re, RULE_EDITOR_LOG_EDIT, filter_rule_clone (re->current),
+ pos, 0);
/* replace the old rule with the new rule */
filter_rule_copy (re->current, re->edit);
@@ -502,7 +504,7 @@ set_sensitive (RuleEditor *re)
static void
-cursor_changed (GtkWidget *list, RuleEditor *re)
+cursor_changed (GtkTreeView *treeview, RuleEditor *re)
{
GtkTreeViewColumn *column;
GtkTreePath *path;
@@ -519,13 +521,11 @@ cursor_changed (GtkWidget *list, RuleEditor *re)
rule_editor_set_sensitive (re);
}
-static gboolean
-double_click (GtkWidget *widget, GdkEventButton *event, RuleEditor *re)
+static void
+double_click (GtkTreeView *treeview, GtkTreePath *path, GtkTreeViewColumn *column, RuleEditor *re)
{
- if (re->current && event->type == GDK_2BUTTON_PRESS)
- rule_edit (widget, re);
-
- return TRUE;
+ if (re->current)
+ rule_edit ((GtkWidget *) treeview, re);
}
static void
@@ -536,7 +536,7 @@ set_source (RuleEditor *re, const char *source)
gtk_list_store_clear (re->model);
- d(printf("Checking for rules that are of type %s\n", source?source:"<nil>"));
+ d(printf("Checking for rules that are of type %s\n", source ? source : "<nil>"));
while ((rule = rule_context_next_rule (re->context, rule, source)) != NULL) {
d(printf("Adding row '%s'\n", rule->name));
gtk_list_store_append (re->model, &iter);
@@ -581,36 +581,37 @@ rule_editor_play_undo (RuleEditor *re)
next = undo->next;
switch (undo->type) {
case RULE_EDITOR_LOG_EDIT:
- printf("Undoing edit on rule '%s'\n", undo->rule->name);
- rule = rule_context_find_rank_rule(re->context, undo->rank, undo->rule->source);
+ d(printf ("Undoing edit on rule '%s'\n", undo->rule->name));
+ rule = rule_context_find_rank_rule (re->context, undo->rank, undo->rule->source);
if (rule) {
- printf(" name was '%s'\n", rule->name);
- filter_rule_copy(rule, undo->rule);
- printf(" name is '%s'\n", rule->name);
+ d(printf (" name was '%s'\n", rule->name));
+ filter_rule_copy (rule, undo->rule);
+ d(printf (" name is '%s'\n", rule->name));
} else {
- g_warning("Could not find the right rule to undo against?\n");
+ g_warning ("Could not find the right rule to undo against?");
}
break;
case RULE_EDITOR_LOG_ADD:
- printf("Undoing add on rule '%s'\n", undo->rule->name);
- rule = rule_context_find_rank_rule(re->context, undo->rank, undo->rule->source);
+ d(printf ("Undoing add on rule '%s'\n", undo->rule->name));
+ rule = rule_context_find_rank_rule (re->context, undo->rank, undo->rule->source);
if (rule)
- rule_context_remove_rule(re->context, rule);
+ rule_context_remove_rule (re->context, rule);
break;
case RULE_EDITOR_LOG_REMOVE:
- printf("Undoing remove on rule '%s'\n", undo->rule->name);
+ d(printf ("Undoing remove on rule '%s'\n", undo->rule->name));
g_object_ref (undo->rule);
- rule_context_add_rule(re->context, undo->rule);
- rule_context_rank_rule(re->context, undo->rule, undo->rank);
+ rule_context_add_rule (re->context, undo->rule);
+ rule_context_rank_rule (re->context, undo->rule, undo->rank);
break;
case RULE_EDITOR_LOG_RANK:
- rule = rule_context_find_rank_rule(re->context, undo->newrank, undo->rule->source);
+ rule = rule_context_find_rank_rule (re->context, undo->newrank, undo->rule->source);
if (rule)
- rule_context_rank_rule(re->context, rule, undo->rank);
+ rule_context_rank_rule (re->context, rule, undo->rank);
break;
}
+
g_object_unref (undo->rule);
- g_free(undo);
+ g_free (undo);
undo = next;
}
re->undo_active = FALSE;
@@ -637,6 +638,44 @@ editor_response (GtkWidget *dialog, int button, RuleEditor *re)
}
}
+GtkWidget *rule_editor_treeview_new (char *widget_name, char *string1, char *string2,
+ int int1, int int2);
+
+GtkWidget *
+rule_editor_treeview_new (char *widget_name, char *string1, char *string2, int int1, int int2)
+{
+ GtkWidget *table, *scrolled;
+ GtkTreeSelection *selection;
+ GtkCellRenderer *renderer;
+ GtkListStore *model;
+
+ scrolled = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+
+ model = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER);
+ table = gtk_tree_view_new_with_model ((GtkTreeModel *) model);
+ gtk_tree_view_set_headers_visible ((GtkTreeView *) table, FALSE);
+
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_tree_view_insert_column_with_attributes ((GtkTreeView *) table, -1,
+ _("Rule name"), renderer,
+ "text", 0, NULL);
+
+ selection = gtk_tree_view_get_selection ((GtkTreeView *) table);
+ gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
+
+ gtk_container_add (GTK_CONTAINER (scrolled), table);
+
+ g_object_set_data ((GObject *) scrolled, "table", table);
+ g_object_set_data ((GObject *) scrolled, "model", model);
+
+ gtk_widget_show (scrolled);
+ gtk_widget_show (table);
+
+ return scrolled;
+}
+
void
rule_editor_construct (RuleEditor *re, RuleContext *context, GladeXML *gui, const char *source)
{
@@ -647,7 +686,7 @@ rule_editor_construct (RuleEditor *re, RuleContext *context, GladeXML *gui, cons
re->context = context;
g_object_ref (context);
- gtk_window_set_policy (GTK_WINDOW (re), FALSE, TRUE, FALSE);
+ gtk_window_set_policy ((GtkWindow *) re, FALSE, TRUE, FALSE);
w = glade_xml_get_widget (gui, "rule_editor");
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (re)->vbox), w, TRUE, TRUE, 0);
@@ -657,20 +696,14 @@ rule_editor_construct (RuleEditor *re, RuleContext *context, GladeXML *gui, cons
g_signal_connect (w, "clicked", edit_buttons[i].func, re);
}
- re->model = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER);
- re->list = (GtkTreeView *) glade_xml_get_widget (gui, "rule_list");
- gtk_tree_view_set_model (re->list, (GtkTreeModel *) re->model);
- gtk_tree_view_insert_column_with_attributes(re->list, -1, _("Rule(s)"),
- gtk_cell_renderer_text_new(),
- "text", 0,
- NULL);
- selection = gtk_tree_view_get_selection (re->list);
- gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
+ w = glade_xml_get_widget (gui, "rule_list");
+ re->list = (GtkTreeView *) g_object_get_data ((GObject *) w, "table");
+ re->model = (GtkListStore *) g_object_get_data ((GObject *) w, "model");
g_signal_connect (re->list, "cursor-changed", G_CALLBACK (cursor_changed), re);
- g_signal_connect (re->list, "button_press_event", G_CALLBACK (double_click), re);
+ g_signal_connect (re->list, "row-activated", G_CALLBACK (double_click), re);
- g_signal_connect (re, "response", G_CALLBACK(editor_response), re);
+ g_signal_connect (re, "response", G_CALLBACK (editor_response), re);
rule_editor_set_source (re, source);
if (enable_undo) {
diff --git a/filter/vfolder-rule.c b/filter/vfolder-rule.c
index 393bfc8650..616349d324 100644
--- a/filter/vfolder-rule.c
+++ b/filter/vfolder-rule.c
@@ -474,6 +474,46 @@ source_remove (GtkWidget *widget, struct _source_data *data)
set_sensitive (data);
}
+
+GtkWidget *vfolder_editor_sourcelist_new (char *widget_name, char *string1, char *string2,
+ int int1, int int2);
+
+GtkWidget *
+vfolder_editor_sourcelist_new (char *widget_name, char *string1, char *string2, int int1, int int2)
+{
+ GtkWidget *table, *scrolled;
+ GtkTreeSelection *selection;
+ GtkCellRenderer *renderer;
+ GtkListStore *model;
+
+ scrolled = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+
+ model = gtk_list_store_new (1, G_TYPE_STRING);
+ table = gtk_tree_view_new_with_model ((GtkTreeModel *) model);
+ gtk_tree_view_set_headers_visible ((GtkTreeView *) table, FALSE);
+
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_tree_view_insert_column_with_attributes ((GtkTreeView *) table, -1,
+ _("VFolder source"), renderer,
+ "text", 0, NULL);
+
+ selection = gtk_tree_view_get_selection ((GtkTreeView *) table);
+ gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
+
+ gtk_container_add (GTK_CONTAINER (scrolled), table);
+
+ g_object_set_data ((GObject *) scrolled, "table", table);
+ g_object_set_data ((GObject *) scrolled, "model", model);
+
+ gtk_widget_show (scrolled);
+ gtk_widget_show (table);
+
+ return scrolled;
+}
+
+
/* DO NOT internationalise these strings */
const char *source_names[] = {
"specific",
@@ -512,15 +552,9 @@ get_widget (FilterRule *fr, RuleContext *rc)
g_signal_connect (data->buttons[i], "clicked", edit_buttons[i].func, data);
}
- data->model = gtk_list_store_new (1, G_TYPE_STRING);
- data->list = (GtkTreeView *) glade_xml_get_widget (gui, "source_list");
- gtk_tree_view_set_model (data->list, (GtkTreeModel *) data->model);
- selection = gtk_tree_view_get_selection (data->list);
- gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
- gtk_tree_view_insert_column_with_attributes(data->list, -1, _("Folder(s)"),
- gtk_cell_renderer_text_new(),
- "text", 0,
- NULL);
+ widget = glade_xml_get_widget (gui, "source_list");
+ data->list = (GtkTreeView *) g_object_get_data ((GObject *) widget, "table");
+ data->model = (GtkListStore *) g_object_get_data ((GObject *) widget, "model");
source = NULL;
while ((source = vfolder_rule_next_source (vr, source))) {