[ekiga/ds-gsettings3: 13/33] GSettings: Converted GmWindow objects to use GSettings.
- From: Damien Sandras <dsandras src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ekiga/ds-gsettings3: 13/33] GSettings: Converted GmWindow objects to use GSettings.
- Date: Sat, 5 Oct 2013 12:15:14 +0000 (UTC)
commit 66415117259ed4d2686bfa65d835ed8b9c8436bd
Author: Damien Sandras <dsandras beip be>
Date: Sun Apr 7 17:48:08 2013 +0200
GSettings: Converted GmWindow objects to use GSettings.
lib/ekiga-settings.h | 44 +++++++++++++++
lib/engine/gui/gtk-frontend/call-window.cpp | 77 ++++++++------------------
lib/engine/gui/gtk-frontend/gtk-frontend.cpp | 13 ++---
lib/engine/gui/gtk-frontend/main_window.cpp | 4 +-
lib/gui/gmwindow.c | 46 ++++++----------
5 files changed, 93 insertions(+), 91 deletions(-)
---
diff --git a/lib/ekiga-settings.h b/lib/ekiga-settings.h
new file mode 100644
index 0000000..c465d6e
--- /dev/null
+++ b/lib/ekiga-settings.h
@@ -0,0 +1,44 @@
+
+/* Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2013 Damien Sandras <dsandras seconix 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 2 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 St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Ekiga is licensed under the GPL license and as a special exception,
+ * you have permission to link or otherwise combine this program with the
+ * programs OPAL, OpenH323 and PWLIB, and distribute the combination,
+ * without applying the requirements of the GNU GPL to the OPAL, OpenH323
+ * and PWLIB programs, as long as you do follow the requirements of the
+ * GNU GPL for all the rest of the software thus combined.
+ */
+
+
+/*
+ * ekiga-ettings.h - description
+ * -------------------------------
+ * begin : Sat Dec 23 2000
+ * copyright : (C) 2000-2013 by Damien Sandras
+ * description : This file defines gsettings keys
+ *
+ */
+
+
+#ifndef EKIGA_SETTINGS_H_
+#define EKIGA_SETTINGS_H_
+
+#define USER_INTERFACE "org.gnome." PACKAGE_NAME ".general.user-interface"
+
+#endif /* EKIGA_SETTINGS_H */
diff --git a/lib/engine/gui/gtk-frontend/call-window.cpp b/lib/engine/gui/gtk-frontend/call-window.cpp
index b070d7b..fd3f65a 100644
--- a/lib/engine/gui/gtk-frontend/call-window.cpp
+++ b/lib/engine/gui/gtk-frontend/call-window.cpp
@@ -38,6 +38,10 @@
#include <glib/gi18n.h>
#include <gdk/gdkkeysyms.h>
+#include "config.h"
+
+#include "ekiga-settings.h"
+
#include "call-window.h"
#include "dialpad.h"
@@ -210,9 +214,6 @@ static void pick_up_call_cb (GtkWidget * /*widget*/,
static void hang_up_call_cb (GtkWidget * /*widget*/,
gpointer data);
-static void show_window_cb (GtkWidget *widget,
- gpointer data);
-
static void hold_current_call_cb (GtkWidget *widget,
gpointer data);
@@ -594,13 +595,6 @@ hang_up_call_cb (GtkWidget * /*widget*/,
static void
-show_window_cb (G_GNUC_UNUSED GtkWidget *widget,
- gpointer data)
-{
- gm_window_show (GTK_WIDGET (data));
-}
-
-static void
hold_current_call_cb (G_GNUC_UNUSED GtkWidget *widget,
gpointer data)
{
@@ -1731,15 +1725,8 @@ gm_cw_video_settings_window_new (EkigaCallWindow *cw)
int brightness = 0, colour = 0, contrast = 0, whiteness = 0;
/* Build the window */
- window = gtk_dialog_new ();
- g_object_set_data_full (G_OBJECT (window), "window_name",
- g_strdup ("video_settings_window"), g_free);
- gtk_dialog_add_button (GTK_DIALOG (window),
- GTK_STOCK_CLOSE,
- GTK_RESPONSE_CANCEL);
-
- gtk_window_set_title (GTK_WINDOW (window),
- _("Video Settings"));
+ window = gm_window_new_with_key (USER_INTERFACE ".video-settings-window");
+ gtk_window_set_title (GTK_WINDOW (window), _("Video Settings"));
/* Webcam Control Frame, we need it to disable controls */
cw->priv->video_settings_frame = gtk_frame_new (NULL);
@@ -1831,18 +1818,12 @@ gm_cw_video_settings_window_new (EkigaCallWindow *cw)
G_CALLBACK (video_settings_changed_cb),
(gpointer) cw);
- gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (window))),
+ gtk_container_add (GTK_CONTAINER (window),
cw->priv->video_settings_frame);
gtk_widget_show_all (cw->priv->video_settings_frame);
gtk_widget_set_sensitive (GTK_WIDGET (cw->priv->video_settings_frame), false);
- /* That's an usual GtkWindow, connect it to the signals */
- g_signal_connect_swapped (window,
- "response",
- G_CALLBACK (gm_window_hide),
- (gpointer) window);
-
gm_window_hide_on_delete (window);
return window;
@@ -1854,27 +1835,21 @@ gm_cw_audio_settings_window_new (EkigaCallWindow *cw)
GtkWidget *hscale_play = NULL;
GtkWidget *hscale_rec = NULL;
GtkWidget *hbox = NULL;
+ GtkWidget *main_vbox = NULL;
GtkWidget *vbox = NULL;
GtkWidget *small_vbox = NULL;
GtkWidget *window = NULL;
/* Build the window */
- window = gtk_dialog_new ();
- g_object_set_data_full (G_OBJECT (window), "window_name",
- g_strdup ("audio_settings_window"), g_free);
- gtk_dialog_add_button (GTK_DIALOG (window),
- GTK_STOCK_CLOSE,
- GTK_RESPONSE_CANCEL);
-
- gtk_window_set_title (GTK_WINDOW (window),
- _("Audio Settings"));
+ window = gm_window_new_with_key (USER_INTERFACE ".audio-settings-window");
+ gtk_window_set_title (GTK_WINDOW (window), _("Audio Settings"));
/* Audio control frame, we need it to disable controls */
cw->priv->audio_output_volume_frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (cw->priv->audio_output_volume_frame),
GTK_SHADOW_NONE);
gtk_container_set_border_width (GTK_CONTAINER (cw->priv->audio_output_volume_frame), 5);
-
+ main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
/* The vbox */
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
@@ -1899,8 +1874,8 @@ gm_cw_audio_settings_window_new (EkigaCallWindow *cw)
gtk_box_pack_start (GTK_BOX (hbox), small_vbox, true, true, 2);
gtk_box_pack_start (GTK_BOX (vbox), hbox, false, false, 3);
- gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (window))),
- cw->priv->audio_output_volume_frame);
+ gtk_box_pack_start (GTK_BOX (main_vbox), cw->priv->audio_output_volume_frame,
+ false, false, 0);
gtk_widget_show_all (cw->priv->audio_output_volume_frame);
gtk_widget_set_sensitive (GTK_WIDGET (cw->priv->audio_output_volume_frame), false);
@@ -1934,23 +1909,19 @@ gm_cw_audio_settings_window_new (EkigaCallWindow *cw)
gtk_box_pack_start (GTK_BOX (hbox), small_vbox, true, true, 2);
gtk_box_pack_start (GTK_BOX (vbox), hbox, false, false, 3);
- gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (window))),
- cw->priv->audio_input_volume_frame);
+ gtk_box_pack_start (GTK_BOX (main_vbox), cw->priv->audio_input_volume_frame,
+ false, false, 0);
gtk_widget_show_all (cw->priv->audio_input_volume_frame);
gtk_widget_set_sensitive (GTK_WIDGET (cw->priv->audio_input_volume_frame), false);
+ gtk_container_add (GTK_CONTAINER (window), main_vbox);
+
g_signal_connect (cw->priv->adj_output_volume, "value-changed",
G_CALLBACK (audio_volume_changed_cb), cw);
g_signal_connect (cw->priv->adj_input_volume, "value-changed",
G_CALLBACK (audio_volume_changed_cb), cw);
- /* That's an usual GtkWindow, connect it to the signals */
- g_signal_connect_swapped (window,
- "response",
- G_CALLBACK (gm_window_hide),
- (gpointer) window);
-
gm_window_hide_on_delete (window);
g_signal_connect (window, "show",
@@ -2426,9 +2397,9 @@ ekiga_call_window_init_gui (EkigaCallWindow *cw)
GTK_TOOL_ITEM (item), -1);
gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (item),
_("Change the volume of your soundcard"));
- g_signal_connect (cw->priv->audio_settings_button, "clicked",
- G_CALLBACK (show_window_cb),
- (gpointer) cw->priv->audio_settings_window);
+ g_signal_connect_swapped (cw->priv->audio_settings_button, "clicked",
+ G_CALLBACK (gtk_widget_show),
+ (gpointer) cw->priv->audio_settings_window);
}
/* Video Settings */
@@ -2447,9 +2418,9 @@ ekiga_call_window_init_gui (EkigaCallWindow *cw)
gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (item),
_("Change the color settings of your video device"));
- g_signal_connect (cw->priv->video_settings_button, "clicked",
- G_CALLBACK (show_window_cb),
- (gpointer) cw->priv->video_settings_window);
+ g_signal_connect_swapped (cw->priv->video_settings_button, "clicked",
+ G_CALLBACK (gtk_widget_show),
+ (gpointer) cw->priv->video_settings_window);
/* Call Pause */
item = gtk_tool_item_new ();
@@ -2640,7 +2611,7 @@ call_window_new (Ekiga::ServiceCore & core)
gm_conf_notifier_add (VIDEO_DISPLAY_KEY "stay_on_top",
stay_on_top_changed_nt, cw);
- gm_window_set_key (GM_WINDOW (cw), USER_INTERFACE_KEY "call_window");
+ gm_window_set_key (GM_WINDOW (cw), USER_INTERFACE ".call-window");
gm_window_set_hide_on_delete (GM_WINDOW (cw), false);
gm_window_set_hide_on_escape (GM_WINDOW (cw), false);
diff --git a/lib/engine/gui/gtk-frontend/gtk-frontend.cpp b/lib/engine/gui/gtk-frontend/gtk-frontend.cpp
index 559a169..dbdf67d 100644
--- a/lib/engine/gui/gtk-frontend/gtk-frontend.cpp
+++ b/lib/engine/gui/gtk-frontend/gtk-frontend.cpp
@@ -39,6 +39,7 @@
#include <gtk/gtk.h>
#include "config.h"
+#include "ekiga-settings.h"
#include "trigger.h"
#include "gtk-frontend.h"
@@ -153,14 +154,11 @@ GtkFrontend::build ()
gtk_window_set_default_icon_name (GM_ICON_LOGO);
addressbook_window =
- boost::shared_ptr<GtkWidget>(addressbook_window_new (contact_core), gtk_widget_destroy);
- gm_window_set_key (GM_WINDOW (addressbook_window.get ()),
- "/apps/" PACKAGE_NAME "/general/user_interface/addressbook_window");
+<<<<<<< HEAD
+ boost::shared_ptr<GtkWidget>(addressbook_window_new_with_key (contact_core, USER_INTERFACE
".addressbook-window"), gtk_widget_destroy);
accounts_window =
- boost::shared_ptr<GtkWidget> (accounts_window_new (account_core, details), gtk_widget_destroy);
- gm_window_set_key(GM_WINDOW (accounts_window.get ()),
- "/apps/" PACKAGE_NAME "/general/user_interface/accounts_window");
+ boost::shared_ptr<GtkWidget> (accounts_window_new_with_key (account_core, USER_INTERFACE
".accounts-window", details), gtk_widget_destroy);
// BEWARE: uses the main window during runtime
assistant_window =
@@ -170,8 +168,7 @@ GtkFrontend::build ()
boost::shared_ptr<GtkWidget> (call_window_new (core), gtk_widget_destroy);
chat_window =
- boost::shared_ptr<GtkWidget> (chat_window_new (core), gtk_widget_destroy);
- gm_window_set_key(GM_WINDOW(chat_window.get ()), "/apps/" PACKAGE_NAME
"/general/user_interface/chat_window");
+ boost::shared_ptr<GtkWidget> (chat_window_new (core, USER_INTERFACE ".chat-window"), gtk_widget_destroy);
preferences_window =
boost::shared_ptr<GtkWidget> (preferences_window_new (core), gtk_widget_destroy);
diff --git a/lib/engine/gui/gtk-frontend/main_window.cpp b/lib/engine/gui/gtk-frontend/main_window.cpp
index 163fa62..d0c6343 100644
--- a/lib/engine/gui/gtk-frontend/main_window.cpp
+++ b/lib/engine/gui/gtk-frontend/main_window.cpp
@@ -37,6 +37,8 @@
#include "config.h"
+#include "ekiga-settings.h"
+
#include "main_window.h"
#include "dialpad.h"
@@ -1566,7 +1568,7 @@ gm_main_window_new (Ekiga::ServiceCore & core)
/* basic gtk+ setup */
mw = EKIGA_MAIN_WINDOW (g_object_new (EKIGA_TYPE_MAIN_WINDOW, NULL));
- gm_window_set_key (GM_WINDOW (mw), USER_INTERFACE_KEY "main_window");
+ gm_window_set_key (GM_WINDOW (mw), USER_INTERFACE ".main-window");
/* fetching needed engine objects */
diff --git a/lib/gui/gmwindow.c b/lib/gui/gmwindow.c
index 3aef798..ec08049 100644
--- a/lib/gui/gmwindow.c
+++ b/lib/gui/gmwindow.c
@@ -37,7 +37,6 @@
*/
#include "gmwindow.h"
-
#include "gmconf.h"
#include <gdk/gdkkeysyms.h>
@@ -49,6 +48,7 @@
struct _GmWindowPrivate
{
GtkAccelGroup *accel;
+ GSettings *settings;
gboolean hide_on_esc;
gboolean hide_on_delete;
gchar *key;
@@ -90,12 +90,16 @@ gm_window_configure_event (GtkWidget *widget,
static void
gm_window_finalize (GObject *obj)
{
- GmWindow *window = NULL;
+ GmWindow *self = NULL;
- window = GM_WINDOW (obj);
+ self = GM_WINDOW (obj);
- g_free (window->priv->key);
- window->priv->key = NULL;
+ g_free (self->priv->key);
+ self->priv->key = NULL;
+
+ if (self->priv->settings)
+ g_clear_object (&self->priv->settings);
+ self->priv->settings = NULL;
G_OBJECT_CLASS (gm_window_parent_class)->finalize (obj);
}
@@ -152,6 +156,9 @@ gm_window_set_property (GObject *obj,
g_free (self->priv->key);
str = g_value_get_string (value);
self->priv->key = g_strdup (str ? str : "");
+ if (self->priv->settings)
+ g_clear_object (&self->priv->settings);
+ self->priv->settings = g_settings_new (self->priv->key);
break;
case GM_HIDE_ON_ESC:
@@ -204,6 +211,7 @@ static void
gm_window_init (GmWindow* self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GM_TYPE_WINDOW, GmWindowPrivate);
+ self->priv->settings = NULL;
self->priv->key = g_strdup ("");
self->priv->hide_on_esc = TRUE;
self->priv->hide_on_delete = TRUE;
@@ -266,8 +274,6 @@ window_show_cb (GtkWidget *w,
GmWindow *self = NULL;
- gchar *conf_key_size = NULL;
- gchar *conf_key_position = NULL;
gchar *size = NULL;
gchar *position = NULL;
gchar **couple = NULL;
@@ -276,14 +282,9 @@ window_show_cb (GtkWidget *w,
g_return_if_fail (g_strcmp0 (self->priv->key, ""));
- conf_key_position =
- g_strdup_printf ("%s/position", self->priv->key);
- conf_key_size =
- g_strdup_printf ("%s/size", self->priv->key);
-
if (gtk_window_get_resizable (GTK_WINDOW (w))) {
- size = gm_conf_get_string (conf_key_size);
+ size = g_settings_get_string (self->priv->settings, "size");
if (size)
couple = g_strsplit (size, ",", 0);
@@ -300,7 +301,7 @@ window_show_cb (GtkWidget *w,
g_free (size);
}
- position = gm_conf_get_string (conf_key_position);
+ position = g_settings_get_string (self->priv->settings, "position");
if (position)
couple = g_strsplit (position, ",", 0);
@@ -317,9 +318,6 @@ window_show_cb (GtkWidget *w,
g_free (position);
gtk_widget_realize (GTK_WIDGET (w));
-
- g_free (conf_key_position);
- g_free (conf_key_size);
}
@@ -329,8 +327,6 @@ window_hide_cb (GtkWidget *w,
{
GmWindow *self = NULL;
- gchar *conf_key_size = NULL;
- gchar *conf_key_position = NULL;
gchar *size = NULL;
gchar *position = NULL;
@@ -340,24 +336,16 @@ window_hide_cb (GtkWidget *w,
g_return_if_fail (g_strcmp0 (self->priv->key, ""));
- conf_key_position =
- g_strdup_printf ("%s/position", self->priv->key);
- conf_key_size =
- g_strdup_printf ("%s/size", self->priv->key);
-
position = g_strdup_printf ("%d,%d", self->priv->x, self->priv->y);
- gm_conf_set_string (conf_key_position, position);
+ g_settings_set_string (self->priv->settings, "position", position);
g_free (position);
if (gtk_window_get_resizable (GTK_WINDOW (w))) {
size = g_strdup_printf ("%d,%d", self->priv->width, self->priv->height);
- gm_conf_set_string (conf_key_size, size);
+ g_settings_set_string (self->priv->settings, "size", size);
g_free (size);
}
-
- g_free (conf_key_position);
- g_free (conf_key_size);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]