[vino/3] radio buttons are working
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vino/3] radio buttons are working
- Date: Mon, 5 Jul 2010 18:57:12 +0000 (UTC)
commit bb9bad2961545c3be6b625f76c4b46dba458a2a4
Author: Ryan Lortie <desrt desrt ca>
Date: Mon Jul 5 14:41:48 2010 -0400
radio buttons are working
capplet/vino-connectivity-info.h | 21 +++++
capplet/vino-preferences.c | 8 ++
capplet/vino-preferences.ui | 9 ++-
capplet/vino-radio-button.c | 172 ++++++++++++++++++++++++++++++++++++++
capplet/vino-radio-button.h | 29 +++++++
5 files changed, 236 insertions(+), 3 deletions(-)
---
diff --git a/capplet/vino-connectivity-info.h b/capplet/vino-connectivity-info.h
index c37698a..ae39fd2 100644
--- a/capplet/vino-connectivity-info.h
+++ b/capplet/vino-connectivity-info.h
@@ -1,3 +1,24 @@
+/*
+ * Copyright © 2010 Codethink Limited
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * Author: Ryan Lortie <desrt desrt ca>
+ */
+
#include <glib.h>
typedef struct _VinoConnectivityInfo VinoConnectivityInfo;
diff --git a/capplet/vino-preferences.c b/capplet/vino-preferences.c
index ff49ff4..d62e788 100644
--- a/capplet/vino-preferences.c
+++ b/capplet/vino-preferences.c
@@ -27,6 +27,7 @@
#include "config.h"
#include "vino-connectivity-info.h"
+#include "vino-radio-button.h"
#include "vino-message-box.h"
#include "vino-keyring.h"
@@ -265,6 +266,8 @@ vino_preferences_create_window (GtkApplication *gtk_app)
const char *ui_file;
gpointer window;
+ vino_radio_button_get_type ();
+
#define VINO_UI_FILE "vino-preferences.ui"
if (g_file_test (VINO_UI_FILE, G_FILE_TEST_EXISTS))
ui_file = VINO_UI_FILE;
@@ -310,6 +313,11 @@ vino_preferences_create_window (GtkApplication *gtk_app)
"text", 0,
get_password, set_password, NULL, NULL);
+ g_settings_bind (settings, "icon-visibility",
+ gtk_builder_get_object (builder, "icon_always_radio"),
+ "settings-active", 0);
+
+
window = gtk_builder_get_object (builder, "vino_dialog");
g_signal_connect (window, "response",
G_CALLBACK (vino_preferences_dialog_response), NULL);
diff --git a/capplet/vino-preferences.ui b/capplet/vino-preferences.ui
index a16b56b..a01f697 100644
--- a/capplet/vino-preferences.ui
+++ b/capplet/vino-preferences.ui
@@ -317,7 +317,8 @@
<property name="visible">True</property>
<property name="spacing">3</property>
<child>
- <object class="GtkRadioButton" id="icon_always_radio">
+ <object class="VinoRadioButton" id="icon_always_radio">
+ <property name='settings-name'>always</property>
<property name="label" translatable="yes">Al_ways display an icon</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -331,7 +332,8 @@
</packing>
</child>
<child>
- <object class="GtkRadioButton" id="icon_client_radio">
+ <object class="VinoRadioButton" id="icon_client_radio">
+ <property name='settings-name'>client</property>
<property name="label" translatable="yes">_Only display an icon when there is someone connected</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -346,7 +348,8 @@
</packing>
</child>
<child>
- <object class="GtkRadioButton" id="icon_never_radio">
+ <object class="VinoRadioButton" id="icon_never_radio">
+ <property name='settings-name'>never</property>
<property name="label" translatable="yes">_Never display an icon</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
diff --git a/capplet/vino-radio-button.c b/capplet/vino-radio-button.c
new file mode 100644
index 0000000..8127a1d
--- /dev/null
+++ b/capplet/vino-radio-button.c
@@ -0,0 +1,172 @@
+/*
+ * Copyright © 2010 Codethink Limited
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * Author: Ryan Lortie <desrt desrt ca>
+ */
+
+#include "vino-radio-button.h"
+
+#include <gtk/gtk.h>
+
+typedef struct
+{
+ GtkRadioButton parent_instance;
+ gchar *name;
+} VinoRadioButton;
+
+typedef GtkRadioButtonClass VinoRadioButtonClass;
+
+G_DEFINE_TYPE (VinoRadioButton, vino_radio_button, GTK_TYPE_RADIO_BUTTON)
+
+enum
+{
+ PROP_0,
+ PROP_SETTINGS_NAME,
+ PROP_SETTINGS_ACTIVE
+};
+
+static void
+vino_radio_button_get_property (GObject *object, guint prop_id,
+ GValue *value, GParamSpec *pspec)
+{
+ VinoRadioButton *vrb = (VinoRadioButton *) object;
+
+ switch (prop_id)
+ {
+ case PROP_SETTINGS_ACTIVE:
+ {
+ const GSList *list;
+
+ list = gtk_radio_button_get_group (&vrb->parent_instance);
+ while (list)
+ {
+ VinoRadioButton *this = list->data;
+
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (this)))
+ {
+ g_value_set_string (value, this->name);
+ return;
+ }
+
+ list = list->next;
+ }
+ }
+
+ g_warning ("No active radio buttons");
+ g_value_set_string (value, "");
+ return;
+
+ default:
+ g_assert_not_reached ();
+ }
+}
+
+static void
+vino_radio_button_set_property (GObject *object, guint prop_id,
+ const GValue *value, GParamSpec *pspec)
+{
+ VinoRadioButton *vrb = (VinoRadioButton *) object;
+
+ switch (prop_id)
+ {
+ case PROP_SETTINGS_NAME:
+ g_assert (vrb->name == NULL);
+ vrb->name = g_value_dup_string (value);
+ return;
+
+ case PROP_SETTINGS_ACTIVE:
+ {
+ const GSList *list;
+ const gchar *name;
+
+ list = gtk_radio_button_get_group (&vrb->parent_instance);
+ name = g_value_get_string (value);
+
+ while (list)
+ {
+ VinoRadioButton *this = list->data;
+
+ if (g_strcmp0 (this->name, name))
+ {
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (this),
+ TRUE);
+ return;
+ }
+
+ list = list->next;
+ }
+
+ g_warning ("No such radio button named `%s'", name);
+ }
+ return;
+
+ default:
+ g_assert_not_reached ();
+ }
+}
+
+static void
+vino_radio_button_toggled (GtkToggleButton *button)
+{
+ VinoRadioButton *vrb = (VinoRadioButton *) button;
+ const GSList *list;
+
+ list = gtk_radio_button_get_group (&vrb->parent_instance);
+ while (list)
+ {
+ g_object_notify (list->data, "settings-active");
+ list = list->next;
+ }
+}
+
+static void
+vino_radio_button_finalize (GObject *object)
+{
+ VinoRadioButton *vrb = (VinoRadioButton *) object;
+
+ g_free (vrb->name);
+
+ G_OBJECT_CLASS (vino_radio_button_parent_class)
+ ->finalize (object);
+}
+
+static void
+vino_radio_button_init (VinoRadioButton *button)
+{
+}
+
+static void
+vino_radio_button_class_init (GtkRadioButtonClass *class)
+{
+ GtkToggleButtonClass *tb_class = GTK_TOGGLE_BUTTON_CLASS (class);
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+ tb_class->toggled = vino_radio_button_toggled;
+ object_class->get_property = vino_radio_button_get_property;
+ object_class->set_property = vino_radio_button_set_property;
+ object_class->finalize = vino_radio_button_finalize;
+
+ g_object_class_install_property (object_class, PROP_SETTINGS_NAME,
+ g_param_spec_string ("settings-name", "name", "name", NULL,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (object_class, PROP_SETTINGS_ACTIVE,
+ g_param_spec_string ("settings-active", "active", "active", NULL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+}
diff --git a/capplet/vino-radio-button.h b/capplet/vino-radio-button.h
new file mode 100644
index 0000000..cf1c18e
--- /dev/null
+++ b/capplet/vino-radio-button.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright © 2010 Codethink Limited
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * Author: Ryan Lortie <desrt desrt ca>
+ */
+
+#ifndef __vino_radio_button_h__
+#define __vino_radio_button_h__
+
+#include <glib-object.h>
+
+GType vino_radio_button_get_type (void);
+
+#endif /* __vino_radio_button_h__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]