[evolution-kolab/ek-wip-acl: 1/6] EPlugin: folder properties dialog code reorganization



commit e718fac8abfe217d036c3620fd7037b4f8db03cd
Author: Christian Hilberg <hilberg kernelconcepts de>
Date:   Tue Aug 7 16:48:30 2012 +0200

    EPlugin: folder properties dialog code reorganization
    
    * moved code to create dialog widgets/data into
      separate static function
    * moved code to assemble the dialog into
      separate static function

 src/eplugin/e-kolab-plugin-ui.c |   56 +++++++++++++++++++++++++++-----------
 1 files changed, 40 insertions(+), 16 deletions(-)
---
diff --git a/src/eplugin/e-kolab-plugin-ui.c b/src/eplugin/e-kolab-plugin-ui.c
index d96d5d4..f0ff7f2 100644
--- a/src/eplugin/e-kolab-plugin-ui.c
+++ b/src/eplugin/e-kolab-plugin-ui.c
@@ -205,19 +205,14 @@ kolab_folder_prop_ui_response_cb (GObject *dialog,
 /*----------------------------------------------------------------------------*/
 /* internal statics (UI) */
 
-static void
-kolab_plugin_ui_action_kolab_properties_cb (GtkAction *action,
-                                            EShellView *shell_view)
+static KolabFolderPropUIData*
+kolab_folder_prop_ui_new_dialog_data (EShellView *shell_view)
 {
 	KolabFolderPropUIData *uidata = NULL;
-	GObject *dialog = NULL;
-	GtkWidget *content = NULL;
-	GtkNotebook *notebook = NULL;
 	gchar *foldername = NULL;
 	gchar *sourcename = NULL;
 
-	g_return_if_fail (action != NULL);
-	g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
+	g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
 
 	foldername = e_kolab_plugin_util_ui_get_selected_foldername (shell_view);
 	if (foldername == NULL) {
@@ -230,7 +225,7 @@ kolab_plugin_ui_action_kolab_properties_cb (GtkAction *action,
 		 */
 		g_warning ("%s()[%u]: Selected folder is no Kolab folder node",
 		           __func__, __LINE__);
-		return;
+		return NULL;
 	}
 
 	/* sourcename may be NULL */
@@ -238,6 +233,7 @@ kolab_plugin_ui_action_kolab_properties_cb (GtkAction *action,
 
 	uidata = kolab_folder_prop_ui_data_new ();
 	uidata->widgets->alert_bar = e_alert_bar_new ();
+	uidata->widgets->notebook = gtk_notebook_new ();
 
 	uidata->widgets->selected_folder =
 		e_kolab_plugin_util_ui_selected_folder_widget (foldername,
@@ -268,17 +264,22 @@ kolab_plugin_ui_action_kolab_properties_cb (GtkAction *action,
 	if (sourcename != NULL)
 		g_free (sourcename);
 
-	/* FIXME get account data here */
 	uidata->account = kolab_data_imap_account_new ();
 
-	dialog = G_OBJECT (uidata->widgets->dialog);
-	g_signal_connect (dialog, "response", G_CALLBACK (kolab_folder_prop_ui_response_cb), NULL);
-	g_object_set_data_full (dialog, E_KOLAB_PROP_DLG_UIDATA, uidata, kolab_folder_prop_ui_data_destroy);
+	return uidata;
+}
+
+static void
+kolab_folder_prop_ui_assemble_dialog (KolabFolderPropUIData *uidata)
+{
+	GtkWidget *content = NULL;
+	GtkNotebook *notebook = NULL;
 
-	content = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+	g_return_if_fail (uidata != NULL);
+
+	content = gtk_dialog_get_content_area (GTK_DIALOG (uidata->widgets->dialog));
 	gtk_container_add (GTK_CONTAINER (content), uidata->widgets->alert_bar);
 	gtk_container_add (GTK_CONTAINER (content), uidata->widgets->selected_folder);
-	uidata->widgets->notebook = gtk_notebook_new ();
 	notebook = GTK_NOTEBOOK (uidata->widgets->notebook);
 	gtk_notebook_set_show_border (notebook, TRUE);
 	gtk_container_add (GTK_CONTAINER (content),
@@ -303,6 +304,30 @@ kolab_plugin_ui_action_kolab_properties_cb (GtkAction *action,
 	                                 uidata->perm_ui_data->widgets->container,
 	                                 C_("Kolab Folder Properties",
 	                                    "IMAP Access Control"));
+	gtk_widget_show_all (content);
+}
+
+static void
+kolab_plugin_ui_action_kolab_properties_cb (GtkAction *action,
+                                            EShellView *shell_view)
+{
+	KolabFolderPropUIData *uidata = NULL;
+	GObject *dialog = NULL;
+
+	g_return_if_fail (action != NULL);
+	g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
+
+	/* create widgets and payload data structures */
+	uidata = kolab_folder_prop_ui_new_dialog_data (shell_view);
+	g_return_if_fail (uidata != NULL);
+
+	/* assemble dialog */
+	kolab_folder_prop_ui_assemble_dialog (uidata);
+
+	/* connect response callback */
+	dialog = G_OBJECT (uidata->widgets->dialog);
+	g_signal_connect (dialog, "response", G_CALLBACK (kolab_folder_prop_ui_response_cb), NULL);
+	g_object_set_data_full (dialog, E_KOLAB_PROP_DLG_UIDATA, uidata, kolab_folder_prop_ui_data_destroy);
 
 	/* TODO connect signals */
 
@@ -314,7 +339,6 @@ kolab_plugin_ui_action_kolab_properties_cb (GtkAction *action,
 	                                   GTK_RESPONSE_OK,
 	                                   FALSE);
 
-	gtk_widget_show_all (content);
 	gtk_widget_hide (uidata->widgets->alert_bar);
 	gtk_widget_show (uidata->widgets->dialog);
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]