diff options
Diffstat (limited to 'src/application.c')
-rw-r--r-- | src/application.c | 76 |
1 files changed, 70 insertions, 6 deletions
diff --git a/src/application.c b/src/application.c index d960ed9..1ae2f88 100644 --- a/src/application.c +++ b/src/application.c | |||
@@ -53,6 +53,8 @@ _application_accounts(gpointer user_data) | |||
53 | { | 53 | { |
54 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 54 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
55 | 55 | ||
56 | app->init = 0; | ||
57 | |||
56 | ui_accounts_dialog_init(app, &(app->ui.accounts)); | 58 | ui_accounts_dialog_init(app, &(app->ui.accounts)); |
57 | ui_accounts_dialog_refresh(app, &(app->ui.accounts)); | 59 | ui_accounts_dialog_refresh(app, &(app->ui.accounts)); |
58 | 60 | ||
@@ -61,17 +63,71 @@ _application_accounts(gpointer user_data) | |||
61 | } | 63 | } |
62 | 64 | ||
63 | static void | 65 | static void |
64 | _application_activate(UNUSED GtkApplication* application, | 66 | _application_init(MESSENGER_Application *app) |
65 | gpointer user_data) | ||
66 | { | 67 | { |
67 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | ||
68 | |||
69 | ui_messenger_init(app, &(app->ui.messenger)); | 68 | ui_messenger_init(app, &(app->ui.messenger)); |
70 | 69 | ||
71 | if (app->chat.identity) | 70 | if (app->chat.identity) |
72 | gtk_widget_show(GTK_WIDGET(app->ui.messenger.main_window)); | 71 | gtk_widget_show(GTK_WIDGET(app->ui.messenger.main_window)); |
73 | else | 72 | else |
74 | g_idle_add(G_SOURCE_FUNC(_application_accounts), app); | 73 | app->init = g_idle_add(G_SOURCE_FUNC(_application_accounts), app); |
74 | } | ||
75 | |||
76 | static void | ||
77 | _application_activate(GApplication* application, | ||
78 | gpointer user_data) | ||
79 | { | ||
80 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | ||
81 | |||
82 | g_application_hold(application); | ||
83 | |||
84 | _application_init(app); | ||
85 | |||
86 | g_application_release(application); | ||
87 | } | ||
88 | |||
89 | static void | ||
90 | _application_open(GApplication* application, | ||
91 | GFile **files, | ||
92 | gint n_files, | ||
93 | UNUSED gchar* hint, | ||
94 | gpointer user_data) | ||
95 | { | ||
96 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | ||
97 | |||
98 | g_application_hold(application); | ||
99 | |||
100 | _application_init(app); | ||
101 | |||
102 | for (gint i = 0; i < n_files; i++) { | ||
103 | if (!g_file_has_uri_scheme(files[i], "gnunet")) | ||
104 | continue; | ||
105 | |||
106 | gchar *uri_string = g_file_get_uri(files[i]); | ||
107 | |||
108 | if (!uri_string) | ||
109 | continue; | ||
110 | |||
111 | char *emsg = NULL; | ||
112 | struct GNUNET_CHAT_Uri *uri = GNUNET_CHAT_uri_parse(uri_string, &emsg); | ||
113 | |||
114 | if (emsg) | ||
115 | { | ||
116 | g_printerr("ERROR: %s\n", emsg); | ||
117 | GNUNET_free(emsg); | ||
118 | } | ||
119 | |||
120 | if (!uri) | ||
121 | goto free_string; | ||
122 | |||
123 | GNUNET_CHAT_lobby_join(app->chat.messenger.handle, uri); | ||
124 | GNUNET_CHAT_uri_destroy(uri); | ||
125 | |||
126 | free_string: | ||
127 | g_free(uri_string); | ||
128 | } | ||
129 | |||
130 | g_application_release(application); | ||
75 | } | 131 | } |
76 | 132 | ||
77 | void | 133 | void |
@@ -84,12 +140,13 @@ application_init(MESSENGER_Application *app, | |||
84 | app->argc = argc; | 140 | app->argc = argc; |
85 | app->argv = argv; | 141 | app->argv = argv; |
86 | 142 | ||
87 | gst_init (&argc, &argv); | 143 | gst_init(&argc, &argv); |
88 | gtk_init(&argc, &argv); | 144 | gtk_init(&argc, &argv); |
89 | hdy_init(); | 145 | hdy_init(); |
90 | 146 | ||
91 | app->application = gtk_application_new( | 147 | app->application = gtk_application_new( |
92 | MESSENGER_APPLICATION_ID, | 148 | MESSENGER_APPLICATION_ID, |
149 | G_APPLICATION_HANDLES_OPEN | | ||
93 | G_APPLICATION_NON_UNIQUE | 150 | G_APPLICATION_NON_UNIQUE |
94 | ); | 151 | ); |
95 | 152 | ||
@@ -136,6 +193,13 @@ application_init(MESSENGER_Application *app, | |||
136 | G_CALLBACK(_application_activate), | 193 | G_CALLBACK(_application_activate), |
137 | app | 194 | app |
138 | ); | 195 | ); |
196 | |||
197 | g_signal_connect( | ||
198 | app->application, | ||
199 | "open", | ||
200 | G_CALLBACK(_application_open), | ||
201 | app | ||
202 | ); | ||
139 | } | 203 | } |
140 | 204 | ||
141 | const gchar* | 205 | const gchar* |