diff --git a/gnome/po/POTFILES.in b/gnome/po/POTFILES.in index 9021ba313387c0396899ee3e1b9c31a2b9be9af0..03dca86d03b73641beedc0bdeb835d070be035bc 100644 --- a/gnome/po/POTFILES.in +++ b/gnome/po/POTFILES.in @@ -19,6 +19,8 @@ src/contacts/searchbar.c src/dbus/dbus.c src/main.c src/mainwindow.c +src/sflphone_client.c +src/sflphone_options.c src/sflnotify.c src/sliders.c src/statusicon.c diff --git a/gnome/src/Makefile.am b/gnome/src/Makefile.am index d4692d0a102944fe9d90699036dfc3df431a1ed2..3c604d4ca3ffa8b8925016e5adaf5c86298919ba 100644 --- a/gnome/src/Makefile.am +++ b/gnome/src/Makefile.am @@ -50,8 +50,9 @@ libsflphone_client_la_SOURCES = \ history_loader.c \ history_loader.h \ sflphone_client.h \ - sflphone_client.c - + sflphone_client.c \ + sflphone_options.c \ + sflphone_options.h libsflphone_client_la_LIBADD = @CLUTTER_LIBS@ @CLUTTERGTK_LIBS@ $(SFLPHONE_LIBS) libsflphone_client_la_LDFLAGS = @CLUTTER_LDFLAGS@ @DBUSGLIB_LIBS@ @LIBNOTIFY_LIBS@ \ diff --git a/gnome/src/main.c b/gnome/src/main.c index d85ea9225dfe8b8ccb38ed5ff7618a65b88def0d..740ca25616f41415748a94638af25141576b2d5f 100644 --- a/gnome/src/main.c +++ b/gnome/src/main.c @@ -33,14 +33,13 @@ #include "calllist.h" #include "config.h" #include "dbus/dbus.h" +#include "shortcuts.h" #include "statusicon.h" #include <glib/gi18n.h> #include <gtk/gtk.h> #include <stdlib.h> -#include "mainwindow.h" #include "sflphone_client.h" -#include "shortcuts.h" #include "history.h" static volatile sig_atomic_t interrupted; @@ -94,22 +93,6 @@ main(int argc, char *argv[]) // Start GTK application gtk_init(&argc, &argv); - - g_print("%s %s\n", PACKAGE_NAME, PACKAGE_VERSION); - g_print("\nCopyright (c) 2005 - 2012 Savoir-faire Linux Inc.\n\n"); - g_print("This is free software. You may redistribute copies of it under the terms of\n" \ - "the GNU General Public License Version 3 <http://www.gnu.org/licenses/gpl.html>.\n" \ - "There is NO WARRANTY, to the extent permitted by law.\n\n" \ - "Additional permission under GNU GPL version 3 section 7:\n\n" \ - "If you modify this program, or any covered work, by linking or\n" \ - "combining it with the OpenSSL project's OpenSSL library (or a\n" \ - "modified version of that library), containing parts covered by the\n" \ - "terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.\n" \ - "grants you additional permission to convey the resulting work.\n" \ - "Corresponding Source for a non-source form of such a combination\n" \ - "shall include the source code for the parts of OpenSSL used as well\n" \ - "as that of the covered work.\n\n"); - srand(time(NULL)); // Internationalization @@ -128,42 +111,6 @@ main(int argc, char *argv[]) g_timeout_add(1000, check_interrupted, client); - GError *error = NULL; - if (!sflphone_init(&error, client)) { - g_warning("%s", error->message); - GtkWidget *dialog = gtk_message_dialog_new( - NULL, - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, - "Unable to initialize.\nMake sure the daemon is running.\nError: %s", - error->message); - - gtk_window_set_title(GTK_WINDOW(dialog), _("SFLphone Error")); - gtk_dialog_run(GTK_DIALOG(dialog)); - gtk_widget_destroy(dialog); - - g_error_free(error); - return 1; - } - - create_main_window(client); - gtk_application_add_window(GTK_APPLICATION(client), GTK_WINDOW(client->win)); - - const gboolean show_status = g_settings_get_boolean(client->settings, "show-status-icon"); - if (show_status) - show_status_icon(client); - - status_bar_display_account(); - - sflphone_fill_history_lazy(); - sflphone_fill_conference_list(client); - sflphone_fill_call_list(); - - // Update the GUI - update_actions(client); - - shortcuts_initialize_bindings(client); - gint status = g_application_run(G_APPLICATION(client), argc, argv); codecs_unload(); diff --git a/gnome/src/sflphone_client.c b/gnome/src/sflphone_client.c index 6aa59079992c0dd2c8d2eebd6e3bb6d3b6f6e2f6..94938cc5789385e1a8344a46de638703893f1feb 100644 --- a/gnome/src/sflphone_client.c +++ b/gnome/src/sflphone_client.c @@ -28,22 +28,72 @@ * as that of the covered work. */ +#include <glib/gi18n.h> #include "sflphone_client.h" +#include "sflphone_options.h" +#include "actions.h" +#include "statusicon.h" +#include "shortcuts.h" +#include "mainwindow.h" G_DEFINE_TYPE(SFLPhoneClient, sflphone_client, GTK_TYPE_APPLICATION); static int sflphone_client_command_line_handler(G_GNUC_UNUSED GApplication *application, - GApplicationCommandLine *cmdline) + GApplicationCommandLine *cmdline, + SFLPhoneClient *client) { - // FIXME: replace with GLib logging gint argc; gchar **argv = g_application_command_line_get_arguments(cmdline, &argc); - for (gint i = 0; i < argc; i++) - if (g_strcmp0(argv[i], "--debug") == 0) {} - ;//set_log_level(LOG_DEBUG); + GOptionContext *context = sflphone_options_get_context(); + g_option_context_set_help_enabled(context, TRUE); + GError *error = NULL; + if (g_option_context_parse(context, &argc, &argv, &error) == FALSE) { + g_print (_("%s\nRun '%s --help' to see a full list of available command line options.\n"), + error->message, argv[0]); + g_error_free(error); + g_option_context_free(context); + return 1; + } - g_strfreev (argv); + g_option_context_free(context); + + if (!sflphone_init(&error, client)) { + g_warning("%s", error->message); + GtkWidget *dialog = gtk_message_dialog_new( + NULL, + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, + "Unable to initialize.\nMake sure the daemon is running.\nError: %s", + error->message); + + gtk_window_set_title(GTK_WINDOW(dialog), _("SFLphone Error")); + gtk_dialog_run(GTK_DIALOG(dialog)); + gtk_widget_destroy(dialog); + + g_error_free(error); + return 1; + } + + create_main_window(client); + gtk_application_add_window(GTK_APPLICATION(client), GTK_WINDOW(client->win)); + + const gboolean show_status = g_settings_get_boolean(client->settings, "show-status-icon"); + if (show_status) + show_status_icon(client); + + status_bar_display_account(); + + sflphone_fill_history_lazy(); + sflphone_fill_conference_list(client); + sflphone_fill_call_list(); + + // Update the GUI + update_actions(client); + + shortcuts_initialize_bindings(client); + + g_strfreev(argv); return 0; } @@ -61,6 +111,7 @@ sflphone_client_init(SFLPhoneClient *self) { self->settings = g_settings_new(SFLPHONE_GSETTINGS_SCHEMA); self->win = 0; + g_signal_connect(G_OBJECT(self), "command-line", G_CALLBACK(sflphone_client_command_line_handler), self); } static void @@ -93,11 +144,9 @@ sflphone_client_finalize(GObject *object) static void sflphone_client_class_init(SFLPhoneClientClass *klass) { - GApplicationClass *application_class = G_APPLICATION_CLASS(klass); GObjectClass *object_class = (GObjectClass *) klass; object_class->dispose = sflphone_client_dispose; object_class->finalize = sflphone_client_finalize; - application_class->command_line = sflphone_client_command_line_handler; /* TODO: add properties, signals, and signal handlers */ } diff --git a/gnome/src/shortcuts.c b/gnome/src/shortcuts.c index 24fad5c6744896f54fda25aa2e0abfbf4e542970..5284a76af4de13022ad40b7d9af5ca2e4bdb1ad9 100644 --- a/gnome/src/shortcuts.c +++ b/gnome/src/shortcuts.c @@ -199,6 +199,9 @@ get_action_callback(const gchar* action) static void remove_bindings() { + if (!accelerators_list) + return; + GdkDisplay *display = NULL; GdkScreen *screen = NULL; GdkWindow *root = NULL; @@ -446,6 +449,8 @@ void shortcuts_destroy_bindings() { int i = 0; + if (!accelerators_list) + return; // remove bindings remove_bindings();