aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2002-11-12 02:34:26 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2002-11-12 02:34:26 +0800
commiteefc354fcccec3e13cf966ec1732da50732efe3b (patch)
treec63e37d740dbf2a925654c08c97a02687a31b50a
parentc552a5ba4f958d2bd23317e8c68f0606f1b1c4c8 (diff)
downloadgsoc2013-evolution-eefc354fcccec3e13cf966ec1732da50732efe3b.tar.gz
gsoc2013-evolution-eefc354fcccec3e13cf966ec1732da50732efe3b.tar.zst
gsoc2013-evolution-eefc354fcccec3e13cf966ec1732da50732efe3b.zip
Ported.
2002-11-11 Jeffrey Stedfast <fejj@ximian.com> * folder-browser-ui.c: Ported. * folder-browser-factory.c: Ported. * folder-browser.c: Ported. svn path=/trunk/; revision=18699
-rw-r--r--mail/ChangeLog4
-rw-r--r--mail/folder-browser-factory.c66
-rw-r--r--mail/folder-browser-ui.c79
-rw-r--r--mail/folder-browser.c13
4 files changed, 89 insertions, 73 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 8786c608be..5fa615e530 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,5 +1,9 @@
2002-11-11 Jeffrey Stedfast <fejj@ximian.com>
+ * folder-browser-ui.c: Ported.
+
+ * folder-browser-factory.c: Ported.
+
* folder-browser.c: Ported.
* e-searching-tokenizer.c: Roughly ported.
diff --git a/mail/folder-browser-factory.c b/mail/folder-browser-factory.c
index e1057cd7e7..763605bf9d 100644
--- a/mail/folder-browser-factory.c
+++ b/mail/folder-browser-factory.c
@@ -153,31 +153,32 @@ control_activate_cb (BonoboControl *control,
}
static void
-control_destroy_cb (BonoboControl *control,
- GtkObject *folder_browser)
+control_destroy_cb (GtkObject *fb, GObject *deadbeef)
{
gtk_object_destroy (folder_browser);
}
static void
-browser_destroy_cb (FolderBrowser *fb,
- BonoboControl *control)
+browser_destroy_cb (BonoboControl *control, GObject *deadbeef)
{
EIterator *it;
-
+
/* We do this from browser_destroy_cb rather than
* control_destroy_cb because currently, the controls
* don't seem to all get destroyed properly at quit
* time (but the widgets get destroyed by X). FIXME.
*/
-
- for (it = e_list_get_iterator (control_list); e_iterator_is_valid (it); e_iterator_next (it)) {
+
+ it = e_list_get_iterator (control_list);
+ while (e_iterator_is_valid (it)) {
if (e_iterator_get (it) == control) {
e_iterator_delete (it);
break;
}
+ e_iterator_next (it);
}
- gtk_object_unref (GTK_OBJECT (it));
+
+ g_object_unref (it);
}
BonoboControl *
@@ -185,36 +186,32 @@ folder_browser_factory_new_control (const char *uri,
const GNOME_Evolution_Shell shell)
{
BonoboControl *control;
- GtkWidget *folder_browser;
-
- folder_browser = folder_browser_new (shell, uri);
- if (folder_browser == NULL)
+ GtkWidget *fb;
+
+ if (!(fb = folder_browser_new (shell, uri)))
return NULL;
-
+
FOLDER_BROWSER (folder_browser)->pref_master = TRUE; /* save UI settings changed in this FB */
-
+
gtk_widget_show (folder_browser);
control = bonobo_control_new (folder_browser);
if (control == NULL) {
- gtk_object_unref (GTK_OBJECT (folder_browser));
+ g_object_unref (fb);
return NULL;
}
- gtk_signal_connect (GTK_OBJECT (control), "activate",
- control_activate_cb, folder_browser);
-
- gtk_signal_connect (GTK_OBJECT (control), "destroy",
- control_destroy_cb, folder_browser);
- gtk_signal_connect (GTK_OBJECT (folder_browser), "destroy",
- browser_destroy_cb, control);
-
+ g_signal_connect (control, "activate", GTK_SIGNAL_FUNC (control_activate_cb), fb);
+
+ g_object_weak_ref (control, (GWeakNotify) control_destroy_cb, fb);
+ g_object_weak_ref (fb, (GWeakNotify) browser_destroy_cb, control);
+
if (!control_list)
control_list = e_list_new (NULL, NULL, NULL);
-
+
e_list_append (control_list, control);
-
+
return control;
}
@@ -233,21 +230,24 @@ folder_browser_factory_get_browser(const char *uri)
EIterator *it;
BonoboControl *control;
FolderBrowser *fb = NULL;
-
+
if (control_list == NULL)
return NULL;
controls = folder_browser_factory_get_control_list ();
- for (it = e_list_get_iterator (controls); e_iterator_is_valid (it); e_iterator_next (it)) {
+
+ it = e_list_get_iterator (controls);
+ while (e_iterator_is_valid (it)) {
control = BONOBO_CONTROL (e_iterator_get (it));
- fb = FOLDER_BROWSER(bonobo_control_get_widget(control));
- if (fb->uri && strcmp(fb->uri, uri) == 0)
+ fb = FOLDER_BROWSER (bonobo_control_get_widget (control));
+ if (fb->uri && strcmp (fb->uri, uri) == 0)
break;
fb = NULL;
+
+ e_iterator_next (it);
}
- gtk_object_unref (GTK_OBJECT(it));
-
+
+ g_object_unref (it);
+
return fb;
}
-
-
diff --git a/mail/folder-browser-ui.c b/mail/folder-browser-ui.c
index a5a6db41cc..a4736baedf 100644
--- a/mail/folder-browser-ui.c
+++ b/mail/folder-browser-ui.c
@@ -26,7 +26,6 @@
#include <config.h>
#endif
-#include <libgnome/gnome-defs.h>
#include <libgnome/gnome-util.h> /* gnome_util_prepend_user_home */
#include <bonobo/bonobo-exception.h>
@@ -348,7 +347,7 @@ folder_browser_ui_setup_view_menus (FolderBrowser *fb)
char *local_dir;
GalViewFactory *factory;
- collection = gal_view_collection_new();
+ collection = gal_view_collection_new ();
gal_view_collection_set_title (collection, _("Mail"));
@@ -359,15 +358,15 @@ folder_browser_ui_setup_view_menus (FolderBrowser *fb)
local_dir);
g_free (local_dir);
- spec = e_table_specification_new();
- e_table_specification_load_from_file(spec, EVOLUTION_ETSPECDIR "/message-list.etspec");
+ spec = e_table_specification_new ();
+ e_table_specification_load_from_file (spec, EVOLUTION_ETSPECDIR "/message-list.etspec");
factory = gal_view_factory_etable_new (spec);
- gtk_object_unref (GTK_OBJECT (spec));
+ g_object_unref (spec);
gal_view_collection_add_factory (collection, factory);
- gtk_object_unref (GTK_OBJECT (factory));
+ g_object_unref (factory);
- gal_view_collection_load(collection);
+ gal_view_collection_load (collection);
}
id = mail_config_folder_to_safe_url(fb->folder);
@@ -390,17 +389,17 @@ folder_browser_ui_setup_view_menus (FolderBrowser *fb)
GalView *view;
spec = e_table_specification_new();
- e_table_specification_load_from_file(spec, EVOLUTION_ETSPECDIR "/message-list.etspec");
- view = gal_view_etable_new(spec, "");
- gtk_object_unref (GTK_OBJECT (spec));
+ e_table_specification_load_from_file (spec, EVOLUTION_ETSPECDIR "/message-list.etspec");
+ view = gal_view_etable_new (spec, "");
+ g_object_unref (spec);
state = e_table_state_new ();
e_table_state_load_from_file (state, path);
gal_view_etable_set_state (GAL_VIEW_ETABLE (view), state);
- gtk_object_unref (GTK_OBJECT (state));
+ g_object_unref (state);
gal_view_instance_set_custom_view (fb->view_instance, view);
- gtk_object_unref (GTK_OBJECT (view));
+ g_object_unref (view);
}
g_free (path);
}
@@ -411,9 +410,9 @@ folder_browser_ui_setup_view_menus (FolderBrowser *fb)
/* Due to CORBA reentrancy, the view could be gone now. */
if (fb->view_instance == NULL)
return;
-
- gtk_signal_connect (GTK_OBJECT (fb->view_instance), "display_view",
- display_view, fb);
+
+ g_signal_connect (fb->view_instance, "display_view", GTK_SIGNAL_FUNC (display_view), fb);
+
display_view (fb->view_instance, gal_view_instance_get_current_view (fb->view_instance), fb);
}
@@ -424,10 +423,10 @@ folder_browser_ui_discard_view_menus (FolderBrowser *fb)
g_assert (fb->view_instance != NULL);
g_assert (fb->view_menus != NULL);
- gtk_object_unref (GTK_OBJECT (fb->view_instance));
+ g_object_unref (fb->view_instance);
fb->view_instance = NULL;
- gtk_object_unref (GTK_OBJECT (fb->view_menus));
+ g_object_unref (fb->view_menus);
fb->view_menus = NULL;
}
@@ -453,6 +452,19 @@ folder_browser_ui_message_list_unfocus (FolderBrowser *fb)
"sensitive", "0", NULL);*/
}
+static const char *
+basename (const char *path)
+{
+ const char *base;
+
+ if (!(base = strrchr (path, '/')))
+ base = path;
+ else
+ base++;
+
+ return base;
+}
+
static void
folder_browser_setup_property_menu (FolderBrowser *fb, BonoboUIComponent *uic)
{
@@ -462,12 +474,12 @@ folder_browser_setup_property_menu (FolderBrowser *fb, BonoboUIComponent *uic)
url = camel_url_new (fb->uri, NULL);
if (url) {
if (url->fragment)
- base = g_basename (url->fragment);
+ base = basename (url->fragment);
else
- base = g_basename (url->path);
+ base = basename (url->path);
}
- if (base && base [0] != 0)
+ if (base && base[0] != '\0')
name = g_strdup_printf (_("Properties for \"%s\""), base);
else
name = g_strdup (_("Properties"));
@@ -554,6 +566,7 @@ folder_browser_ui_add_list (FolderBrowser *fb)
} else {
state = mail_config_get_hide_deleted ();
}
+
bonobo_ui_component_set_prop (uic, "/commands/HideDeleted", "state", state ? "1" : "0", NULL);
bonobo_ui_component_add_listener (uic, "HideDeleted", folder_browser_toggle_hide_deleted, fb);
/* FIXME: this kind of bypasses bonobo but seems the only way when we change components */
@@ -591,7 +604,7 @@ folder_browser_ui_add_global (FolderBrowser *fb)
BonoboUIComponent *uic = fb->uicomp;
if (fb->sensitise_state) {
- g_hash_table_destroy(fb->sensitise_state);
+ g_hash_table_destroy (fb->sensitise_state);
fb->sensitise_state = NULL;
}
@@ -607,7 +620,7 @@ folder_browser_ui_add_global (FolderBrowser *fb)
/* Stop button */
/* TODO: Go through cache, but we can't becaus eof mail-mt.c:set_stop at the moment */
- bonobo_ui_component_set_prop(uic, "/commands/MailStop", "sensitive", "0", NULL);
+ bonobo_ui_component_set_prop (uic, "/commands/MailStop", "sensitive", "0", NULL);
}
void
@@ -640,7 +653,7 @@ fbui_sensitise_item (FolderBrowser *fb, const char *item, int state)
}
if (fb->uicomp) {
- name = alloca (strlen (item) + strlen ("/commands/") + 1);
+ name = g_alloca (strlen (item) + strlen ("/commands/") + 1);
sprintf (name, "/commands/%s", item);
bonobo_ui_component_set_prop (fb->uicomp, name, "sensitive", state ? "1" : "0", NULL);
g_hash_table_insert (fb->sensitise_state, (char *) item, (gpointer) state);
@@ -676,16 +689,15 @@ folder_browser_ui_scan_selection (FolderBrowser *fb)
message_list_foreach (fb->message_list, enumerate_msg, uids);
for (i = 0; i < uids->len; i++) {
-
info = camel_folder_get_message_info (fb->folder, uids->pdata[i]);
if (info == NULL)
continue;
-
+
if (info->flags & CAMEL_MESSAGE_DELETED)
temp_mask |= HAS_DELETED;
else
temp_mask |= HAS_UNDELETED;
-
+
if (info->flags & CAMEL_MESSAGE_SEEN)
temp_mask |= HAS_READ;
else
@@ -695,14 +707,13 @@ folder_browser_ui_scan_selection (FolderBrowser *fb)
temp_mask |= HAS_IMPORTANT;
else
temp_mask |= HAS_UNIMPORTANT;
-
-
+
camel_folder_free_message_info (fb->folder, info);
g_free (uids->pdata[i]);
}
-
+
g_ptr_array_free (uids, TRUE);
-
+
/* yeah, the naming is a bit backwards, but we need to support
* the case when, say, both a deleted and an undeleted message
* are selected. Both the Delete and Undelete menu items should
@@ -711,10 +722,10 @@ folder_browser_ui_scan_selection (FolderBrowser *fb)
* so that it's sensible both above and in the definition of
* the UI items, so deal with it.
*/
-
+
enable_mask |= (~temp_mask & HAS_FLAGS);
}
-
+
if (folder_browser_is_drafts (fb)) {
enable_mask |= IS_DRAFTS_FOLDER;
outgoing = TRUE;
@@ -750,7 +761,7 @@ folder_browser_ui_scan_selection (FolderBrowser *fb)
enable_mask |= SELECTION_NONE;
break;
}
-
+
fbui_sensitize_items (fb, enable_mask);
}
@@ -762,7 +773,7 @@ folder_browser_ui_set_selection_state (FolderBrowser *fb, FolderBrowserSelection
* a recheck of the flags of the selected
* messages.
*/
-
+
if (state == fb->selection_state &&
state != FB_SELSTATE_SINGLE &&
state != FB_SELSTATE_MULTIPLE)
diff --git a/mail/folder-browser.c b/mail/folder-browser.c
index b62b31940e..7b52727220 100644
--- a/mail/folder-browser.c
+++ b/mail/folder-browser.c
@@ -809,7 +809,8 @@ update_status_bar_idle_cb(gpointer data)
update_status_bar (fb);
fb->update_status_bar_idle_id = 0;
- gtk_object_unref (GTK_OBJECT (fb));
+ g_object_unref (fb);
+
return FALSE;
}
@@ -817,7 +818,7 @@ static void
update_status_bar_idle(FolderBrowser *fb)
{
if (fb->update_status_bar_idle_id == 0) {
- gtk_object_ref (GTK_OBJECT (fb));
+ g_object_ref (fb);
fb->update_status_bar_idle_id = g_idle_add (update_status_bar_idle_cb, fb);
}
}
@@ -830,10 +831,10 @@ static void main_folder_changed(CamelObject *o, void *event_data, void *data)
return;
/* so some corba unref doesnt blow us away while we're busy */
- gtk_object_ref((GtkObject *)fb);
- update_status_bar(fb);
+ g_object_ref (fb);
+ update_status_bar (fb);
folder_browser_ui_scan_selection (fb);
- gtk_object_unref((GtkObject *)fb);
+ g_object_unref (fb);
}
static void folder_changed (CamelObject *obj, void *event_data, void *user_data)
@@ -2046,7 +2047,7 @@ on_right_click (ETree *tree, gint row, ETreePath path, gint col, GdkEvent *event
closures = g_ptr_array_new ();
label_menu[0].closure = g_new (struct _label_data, 1);
g_ptr_array_add (closures, label_menu[0].closure);
- gtk_object_ref (GTK_OBJECT (fb));
+ g_object_ref (fb);
((struct _label_data *) label_menu[0].closure)->fb = fb;
((struct _label_data *) label_menu[0].closure)->label = NULL;