Fix bug #3151 ‘loaded vCalendar plugin "disables"…
authorRicardo Mones <ricardo@mones.org>
Wed, 21 Oct 2015 20:54:47 +0000 (22:54 +0200)
committerRicardo Mones <ricardo@mones.org>
Wed, 21 Oct 2015 20:54:47 +0000 (22:54 +0200)
…gnome-shells calendar view entries’

src/plugins/vcalendar/plugin.c
src/plugins/vcalendar/vcal_dbus.c
src/plugins/vcalendar/vcal_prefs.c
src/plugins/vcalendar/vcal_prefs.h

index 023620b..90de166 100644 (file)
@@ -36,6 +36,7 @@
 #include "plugin.h"
 
 #include "vcal_dbus.h"
+#include "vcal_prefs.h"
 
 gint plugin_init(gchar **error)
 {
@@ -47,15 +48,18 @@ gint plugin_init(gchar **error)
 
        curl_global_init(CURL_GLOBAL_DEFAULT);
        vcalendar_init();
-       connect_dbus();
+       if (vcalprefs.calendar_server)
+               connect_dbus();
 
-       return 0;       
+       return 0;
 }
 
 gboolean plugin_done(void)
 {
-       disconnect_dbus();
+       if (vcalprefs.calendar_server)
+               disconnect_dbus();
        vcalendar_done();
+
        return TRUE;
 }
 
index 8cb1854..38d86b3 100644 (file)
@@ -176,6 +176,7 @@ static void bus_acquired(GDBusConnection *connection,
 
 void connect_dbus(void)
 {
+       debug_print("connect_dbus() invoked\n");
        introspection_data = g_dbus_node_info_new_for_xml(
                                introspection_xml, NULL);
        if (introspection_data == NULL) {
@@ -198,6 +199,7 @@ void connect_dbus(void)
 
 void disconnect_dbus(void)
 {
+       debug_print("disconnect_dbus() invoked\n");
        g_bus_unown_name(dbus_own_id);
 }
 
index 859b893..64ea6da 100644 (file)
@@ -38,6 +38,7 @@
 #include "vcalendar.h"
 #include "vcal_prefs.h"
 #include "vcal_folder.h"
+#include "vcal_dbus.h"
 
 #define PREFS_BLOCK_NAME "VCalendar"
 
@@ -70,6 +71,7 @@ struct VcalendarPage
        GtkWidget *freebusy_get_url_entry;
        
        GtkWidget *ssl_verify_peer_checkbtn;
+       GtkWidget *calendar_server_checkbtn;
 };
 
 VcalendarPrefs vcalprefs;
@@ -115,6 +117,9 @@ static PrefParam param[] = {
        {"ssl_verify_peer", "TRUE", &vcalprefs.ssl_verify_peer, P_BOOL,
         NULL, NULL, NULL},
 
+       {"calendar_server", "FALSE", &vcalprefs.calendar_server, P_BOOL,
+        NULL, NULL, NULL},
+
        {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
 };
 
@@ -208,6 +213,16 @@ void register_orage_checkbtn_toggled(GtkToggleButton       *toggle_btn,
        vcalprefs.orage_registered = gtk_toggle_button_get_active(toggle_btn);
 }
 
+void calendar_server_checkbtn_toggled(GtkToggleButton *toggle, GtkWidget *widget)
+{
+       gboolean active = gtk_toggle_button_get_active(toggle);
+       if (active)
+               connect_dbus();
+       else
+               disconnect_dbus();
+       vcalprefs.calendar_server = active;
+}
+
 static void vcal_prefs_create_widget_func(PrefsPage * _page,
                                           GtkWindow * window,
                                           gpointer data)
@@ -230,6 +245,7 @@ static void vcal_prefs_create_widget_func(PrefsPage * _page,
        GtkWidget *export_command_label;
        GtkWidget *export_command_entry;
        GtkWidget *register_orage_checkbtn;
+       GtkWidget *calendar_server_checkbtn;
 
        GtkWidget *export_user_label;
        GtkWidget *export_user_entry;
@@ -399,6 +415,16 @@ static void vcal_prefs_create_widget_func(PrefsPage * _page,
        gtk_widget_show (register_orage_checkbtn);
        gtk_box_pack_start(GTK_BOX (hbox3), register_orage_checkbtn, TRUE, TRUE, 0);
 
+       calendar_server_checkbtn = gtk_check_button_new_with_label(_("Export as GNOME shell calendar server"));
+       CLAWS_SET_TIP(calendar_server_checkbtn,
+                     _("Register D-Bus calendar server interface to export Claws Mail's calendar"));
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(calendar_server_checkbtn),
+                                    vcalprefs.calendar_server);
+       g_signal_connect(G_OBJECT(calendar_server_checkbtn), "toggled",
+                        G_CALLBACK(calendar_server_checkbtn_toggled), NULL);
+       gtk_widget_show(calendar_server_checkbtn);
+       gtk_box_pack_start(GTK_BOX(hbox3), calendar_server_checkbtn, TRUE, TRUE, 0);
+
 /* freebusy export */
 /* export enable + path stuff */
        PACK_FRAME(vbox2, frame_freebusy_export, _("Free/Busy information"));
index fd4637a..11475fa 100644 (file)
@@ -43,6 +43,7 @@ struct _VcalendarPrefs
        gchar           *export_freebusy_pass;
        gboolean         orage_registered;
        gboolean         ssl_verify_peer;
+       gboolean         calendar_server;
 };
 
 extern VcalendarPrefs vcalprefs;