aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2002-04-05 04:03:02 +0800
committerDan Winship <danw@src.gnome.org>2002-04-05 04:03:02 +0800
commitf99f9d948846af22726a5d8d68617366ab267310 (patch)
treed48050a70ebd2180e4fa15ddd8e45d3f0ad9b75b
parentb064051f5ff3c148c54c9fc11efc6078fea8157c (diff)
downloadgsoc2013-evolution-f99f9d948846af22726a5d8d68617366ab267310.tar.gz
gsoc2013-evolution-f99f9d948846af22726a5d8d68617366ab267310.tar.zst
gsoc2013-evolution-f99f9d948846af22726a5d8d68617366ab267310.zip
Remove the #ifndef SHELL part. Use an EvolutionFolderSelectorButton.
* filter-folder.c: Remove the #ifndef SHELL part. Use an EvolutionFolderSelectorButton. Remove FilterFolder->name since it's no longer needed. * filter-context.c (filter_rename_uri): Update for removal of FilterFolder->name. * filter-element.c (filter_element_copy_value): Likewise. * vfolder-rule.c (source_add): Update for evolution_shell_client_user_select_folder API change. svn path=/trunk/; revision=16354
-rw-r--r--filter/ChangeLog14
-rw-r--r--filter/filter-context.c9
-rw-r--r--filter/filter-element.c2
-rw-r--r--filter/filter-folder.c124
-rw-r--r--filter/filter-folder.h3
-rw-r--r--filter/vfolder-rule.c14
6 files changed, 40 insertions, 126 deletions
diff --git a/filter/ChangeLog b/filter/ChangeLog
index 28d0cd862f..b09f0b955b 100644
--- a/filter/ChangeLog
+++ b/filter/ChangeLog
@@ -1,3 +1,17 @@
+2002-04-04 Dan Winship <danw@ximian.com>
+
+ * filter-folder.c: Remove the #ifndef SHELL part. Use an
+ EvolutionFolderSelectorButton. Remove FilterFolder->name since
+ it's no longer needed.
+
+ * filter-context.c (filter_rename_uri): Update for removal of
+ FilterFolder->name.
+
+ * filter-element.c (filter_element_copy_value): Likewise.
+
+ * vfolder-rule.c (source_add): Update for
+ evolution_shell_client_user_select_folder API change.
+
2002-04-01 Jeffrey Stedfast <fejj@ximian.com>
* rule-editor.c (rule_edit): Set 're' as the parent window rather
diff --git a/filter/filter-context.c b/filter/filter-context.c
index aa3b36a5ee..2f77fbe2f5 100644
--- a/filter/filter-context.c
+++ b/filter/filter-context.c
@@ -171,15 +171,8 @@ static int filter_rename_uri(RuleContext *f, const char *olduri, const char *new
GList *l, *el;
FilterPart *action;
FilterElement *element;
- const char *name;
int count = 0;
- name = strrchr(newuri, '/');
- if (name)
- name++;
- else
- name = newuri;
-
d(printf("uri '%s' renamed to '%s'\n", olduri, newuri));
/* For all rules, for all actions, for all elements, rename any folder elements */
@@ -207,7 +200,7 @@ static int filter_rename_uri(RuleContext *f, const char *olduri, const char *new
if (IS_FILTER_FOLDER(element)
&& cmp(((FilterFolder *)element)->uri, olduri)) {
d(printf(" Changed!\n"));
- filter_folder_set_value((FilterFolder *)element, newuri, name);
+ filter_folder_set_value((FilterFolder *)element, newuri);
rulecount++;
}
el = el->next;
diff --git a/filter/filter-element.c b/filter/filter-element.c
index 3ff4bee533..fcb814e538 100644
--- a/filter/filter-element.c
+++ b/filter/filter-element.c
@@ -327,7 +327,7 @@ filter_element_copy_value(FilterElement *de, FilterElement *se)
}
} else if (IS_FILTER_FOLDER(se)) {
if (IS_FILTER_FOLDER(de)) {
- filter_folder_set_value((FilterFolder *)de, ((FilterFolder *)se)->uri, ((FilterFolder *)se)->name);
+ filter_folder_set_value((FilterFolder *)de, ((FilterFolder *)se)->uri);
}
} else if (IS_FILTER_COLOUR(se)) {
if (IS_FILTER_COLOUR(de)) {
diff --git a/filter/filter-folder.c b/filter/filter-folder.c
index 5b862a986a..100b4fe253 100644
--- a/filter/filter-folder.c
+++ b/filter/filter-folder.c
@@ -20,8 +20,6 @@
#include <config.h>
-#define SHELL
-
#include <glib.h>
#include <libgnome/gnome-defs.h>
#include <libgnome/gnome-i18n.h>
@@ -30,9 +28,7 @@
#include <gal/widgets/e-unicode.h>
#include "filter-folder.h"
-#ifdef SHELL
-#include "shell/evolution-shell-client.h"
-#endif
+#include "shell/evolution-folder-selector-button.h"
#include "e-util/e-sexp.h"
#define d(x)
@@ -45,9 +41,7 @@ static GtkWidget *get_widget(FilterElement *fe);
static void build_code(FilterElement *fe, GString *out, struct _FilterPart *ff);
static void format_sexp(FilterElement *, GString *);
-#ifdef SHELL
extern EvolutionShellClient *global_shell_client;
-#endif
static void filter_folder_class_init (FilterFolderClass *class);
static void filter_folder_init (FilterFolder *gspaper);
@@ -115,7 +109,6 @@ filter_folder_finalise (GtkObject *obj)
FilterFolder *o = (FilterFolder *)obj;
g_free (o->uri);
- g_free (o->name);
((GtkObjectClass *)(parent_class))->finalize(obj);
}
@@ -135,12 +128,10 @@ filter_folder_new (void)
}
void
-filter_folder_set_value(FilterFolder *ff, const char *uri, const char *name)
+filter_folder_set_value(FilterFolder *ff, const char *uri)
{
g_free(ff->uri);
ff->uri = g_strdup(uri);
- g_free(ff->name);
- ff->name = g_strdup(name);
}
static gboolean
@@ -182,7 +173,6 @@ xml_encode (FilterElement *fe)
xmlSetProp (value, "type", "folder");
work = xmlNewChild (value, NULL, "folder", NULL);
- xmlSetProp (work, "name", ff->name);
xmlSetProp (work, "uri", ff->uri);
return value;
@@ -202,12 +192,7 @@ xml_decode (FilterElement *fe, xmlNodePtr node)
n = node->childs;
while (n) {
if (!strcmp (n->name, "folder")) {
- char *uri, *name;
-
- name = xmlGetProp (n, "name");
- g_free (ff->name);
- ff->name = g_strdup (name);
- xmlFree (name);
+ char *uri;
uri = xmlGetProp (n, "uri");
g_free (ff->uri);
@@ -222,88 +207,12 @@ xml_decode (FilterElement *fe, xmlNodePtr node)
}
static void
-button_clicked (GtkButton *button, FilterFolder *ff)
+folder_selected (EvolutionFolderSelectorButton *button,
+ GNOME_Evolution_Folder *folder,
+ FilterFolder *ff)
{
-#ifdef SHELL
- const char *allowed_types[] = { "mail", NULL };
- char *def, *physical_uri, *evolution_uri;
- gchar *s;
-
- def = ff->uri ? ff->uri : "";
-
- gtk_widget_set_sensitive((GtkWidget *)button, FALSE);
- gtk_object_ref((GtkObject *)ff);
-
- evolution_shell_client_user_select_folder (global_shell_client,
- GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (button))),
- _("Select Folder"),
- def, allowed_types,
- &evolution_uri,
- &physical_uri);
-
- if (GTK_OBJECT_DESTROYED(button)) {
- g_free(physical_uri);
- g_free(evolution_uri);
- gtk_object_unref((GtkObject *)ff);
- return;
- }
-
- gtk_widget_set_sensitive((GtkWidget *)button, TRUE);
-
- if (physical_uri != NULL && physical_uri[0] != '\0') {
- g_free (ff->uri);
- ff->uri = physical_uri;
-
- g_free (ff->name);
- ff->name = g_strdup (g_basename (evolution_uri));
- s = e_utf8_to_gtk_string (GTK_WIDGET (button), ff->name);
- gtk_label_set_text (GTK_LABEL (GTK_BIN (button)->child), s);
- g_free (s);
- } else {
- g_free (physical_uri);
- }
- g_free (evolution_uri);
-
- gtk_object_unref((GtkObject *)ff);
-
-#else
- GnomeDialog *gd;
- GtkEntry *entry;
- char *uri, *str;
-
- gd = (GnomeDialog *)gnome_dialog_new(_("Enter folder URI"),
- GNOME_STOCK_BUTTON_OK, GNOME_STOCK_BUTTON_CANCEL,
- NULL);
- gtk_window_set_policy(GTK_WINDOW(gd), FALSE, TRUE, FALSE);
- entry = (GtkEntry *)gtk_entry_new();
- if (ff->uri) {
- e_utf8_gtk_entry_set_text(entry, ff->uri);
- }
- gtk_box_pack_start((GtkBox *)gd->vbox, (GtkWidget *)entry, TRUE, TRUE, 3);
- gtk_widget_show((GtkWidget *)entry);
- switch (gnome_dialog_run(gd)) {
- case 0:
- g_free(ff->uri);
- g_free(ff->name);
- uri = e_utf8_gtk_entry_get_text(entry);
- ff->uri = uri;
- str = strstr(uri, "//");
- if (str)
- str = strchr(str+2, '/');
- if (str)
- str++;
- else
- str = uri;
- ff->name = g_strdup(str);
- s = e_utf8_to_gtk_string ((GtkWidget *) button, ff->name);
- gtk_label_set_text((GtkLabel *)GTK_BIN(button)->child, s);
- g_free (s);
- case 1:
- gnome_dialog_close(gd);
- case -1:
- /* nothing */
- }
-#endif
+ g_free (ff->uri);
+ ff->uri = g_strdup (folder->physicalUri);
gdk_window_raise (GTK_WIDGET (gtk_widget_get_ancestor (GTK_WIDGET (button), GTK_TYPE_WINDOW))->window);
}
@@ -311,20 +220,17 @@ button_clicked (GtkButton *button, FilterFolder *ff)
static GtkWidget *
get_widget (FilterElement *fe)
{
+ static const char *allowed_types[] = { "mail", NULL };
FilterFolder *ff = (FilterFolder *)fe;
GtkWidget *button;
- GtkWidget *label;
- if (ff->name && ff->name[0])
- label = gtk_label_new (g_basename (ff->name));
- else
- label = gtk_label_new (_("<click here to select a folder>"));
-
- button = gtk_button_new ();
- gtk_container_add (GTK_CONTAINER (button), label);
+ button = evolution_folder_selector_button_new (global_shell_client,
+ _("Select Folder"),
+ ff->uri,
+ allowed_types);
+
gtk_widget_show (button);
- gtk_widget_show (label);
- gtk_signal_connect (GTK_OBJECT (button), "clicked", button_clicked, ff);
+ gtk_signal_connect (GTK_OBJECT (button), "selected", folder_selected, ff);
return button;
}
diff --git a/filter/filter-folder.h b/filter/filter-folder.h
index e58444fb14..d69a5e5352 100644
--- a/filter/filter-folder.h
+++ b/filter/filter-folder.h
@@ -35,7 +35,6 @@ struct _FilterFolder {
struct _FilterFolderPrivate *priv;
char *uri;
- char *name; /* name of folder for display? */
};
struct _FilterFolderClass {
@@ -50,7 +49,7 @@ guint filter_folder_get_type (void);
FilterFolder *filter_folder_new (void);
/* methods */
-void filter_folder_set_value(FilterFolder *ff, const char *uri, const char *name);
+void filter_folder_set_value(FilterFolder *ff, const char *uri);
#endif /* ! _FILTER_FOLDER_H */
diff --git a/filter/vfolder-rule.c b/filter/vfolder-rule.c
index 818b303366..36b381eb06 100644
--- a/filter/vfolder-rule.c
+++ b/filter/vfolder-rule.c
@@ -352,7 +352,8 @@ select_source_with(GtkWidget *w, struct _source_data *data)
static void
source_add(GtkWidget *widget, struct _source_data *data)
{
- const char *allowed_types[] = { "mail", NULL };
+ static const char *allowed_types[] = { "mail", NULL };
+ GNOME_Evolution_Folder *folder;
char *def, *uri;
GtkListItem *item;
GList *l;
@@ -363,16 +364,18 @@ source_add(GtkWidget *widget, struct _source_data *data)
evolution_shell_client_user_select_folder (global_shell_client,
GTK_WINDOW (gtk_widget_get_toplevel (widget)),
_("Select Folder"),
- def, allowed_types, NULL, &uri);
+ def, allowed_types, &folder);
if (GTK_OBJECT_DESTROYED(widget)) {
- g_free(uri);
+ if (folder)
+ CORBA_free (folder);
return;
}
gtk_widget_set_sensitive(widget, TRUE);
- if (uri != NULL && uri[0] != '\0') {
+ if (folder) {
+ uri = g_strdup (folder->physicalUri);
data->vr->sources = g_list_append(data->vr->sources, uri);
l = NULL;
@@ -385,9 +388,8 @@ source_add(GtkWidget *widget, struct _source_data *data)
gtk_list_append_items(data->list, l);
gtk_list_select_child(data->list, (GtkWidget *)item);
data->current = uri;
- } else {
- g_free(uri);
}
+ CORBA_free (folder);
set_sensitive(data);
}