~ubuntu-branches/ubuntu/precise/evolution/precise

« back to all changes in this revision

Viewing changes to capplet/anjal-settings-main.c

  • Committer: Bazaar Package Importer
  • Author(s): Mathieu Trudel-Lapierre
  • Date: 2011-06-24 00:27:53 UTC
  • mfrom: (1.1.80 upstream)
  • Revision ID: james.westby@ubuntu.com-20110624002753-2vh1vjavlya7r103
Tags: 3.1.2-0ubuntu1
* New upstream release 3.1.2.
* debian/control: adjust Build-Depends to match new upstream requirements for
  the new release.
* debian/control: update evolution and evolution-dev Depends to require the
  right versions of e-d-s (>= 3.1, << 3.2), and drop libunique-3.0-dev.
* debian/control,
  debian/evolution.install: remove groupwise-features from the plugin list,
  it's now split out into a separate module.
* debian/patches/03_lpi.patch: refreshed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 *
23
23
 */
24
24
 
 
25
#ifdef HAVE_CONFIG_H
 
26
#include <config.h>
 
27
#endif
 
28
 
25
29
#include <sys/types.h>
26
30
#include <sys/stat.h>
27
31
#include <locale.h>
29
33
#include <string.h>
30
34
#include <stdio.h>
31
35
 
32
 
#include <config.h>
33
 
 
34
36
#include <gtk/gtk.h>
35
37
#include <glib/gi18n.h>
36
38
#include <libedataserverui/e-passwords.h>
56
58
#endif
57
59
#endif
58
60
 
59
 
#include <unique/unique.h>
60
 
 
61
 
gboolean windowed = FALSE;
62
 
gboolean anjal_icon_decoration = FALSE;
63
 
gboolean default_app =  FALSE;
64
61
guint32 socket_id = 0;
65
62
GtkWidget *main_window;
66
63
static gchar **remaining_args;
67
 
extern gchar *shell_moduledir;
68
 
 
69
 
#define GCONF_KEY_MAILTO_ENABLED "/desktop/gnome/url-handlers/mailto/enabled"
70
 
#define GCONF_KEY_MAILTO_COMMAND "/desktop/gnome/url-handlers/mailto/command"
71
 
#define ANJAL_MAILTO_COMMAND "anjal %s"
72
 
 
73
 
static UniqueResponse
74
 
mail_message_received_cb (UniqueApp         *app G_GNUC_UNUSED,
75
 
                         gint               command,
76
 
                         UniqueMessageData *message_data,
77
 
                         guint              time_ G_GNUC_UNUSED,
78
 
                         gpointer           user_data)
79
 
{
80
 
         GtkWindow *window = (GtkWindow *) user_data;
81
 
 
82
 
         switch (command) {
83
 
         case UNIQUE_ACTIVATE :
84
 
                  gtk_window_deiconify (window);
85
 
                  gtk_window_present (window);
86
 
                  return UNIQUE_RESPONSE_OK;
87
 
 
88
 
         case UNIQUE_NEW :
89
 
                  return UNIQUE_RESPONSE_OK;
90
 
 
91
 
         case UNIQUE_OPEN :
92
 
                  gdk_window_raise (gtk_widget_get_window (GTK_WIDGET (window)));
93
 
                  gtk_window_deiconify (window);
94
 
                  gtk_window_present (window);
95
 
 
96
 
                  return UNIQUE_RESPONSE_OK;
97
 
         }
98
 
 
99
 
         return UNIQUE_RESPONSE_PASSTHROUGH;
100
 
}
101
64
 
102
65
static void
103
66
categories_icon_theme_hack (void)
130
93
}
131
94
 
132
95
static void
133
 
check_and_set_default_mail (void)
134
 
{
135
 
        GConfClient *client = gconf_client_get_default ();
136
 
        gchar *mailer;
137
 
 
138
 
        mailer  = gconf_client_get_string (client, GCONF_KEY_MAILTO_COMMAND, NULL);
139
 
        if (mailer && *mailer && (strcmp (mailer, ANJAL_MAILTO_COMMAND) == 0)) {
140
 
                g_object_unref (client);
141
 
                return; /* Anjal is the default mailer */
142
 
        }
143
 
 
144
 
        gconf_client_set_bool (client, GCONF_KEY_MAILTO_ENABLED, TRUE, NULL);
145
 
        gconf_client_set_string (client, GCONF_KEY_MAILTO_COMMAND, ANJAL_MAILTO_COMMAND, NULL);
146
 
        g_object_unref (client);
147
 
}
148
 
 
149
 
static gboolean
150
 
idle_cb (MailCappletShell *mshell G_GNUC_UNUSED)
151
 
{
152
 
 
153
 
        if (default_app) {
154
 
                check_and_set_default_mail ();
155
 
        }
156
 
 
157
 
        return FALSE;
158
 
}
159
 
 
160
 
static void
161
96
create_default_shell (void)
162
97
{
163
98
        main_window = mail_capplet_shell_new (socket_id, FALSE, TRUE);
164
99
        if (!socket_id)
165
100
                gtk_widget_show (main_window);
166
 
        g_idle_add ((GSourceFunc) idle_cb, remaining_args);
167
101
}
168
102
 
169
103
gint
170
104
main (gint argc, gchar *argv[])
171
105
{
172
106
        GError *error = NULL;
173
 
        GConfClient *client;
174
 
 
175
 
        UniqueApp *app;
176
107
 
177
108
#ifdef G_OS_WIN32
178
109
        /* Reduce risks */
213
144
#endif
214
145
 
215
146
        static GOptionEntry entries[] = {
216
 
                { "windowed", 'w', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_NONE, &windowed,N_("Run Anjal in a window"), NULL },
217
 
                { "default-mailer", 'd', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_NONE, &default_app,N_("Make Anjal the default email client"), NULL },
218
147
                { "socket",
219
148
                  's',
220
149
                  G_OPTION_FLAG_IN_MAIN,
235
164
 
236
165
        setlocale (LC_ALL, NULL);
237
166
 
238
 
        if (!gtk_init_with_args (&argc, &argv, _("Anjal email client"), entries, NULL, &error)) {
239
 
                g_error ("Unable to start Anjal: %s\n", error->message);
240
 
                g_error_free (error);
241
 
        }
 
167
        if (!gtk_init_with_args (&argc, &argv, NULL, entries, NULL, &error))
 
168
                g_error ("%s", error->message);
242
169
 
243
170
        if (!g_thread_get_initialized ())
244
171
                g_thread_init (NULL);
245
172
 
246
 
        client = gconf_client_get_default ();
247
 
 
248
173
        e_passwords_init ();
249
 
        gtk_icon_theme_append_search_path (gtk_icon_theme_get_default(), PACKAGE_DATA_DIR G_DIR_SEPARATOR_S "anjal" G_DIR_SEPARATOR_S "icons");
250
174
        categories_icon_theme_hack ();
251
175
 
252
 
        gconf_client_set_bool (client, "/apps/evolution/mail/display/enable_vfolders", FALSE, NULL);
253
 
        g_object_unref (client);
254
 
 
255
 
        app = unique_app_new ("org.gnome.AnjalSettings", NULL);
256
 
          if (unique_app_is_running (app) && !socket_id)  {
257
 
                   gboolean cmd_line =  (remaining_args && remaining_args[0] != NULL);
258
 
 
259
 
                  if (!cmd_line)
260
 
                        unique_app_send_message (app, UNIQUE_ACTIVATE, NULL);
261
 
                  else {
262
 
                          UniqueMessageData *data = unique_message_data_new ();
263
 
                          unique_message_data_set_text (data, remaining_args[0], -1);
264
 
                          unique_app_send_message (app, UNIQUE_OPEN, data);
265
 
                          unique_message_data_free (data);
266
 
                  }
267
 
 
268
 
                  return 0;
269
 
          }
270
 
 
271
176
        create_default_shell ();
272
177
 
273
 
        g_signal_connect (
274
 
                UNIQUE_APP(app), "message-received",
275
 
                G_CALLBACK (mail_message_received_cb),  main_window);
276
 
 
277
 
        if (windowed)
278
 
                anjal_icon_decoration = TRUE;
279
 
 
280
178
        gtk_main ();
281
179
 
282
180
        return 0;