diff options
author | Iain Holmes <iain@src.gnome.org> | 2002-06-26 23:12:24 +0800 |
---|---|---|
committer | Iain Holmes <iain@src.gnome.org> | 2002-06-26 23:12:24 +0800 |
commit | 6f679c6c889771b0ca773cf90d2bfde4afd164ee (patch) | |
tree | 0aad039490c852e1b27d8a2f0a55a66837baca12 /shell | |
parent | 65117fc884fdc8772306d97b076807b0ab3998e2 (diff) | |
download | gsoc2013-evolution-6f679c6c889771b0ca773cf90d2bfde4afd164ee.tar.gz gsoc2013-evolution-6f679c6c889771b0ca773cf90d2bfde4afd164ee.tar.zst gsoc2013-evolution-6f679c6c889771b0ca773cf90d2bfde4afd164ee.zip |
Changes for an importer bug and to get the storagesetselector in the summary
svn path=/trunk/; revision=17289
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ChangeLog | 27 | ||||
-rw-r--r-- | shell/Evolution-StorageSetView.idl | 3 | ||||
-rw-r--r-- | shell/e-shell-importer.c | 127 | ||||
-rw-r--r-- | shell/e-storage-set-view.c | 1 | ||||
-rw-r--r-- | shell/evolution-storage-set-view-listener.c | 21 | ||||
-rw-r--r-- | shell/evolution-storage-set-view-listener.h | 3 | ||||
-rw-r--r-- | shell/evolution-storage-set-view.c | 63 |
7 files changed, 216 insertions, 29 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog index eb73a348bb..4fa46fc8d1 100644 --- a/shell/ChangeLog +++ b/shell/ChangeLog @@ -1,3 +1,30 @@ +2002-06-26 Iain <iain@ximian.com> + + * Evolution-StorageSetView.idl: Add a notifyFolderToggled method, + allow checkedFolders to be writable. + + * e-shell-importer.c (free_iid_list): Free the list of iid infos. + (get_name_from_component_info): Move this function from futher down + the file to here because it's useful. + (choose_importer_from_list): Present the user with a list of importer + names to select the one they want to use. + (get_iid_for_filetype): Store the name of the importer as well as the + iid in the list. If there are multiple matches, show the user a list. + + * evolution-storage-set-view-listener.[ch]: Add a folder toggled signal. + (impl_GNOME_Evolution_StorageSetViewListener_notifyFolderToggled): + Notify listeners that a folder has been toggled. + (corba_class_init): Hook up the new method. + (class_init): Create the new signal. + + * evolution-storage-set-view.c + (storage_set_view_widget_folder_toggled_cb): Call the CORBA method for + each listener. + (impl_StorageSetView__set_checkedFolders): Set the checked folders + from the list. + (impl_StorageSetView__get_checkedFolders): Don't include blanks in the + list. + 2002-06-24 Ettore Perazzoli <ettore@ximian.com> * e-shell-folder-selection-dialog.c (impl_clicked): Pass diff --git a/shell/Evolution-StorageSetView.idl b/shell/Evolution-StorageSetView.idl index 7ed45a3358..9aca41f6ad 100644 --- a/shell/Evolution-StorageSetView.idl +++ b/shell/Evolution-StorageSetView.idl @@ -14,6 +14,7 @@ module GNOME { module Evolution { interface StorageSetViewListener { void notifyFolderSelected (in string uri); + void notifyFolderToggled (); }; /* FIXME: Maybe we should have a generic Bonobo::Listener interface. */ @@ -24,7 +25,7 @@ module Evolution { attribute boolean showFolders; attribute boolean showCheckboxes; - readonly attribute FolderList checkedFolders; + attribute FolderList checkedFolders; void addListener (in StorageSetViewListener listener) raises (AlreadyListening); diff --git a/shell/e-shell-importer.c b/shell/e-shell-importer.c index 4e48d41bc4..f555d553b7 100644 --- a/shell/e-shell-importer.c +++ b/shell/e-shell-importer.c @@ -322,12 +322,90 @@ dialog_destroy_cb (GtkObject *object, icd->destroyed = TRUE; } +struct _IIDInfo { + char *iid; + char *name; +}; + +static void +free_iid_list (GList *list) +{ + for (; list; list = list->next) { + struct _IIDInfo *iid = list->data; + + g_free (iid->iid); + g_free (iid->name); + g_free (iid); + } +} + +static const char * +get_name_from_component_info (const OAF_ServerInfo *info) +{ + OAF_Property *property; + const char *name; + + property = oaf_server_info_prop_find ((OAF_ServerInfo *) info, + "evolution:menu-name"); + if (property == NULL || property->v._d != OAF_P_STRING) + return NULL; + + name = property->v._u.value_string; + + return name; +} + +static char * +choose_importer_from_list (GList *importer_list) +{ + GtkWidget *dialog, *clist; + GList *p; + int ans; + char *iid; + + dialog = gnome_dialog_new (_("Select importer"), + GNOME_STOCK_BUTTON_OK, + GNOME_STOCK_BUTTON_CANCEL, + NULL); + clist = gtk_clist_new (1); + for (p = importer_list; p; p = p->next) { + struct _IIDInfo *iid; + char *text[1]; + int row; + + iid = p->data; + text[0] = iid->name; + row = gtk_clist_append (GTK_CLIST (clist), text); + gtk_clist_set_row_data (GTK_CLIST (clist), row, iid->iid); + } + + gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), clist, + TRUE, TRUE, 0); + gtk_widget_show (clist); + + switch (gnome_dialog_run (GNOME_DIALOG (dialog))) { + case 0: + ans = GPOINTER_TO_INT (GTK_CLIST (clist)->selection->data); + iid = gtk_clist_get_row_data (GTK_CLIST (clist), ans); + break; + + case 1: + default: + iid = NULL; + break; + } + + gtk_widget_destroy (dialog); + + return g_strdup (iid); +} + static char * get_iid_for_filetype (const char *filename) { OAF_ServerInfoList *info_list; CORBA_Environment ev; - GList *can_handle = NULL, *l; + GList *can_handle = NULL; char *ret_iid; int i, len = 0; @@ -338,7 +416,7 @@ get_iid_for_filetype (const char *filename) CORBA_Environment ev2; CORBA_Object importer; const OAF_ServerInfo *info; - + info = info_list->_buffer + i; CORBA_exception_init (&ev2); @@ -351,29 +429,40 @@ get_iid_for_filetype (const char *filename) if (GNOME_Evolution_Importer_supportFormat (importer, filename, &ev2)) { - can_handle = g_list_prepend (can_handle, - g_strdup (info->iid)); + struct _IIDInfo *iid; + + iid = g_new (struct _IIDInfo, 1); + iid->iid = g_strdup (info->iid); + iid->name = g_strdup (get_name_from_component_info (info)); + + can_handle = g_list_prepend (can_handle, iid); len++; } bonobo_object_release_unref (importer, &ev2); CORBA_exception_free (&ev2); } + CORBA_free (info_list); if (len == 1) { - ret_iid = can_handle->data; + struct _IIDInfo *iid; + + iid = can_handle->data; + + ret_iid = g_strdup (iid->iid); + + free_iid_list (can_handle); g_list_free (can_handle); + return ret_iid; } else if (len > 1) { - /* FIXME: Some way to choose between multiple iids */ - /* FIXME: Free stuff */ - g_warning ("Multiple iids can support %s", filename); - ret_iid = g_strdup (can_handle->data); + /* Display all the IIDs */ + ret_iid = choose_importer_from_list (can_handle); - for (l = can_handle; l; l = l->next) - g_free (l->data); + free_iid_list (can_handle); g_list_free (can_handle); + return ret_iid; } else { return NULL; @@ -529,22 +618,6 @@ filename_changed (GtkEntry *entry, TRUE, !page->need_filename, TRUE); } -static const char * -get_name_from_component_info (const OAF_ServerInfo *info) -{ - OAF_Property *property; - const char *name; - - property = oaf_server_info_prop_find ((OAF_ServerInfo *) info, - "evolution:menu-name"); - if (property == NULL || property->v._d != OAF_P_STRING) - return NULL; - - name = property->v._u.value_string; - - return name; -} - static void item_selected (GtkWidget *item, ImportData *data) diff --git a/shell/e-storage-set-view.c b/shell/e-storage-set-view.c index f059e06493..a856ce5c93 100644 --- a/shell/e-storage-set-view.c +++ b/shell/e-storage-set-view.c @@ -2071,6 +2071,7 @@ e_storage_set_view_set_checkboxes_list (EStorageSetView *storage_set_view, priv->checkboxes = g_hash_table_new (g_str_hash, g_str_equal); for (; checkboxes; checkboxes = g_list_next (checkboxes)) { char *path = checkboxes->data; + if (g_hash_table_lookup (priv->checkboxes, path)) continue; path = g_strdup (path); diff --git a/shell/evolution-storage-set-view-listener.c b/shell/evolution-storage-set-view-listener.c index 28841f72d4..310a2f2844 100644 --- a/shell/evolution-storage-set-view-listener.c +++ b/shell/evolution-storage-set-view-listener.c @@ -41,6 +41,7 @@ struct _EvolutionStorageSetViewListenerPrivate { enum { FOLDER_SELECTED, + FOLDER_TOGGLED, LAST_SIGNAL }; static guint signals[LAST_SIGNAL] = { 0 }; @@ -71,6 +72,17 @@ impl_GNOME_Evolution_StorageSetViewListener_notifyFolderSelected (PortableServer gtk_signal_emit (GTK_OBJECT (listener), signals[FOLDER_SELECTED], uri); } +static void +impl_GNOME_Evolution_StorageSetViewListener_notifyFolderToggled (PortableServer_Servant servant, + CORBA_Environment *ev) +{ + EvolutionStorageSetViewListener *listener; + + listener = gtk_object_from_servant (servant); + + gtk_signal_emit (GTK_OBJECT (listener), signals[FOLDER_TOGGLED]); +} + static EvolutionStorageSetViewListenerServant * create_servant (EvolutionStorageSetViewListener *listener) { @@ -170,7 +182,8 @@ corba_class_init (void) epv = g_new0 (POA_GNOME_Evolution_StorageSetViewListener__epv, 1); epv->notifyFolderSelected = impl_GNOME_Evolution_StorageSetViewListener_notifyFolderSelected; - + epv->notifyFolderToggled = impl_GNOME_Evolution_StorageSetViewListener_notifyFolderToggled; + vepv = & my_GNOME_Evolution_StorageSetViewListener_vepv; vepv->_base_epv = base_epv; vepv->GNOME_Evolution_StorageSetViewListener_epv = epv; @@ -193,6 +206,12 @@ class_init (EvolutionStorageSetViewListenerClass *klass) gtk_marshal_NONE__STRING, GTK_TYPE_NONE, 1, GTK_TYPE_STRING); + signals[FOLDER_TOGGLED] = gtk_signal_new ("folder_toggled", + GTK_RUN_FIRST, + object_class->type, + GTK_SIGNAL_OFFSET (EvolutionStorageSetViewListenerClass, folder_toggled), + gtk_marshal_NONE__NONE, + GTK_TYPE_NONE, 0); gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); diff --git a/shell/evolution-storage-set-view-listener.h b/shell/evolution-storage-set-view-listener.h index c95778ee7e..b81ab1ed30 100644 --- a/shell/evolution-storage-set-view-listener.h +++ b/shell/evolution-storage-set-view-listener.h @@ -54,6 +54,9 @@ struct _EvolutionStorageSetViewListenerClass { void (* folder_selected) (EvolutionStorageSetViewListener *listener, const char *uri); + void (* folder_toggled) (EvolutionStorageSetViewListener *listener, + const char *uri, + gboolean active); }; diff --git a/shell/evolution-storage-set-view.c b/shell/evolution-storage-set-view.c index 6016007015..4253ea3158 100644 --- a/shell/evolution-storage-set-view.c +++ b/shell/evolution-storage-set-view.c @@ -68,6 +68,32 @@ storage_set_view_widget_folder_selected_cb (EStorageSetView *storage_set_view_wi } } +static void +storage_set_view_widget_folder_toggled_cb (EStorageSetView *storage_set_view_widget, + void *data) +{ + EvolutionStorageSetView *storage_set_view; + EvolutionStorageSetViewPrivate *priv; + GList *p; + + storage_set_view = EVOLUTION_STORAGE_SET_VIEW (data); + priv = storage_set_view->priv; + + for (p = priv->listeners; p != NULL; p = p->next) { + CORBA_Environment ev; + GNOME_Evolution_StorageSetViewListener listener; + + CORBA_exception_init (&ev); + + listener = (GNOME_Evolution_StorageSetViewListener) p->data; + GNOME_Evolution_StorageSetViewListener_notifyFolderToggled (listener, &ev); + + /* FIXME: What if we fail? */ + + CORBA_exception_free (&ev); + } +} + /* Listener handling. */ @@ -271,6 +297,35 @@ impl_StorageSetView__get_showCheckboxes (PortableServer_Servant servant, return e_storage_set_view_get_show_checkboxes (E_STORAGE_SET_VIEW (priv->storage_set_view_widget)); } +static void +impl_StorageSetView__set_checkedFolders (PortableServer_Servant servant, + const GNOME_Evolution_FolderList *list, + CORBA_Environment *ev) +{ + BonoboObject *bonobo_object; + EvolutionStorageSetView *storage_set_view; + EvolutionStorageSetViewPrivate *priv; + GList *path_list = NULL; + GList *p; + int i; + + bonobo_object = bonobo_object_from_servant (servant); + storage_set_view = EVOLUTION_STORAGE_SET_VIEW (bonobo_object); + priv = storage_set_view->priv; + + for (i = 0; i < list->_length; i++) { + path_list = g_list_append (path_list, g_strdup (list->_buffer[i].evolutionUri)); + } + + e_storage_set_view_set_checkboxes_list (E_STORAGE_SET_VIEW (priv->storage_set_view_widget), path_list); + + for (p = path_list; p; p = p->next) { + g_free (p->data); + } + + g_list_free (path_list); +} + static GNOME_Evolution_FolderList * impl_StorageSetView__get_checkedFolders (PortableServer_Servant servant, CORBA_Environment *ev) @@ -309,6 +364,11 @@ impl_StorageSetView__get_checkedFolders (PortableServer_Servant servant, folder = e_storage_set_get_folder (storage_set, path); if (folder == NULL) { g_warning ("Cannot find folder -- %s", path); + + /* Subtract here so that we don't start putting + ininitialised blanks into the CORBA list */ + return_list->_length--; + i--; continue; } @@ -374,6 +434,7 @@ corba_class_init (void) epv->_get_showFolders = impl_StorageSetView__get_showFolders; epv->_set_showCheckboxes = impl_StorageSetView__set_showCheckboxes; epv->_get_showCheckboxes = impl_StorageSetView__get_showCheckboxes; + epv->_set_checkedFolders = impl_StorageSetView__set_checkedFolders; epv->_get_checkedFolders = impl_StorageSetView__get_checkedFolders; vepv = &StorageSetView_vepv; @@ -430,6 +491,8 @@ evolution_storage_set_view_construct (EvolutionStorageSetView *storage_set_view, gtk_signal_connect (GTK_OBJECT (priv->storage_set_view_widget), "folder_selected", GTK_SIGNAL_FUNC (storage_set_view_widget_folder_selected_cb), storage_set_view); + gtk_signal_connect (GTK_OBJECT (priv->storage_set_view_widget), "checkboxes_changed", + GTK_SIGNAL_FUNC (storage_set_view_widget_folder_toggled_cb), storage_set_view); } EvolutionStorageSetView * |