[evolution-kolab/ek-wip-gui: 18/22] EPlugin: added initial implementation for folder permissions dialog



commit 0d6a41d1ce8d21531f47c21633fc39911fe78bff
Author: Christian Hilberg <hilberg kernelconcepts de>
Date:   Fri Feb 17 21:15:25 2012 +0100

    EPlugin: added initial implementation for folder permissions dialog
    
    * open a dialog when clicking the "Permissions..."
      context menu entry for Kolab folder
    * dialog does not do anything right now, but can be
      closed via the "cancel" button

 src/eplugin/e-kolab-folder-permissions.c |  195 ++++++++++++++++++++++++++++++
 src/eplugin/e-kolab-folder-permissions.h |    3 +
 src/eplugin/e-kolab-plugin-ui.c          |   11 ++-
 3 files changed, 207 insertions(+), 2 deletions(-)
---
diff --git a/src/eplugin/e-kolab-folder-permissions.c b/src/eplugin/e-kolab-folder-permissions.c
index 3aff248..e2bd55c 100644
--- a/src/eplugin/e-kolab-folder-permissions.c
+++ b/src/eplugin/e-kolab-folder-permissions.c
@@ -28,15 +28,165 @@
 
 #include <config.h>
 
+#include <glib/gi18n-lib.h>
+
+#include <e-util/e-config.h>
+#include <e-util/e-plugin.h>
+
+#include <libekolab/kolab-data-folder-permissions.h>
+#include <libekolab/kolab-data-imap-account.h>
+
+#include <libekolabutil/kolab-util-folder.h>
+
+#include "e-kolab-plugin-types.h"
 #include "e-kolab-folder-permissions.h"
 
 /*----------------------------------------------------------------------------*/
+
+#define  E_KOLAB_PERM_DLG_UIDATA "e-kolab-perm-dlg-uidata"
+
+typedef struct _KolabFolderPermUIWidgets KolabFolderPermUIWidgets;
+struct _KolabFolderPermUIWidgets {
+	GtkWidget *dialog;
+};
+
+typedef struct _KolabFolderPermUIData KolabFolderPermUIData;
+struct _KolabFolderPermUIData {
+	KolabFolderPermUIWidgets *widgets;
+	KolabDataFolderPermissions *permissions;
+	KolabDataImapAccount *account;
+};
+
+/*----------------------------------------------------------------------------*/
 /* internal statics (non-UI) */
 
+static KolabDataFolderPermissions*
+kolab_folder_permissions_read_data_from_folder (const KolabDataImapAccount *account,
+                                                const gchar *foldername,
+                                                KolabFolderTypeID foldertype,
+                                                GError **err)
+{
+	KolabDataFolderPermissions *data = NULL;
+
+	g_assert (account != NULL);
+	g_assert (foldername != NULL);
+	g_assert (foldertype < KOLAB_FOLDER_LAST_TYPE);
+	g_return_val_if_fail (err == NULL || *err == NULL, NULL);
+
+	/* FIXME implement me */
+	g_warning ("%s: FIXME implement me", __func__);
+
+	data = kolab_data_folder_permissions_new ();
+
+	return data;
+}
+
+static gboolean
+kolab_folder_permissions_write_data_to_folder (const KolabDataImapAccount *account,
+                                               const gchar *foldername,
+                                               KolabFolderTypeID foldertype,
+                                               const KolabDataFolderPermissions *data,
+                                               GError **err)
+{
+	g_assert (account != NULL);
+	g_assert (foldername != NULL);
+	g_assert (foldertype < KOLAB_FOLDER_LAST_TYPE);
+	g_assert (data != NULL);
+	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
+
+	/* FIXME implement me */
+	g_warning ("%s: FIXME implement me", __func__);
+
+	return TRUE;
+}
 
 /*----------------------------------------------------------------------------*/
 /* internal statics (UI) */
 
+static KolabFolderPermUIWidgets*
+kolab_folder_perm_ui_widgets_new (void)
+{
+	return g_new0 (KolabFolderPermUIWidgets, 1);
+}
+
+static void
+kolab_folder_perm_ui_widgets_free (KolabFolderPermUIWidgets *widgets)
+{
+	if (widgets == NULL)
+		return;
+
+	g_free (widgets);
+}
+
+static void
+kolab_folder_perm_ui_widgets_enable (KolabFolderPermUIWidgets *widgets,
+                                     gboolean enabled)
+{
+	g_return_if_fail (widgets != NULL);
+
+	/* FIXME implement me */
+	g_warning ("%s: FIXME implement me", __func__);
+}
+
+static KolabFolderPermUIData*
+kolab_folder_perm_ui_data_new ()
+{
+	KolabFolderPermUIData *uidata = NULL;
+
+	uidata = g_new0 (KolabFolderPermUIData, 1);
+	uidata->widgets = kolab_folder_perm_ui_widgets_new ();
+	uidata->permissions = NULL;
+	uidata->account = NULL;
+
+	return uidata;
+}
+
+static void
+kolab_folder_perm_ui_data_free (KolabFolderPermUIData *uidata)
+{
+	if (uidata == NULL)
+		return;
+
+	kolab_folder_perm_ui_widgets_free (uidata->widgets);
+	kolab_data_folder_permissions_free (uidata->permissions);
+	kolab_data_imap_account_free (uidata->account);
+
+	g_free (uidata);
+}
+
+static void
+kolab_folder_perm_ui_data_destroy (gpointer data)
+{
+	if (data == NULL)
+		return;
+
+	kolab_folder_perm_ui_data_free ((KolabFolderPermUIData *)data);
+}
+
+static void
+kolab_folder_perm_ui_clear_all_entries (GObject *dialog)
+{
+	g_return_if_fail (dialog != NULL);
+
+	/* FIXME implement me */
+	g_warning ("%s: FIXME implement me", __func__);
+}
+
+static void
+kolab_folder_perm_ui_response_cb (GObject *dialog,
+                                  gint response_id)
+{
+	g_return_if_fail (dialog != NULL);
+
+	if (response_id != GTK_RESPONSE_OK) {
+		kolab_folder_perm_ui_clear_all_entries (dialog);
+		gtk_widget_destroy (GTK_WIDGET (dialog));
+		return;
+	}
+
+	/* FIXME implement me */
+	g_warning ("%s: FIXME implement me", __func__);
+}
 
 /*----------------------------------------------------------------------------*/
 /* API functions (non-UI) */
@@ -45,5 +195,50 @@
 /*----------------------------------------------------------------------------*/
 /* API functions (UI) */
 
+void
+e_kolab_folder_permissions_ui_dialog (GtkWindow *parent,
+                                      const KolabDataImapAccount *account)
+{
+	KolabFolderPermUIData *uidata = NULL;
+	GObject *dialog = NULL;
+	GtkWidget *content = NULL;
+
+	if (parent != NULL)
+		g_assert (GTK_IS_WINDOW (parent));
+	g_assert (account != NULL);
+
+	uidata = kolab_folder_perm_ui_data_new ();
+
+	uidata->widgets->dialog = \
+		gtk_dialog_new_with_buttons (_("Edit Kolab folder permissions..."),
+		                             parent,
+		                             GTK_DIALOG_DESTROY_WITH_PARENT,
+		                             GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+		                             GTK_STOCK_OK, GTK_RESPONSE_OK,
+		                             NULL);
+
+	uidata->account = kolab_data_imap_account_clone (account);
+
+	dialog = G_OBJECT (uidata->widgets->dialog);
+	g_signal_connect (dialog, "response", G_CALLBACK (kolab_folder_perm_ui_response_cb), NULL);
+	g_object_set_data_full (dialog, E_KOLAB_PERM_DLG_UIDATA, uidata, kolab_folder_perm_ui_data_destroy);
+
+	content = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+
+	/* TODO set dialog content */
+
+	/* TODO set signals */
+
+	gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+
+	kolab_folder_perm_ui_widgets_enable (uidata->widgets, FALSE);
+
+	gtk_dialog_set_response_sensitive (GTK_DIALOG (uidata->widgets->dialog),
+	                                   GTK_RESPONSE_OK,
+	                                   FALSE);
+
+	gtk_widget_show_all (content);
+	gtk_widget_show (GTK_WIDGET (dialog));
+}
 
 /*----------------------------------------------------------------------------*/
diff --git a/src/eplugin/e-kolab-folder-permissions.h b/src/eplugin/e-kolab-folder-permissions.h
index 12fd07a..15cde4e 100644
--- a/src/eplugin/e-kolab-folder-permissions.h
+++ b/src/eplugin/e-kolab-folder-permissions.h
@@ -36,6 +36,9 @@
 
 /*----------------------------------------------------------------------------*/
 
+void
+e_kolab_folder_permissions_ui_dialog (GtkWindow *parent,
+                                      const KolabDataImapAccount *account);
 
 /*----------------------------------------------------------------------------*/
 
diff --git a/src/eplugin/e-kolab-plugin-ui.c b/src/eplugin/e-kolab-plugin-ui.c
index 0a37865..54b3ec2 100644
--- a/src/eplugin/e-kolab-plugin-ui.c
+++ b/src/eplugin/e-kolab-plugin-ui.c
@@ -43,9 +43,10 @@
 #include <mail/em-config.h>
 #include <mail/em-folder-tree.h>
 
+#include <libekolab/kolab-data-imap-account.h>
 #include <libekolabutil/kolab-util-camel.h>
-#include <libekolabutil/kolab-util-types.h>
 
+#include "e-kolab-folder-permissions.h"
 #include "e-kolab-plugin-ui.h"
 
 /*----------------------------------------------------------------------------*/
@@ -152,11 +153,17 @@ static void
 kolab_plugin_ui_action_folder_permissions_cb (GtkAction *action,
                                               EShellView *shell_view)
 {
+	KolabDataImapAccount *account = NULL;
+
 	g_assert (action != NULL);
 	g_assert (E_IS_SHELL_VIEW (shell_view));
 
 	/* FIXME implement me */
 	g_warning ("%s: FIXME implement me", __func__);
+
+	account = kolab_data_imap_account_new ();
+	e_kolab_folder_permissions_ui_dialog (NULL, account);
+	kolab_data_imap_account_free (account);
 }
 
 static void
@@ -191,7 +198,7 @@ kolab_plugin_ui_get_selected_source (EShellView *shell_view,
 	source = e_source_selector_peek_primary_selection (selector);
 	uri = source ? e_source_get_uri (source) : NULL;
 	/* check whether we have a Kolab ESource selected */
-	if (uri && g_str_has_prefix (uri, KOLAB_URI_PREFIX))
+	if (uri && g_str_has_prefix (uri, KOLAB_CAMEL_URI_PREFIX))
 		source = g_object_ref (source);
 	else
 		source = NULL;



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