Commit dc5d6d5e authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #19682: gnome: created sflphone_client GObject

For now it just manages the GSettings instance.
parent 71c52b1c
......@@ -51,7 +51,9 @@ libsflphone_client_la_SOURCES = \
seekslider.h \
account_schema.h \
history_loader.c \
history_loader.h
history_loader.h \
sflphone_client.h \
sflphone_client.c
libsflphone_client_la_LIBADD = @CLUTTER_LIBS@ @CLUTTERGTK_LIBS@ $(SFLPHONE_LIBS)
......
......@@ -39,6 +39,7 @@
#include <gtk/gtk.h>
#include <stdlib.h>
#include "sflphone_client.h"
#include "shortcuts.h"
#include "history.h"
......@@ -82,9 +83,6 @@ main(int argc, char *argv[])
// Start GTK application
gtk_init(&argc, &argv);
/* Tell glib to look for our schema in gnome/data in case SFLphone is not installed */
update_schema_dir(argv[0]);
// Check arguments if debug mode is activated
for (int i = 0; i < argc; i++)
if (g_strcmp0(argv[i], "--debug") == 0)
......@@ -111,9 +109,11 @@ main(int argc, char *argv[])
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
g_set_application_name("SFLphone");
SFLPhoneClient *client = sflphone_client_new();
GError *error = NULL;
GSettings *settings = g_settings_new("org.sflphone.SFLphone");
if (!sflphone_init(&error, settings)) {
if (!sflphone_init(&error, client->settings)) {
ERROR("%s", error->message);
GtkWidget *dialog = gtk_message_dialog_new(
GTK_WINDOW(get_main_window()),
......@@ -130,29 +130,29 @@ main(int argc, char *argv[])
return 1;
}
const gboolean show_status = g_settings_get_boolean(settings, "show-status-icon");
const gboolean show_status = g_settings_get_boolean(client->settings, "show-status-icon");
if (show_status)
show_status_icon(settings);
show_status_icon(client->settings);
create_main_window(settings);
gtk_application_add_window(GTK_APPLICATION(client), GTK_WINDOW(create_main_window(client->settings)));
status_bar_display_account();
sflphone_fill_history_lazy();
sflphone_fill_conference_list(settings);
sflphone_fill_conference_list(client->settings);
sflphone_fill_call_list();
// Update the GUI
update_actions(settings);
update_actions(client->settings);
shortcuts_initialize_bindings(settings);
shortcuts_initialize_bindings(client->settings);
gtk_main();
g_application_run(G_APPLICATION(client), argc, argv);
codecs_unload();
shortcuts_destroy_bindings();
g_object_unref(settings);
g_object_unref(client);
return 0;
}
......
......@@ -213,7 +213,7 @@ static void pack_main_window_start(GtkBox *box, GtkWidget *widget, gboolean expa
gtk_box_pack_start(box, alignment, expand, fill, padding);
}
void
GtkWidget *
create_main_window(GSettings *settings)
{
// Get configuration stored in GSettings
......@@ -364,6 +364,7 @@ create_main_window(GSettings *settings)
// Restore position according to the configuration stored in gconf
gtk_window_move(GTK_WINDOW(window), position_x, position_y);
return window;
}
GtkAccelGroup *
......
......@@ -54,7 +54,8 @@ GtkWidget *waitingLayer;
/**
* Build the main window
*/
void create_main_window (GSettings *settings);
GtkWidget *
create_main_window (GSettings *settings);
/**
* Display a dialog window
......
/*
* Copyright (C) 2012 Savoir-Faire Linux Inc.
* Author: Tristan Matthews <tristan.matthews@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#include "sflphone_client.h"
// FIXME: replace with GLib logging
#include "logger.h"
G_DEFINE_TYPE(SFLPhoneClient, sflphone_client, GTK_TYPE_APPLICATION);
static int
sflphone_client_command_line_handler(G_GNUC_UNUSED GApplication *application,
GApplicationCommandLine *cmdline)
{
// 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);
g_strfreev (argv);
return 0;
}
SFLPhoneClient *
sflphone_client_new()
{
SFLPhoneClient *client = g_object_new(sflphone_client_get_type(),
"application-id", "org.sfl.SFLphone",
"flags", G_APPLICATION_HANDLES_COMMAND_LINE, NULL);
return client;
}
static void
sflphone_client_init(SFLPhoneClient *self)
{
self->settings = g_settings_new(SFLPHONE_GSETTINGS_SCHEMA);
}
static void
sflphone_client_dispose(GObject *object)
{
SFLPhoneClient *self = SFLPHONE_CLIENT(object);
/*
* Unref all members to which self owns a reference.
*/
/* dispose might be called multiple times, so we must guard against
* calling g_object_unref() on an invalid GObject.
*/
if (self->settings) {
g_object_unref(self->settings);
self->settings = NULL;
}
/* Chain up to the parent class */
G_OBJECT_CLASS (sflphone_client_parent_class)->dispose(object);
}
static void
sflphone_client_finalize(GObject *object)
{
SFLPhoneClient *self = SFLPHONE_CLIENT(object);
g_object_unref(self->settings);
/* Chain up to the parent class */
G_OBJECT_CLASS(sflphone_client_parent_class)->finalize(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 */
}
/*
* Copyright (C) 2012 Savoir-Faire Linux Inc.
* Author: Tristan Matthews <tristan.matthews@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#ifndef SFLPHONE_CLIENT_H_
#define SFLPHONE_CLIENT_H_
#include <gtk/gtk.h>
#define SFLPHONE_GSETTINGS_SCHEMA "org.sflphone.SFLphone"
#define SFLPHONE_TYPE_CLIENT (sflphone_client_get_type())
#define SFLPHONE_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SFLPHONE_TYPE_CLIENT, SFLPhoneClient))
typedef struct
{
GtkApplication parent;
GSettings *settings;
} SFLPhoneClient;
typedef GtkApplicationClass SFLPhoneClientClass;
SFLPhoneClient *
sflphone_client_new();
#endif
Supports Markdown
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