Commit 659200d1 authored by Tristan Matthews's avatar Tristan Matthews

* #19683: gnome: use GOption entry for command line parsing

parent 56240878
......@@ -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
......
......@@ -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@ \
......
......@@ -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();
......
......@@ -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 */
}
......@@ -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();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment