[mousetweaks] Port pointer-capture applet to GSettings and refactor
- From: Gerd Kohlberger <gerdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mousetweaks] Port pointer-capture applet to GSettings and refactor
- Date: Sun, 17 Oct 2010 17:26:05 +0000 (UTC)
commit f94c986207f088b2328ef5b6c183e0eedb43602f
Author: Gerd Kohlberger <gerdk src gnome org>
Date: Sun Oct 17 19:23:26 2010 +0200
Port pointer-capture applet to GSettings and refactor
- Reduce the number of configuration options.
- Clean up preferences dialog.
configure.ac | 18 +--
data/Makefile.am | 20 +--
data/org.gnome.pointer-capture.gschema.xml.in | 26 ++
data/pointer-capture-applet.schemas.in | 95 --------
data/pointer-capture-applet.ui | 207 ++---------------
po/POTFILES.in | 2 +-
src/pointer-capture-applet.c | 302 ++++++++-----------------
7 files changed, 144 insertions(+), 526 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index ac44a9a..967fcc6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -46,23 +46,18 @@ dnl *** dependencies ***
GLIB_REQUIRED=2.25.3
GIO_REQUIRED=2.25.9
GTK_REQUIRED=2.91.0
-GCONF_REQUIRED=2.31.1
GSD_REQUIRED=2.91.0
PKG_CHECK_MODULES(DEPENDENCIES,
glib-2.0 >= $GLIB_REQUIRED
gio-2.0 >= $GIO_REQUIRED
gtk+-3.0 >= $GTK_REQUIRED
- gconf-2.0 >= $GCONF_REQUIRED
gnome-settings-daemon >= $GSD_REQUIRED
x11
xcursor
xfixes
xtst)
-AC_SUBST(DEPENDENCIES_CFLAGS)
-AC_SUBST(DEPENDENCIES_LIBS)
-
dnl *** arguments ***
AC_ARG_ENABLE(pointer-capture,
@@ -83,23 +78,12 @@ if test "$build_dca" = yes; then
AC_DEFINE(BUILD_DCA, 1, [Build dwell-click applet])
fi
-dnl *** libpanelapplet ***
+dnl *** libpanelapplet (OPTIONAL) ***
if test "$build_dca" = yes -o "$build_pca" = yes; then
PKG_CHECK_MODULES(PANELAPPLET, libpanelapplet-2.0)
- AC_SUBST(PANELAPPLET_CFLAGS)
- AC_SUBST(PANELAPPLET_LIBS)
fi
-dnl *** gconf ***
-
-AC_PATH_PROG(GCONFTOOL, gconftool-2, no)
-if test x"$GCONFTOOL" = xno; then
- AC_MSG_ERROR([gconftool-2 executable not found in your path])
-fi
-
-AM_GCONF_SOURCE_2
-
dnl *** output ***
AC_CONFIG_FILES([
diff --git a/data/Makefile.am b/data/Makefile.am
index d6da061..7c21577 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,4 +1,5 @@
if BUILD_PCA
+pca_schema = org.gnome.pointer-capture.gschema.xml.in
pca_ui = pointer-capture-applet.ui
pca_server = PointerCapture_Factory.server.in
pca_menu = PointerCapture.xml
@@ -32,24 +33,7 @@ ui_DATA = mousetweaks.ui $(pca_ui) $(dca_ui)
menudir = $(datadir)/mousetweaks
menu_DATA = $(pca_menu) $(dca_menu)
-if BUILD_PCA
- INTLTOOL_SCHEMAS_RULE@
-schemasdir = @GCONF_SCHEMA_FILE_DIR@
-schemas_in_files = pointer-capture-applet.schemas.in
-schemas_DATA = $(schemas_in_files:.schemas.in=.schemas)
-
-if GCONF_SCHEMAS_INSTALL
-install-data-local:
- -GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) \
- $(GCONFTOOL) --makefile-install-rule pointer-capture-applet.schemas
-
-uninstall-local:
- -GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) \
- $(GCONFTOOL) --makefile-uninstall-rule pointer-capture-applet.schemas
-endif
-endif
-
-gsettings_in_files = org.gnome.mousetweaks.gschema.xml.in
+gsettings_in_files = org.gnome.mousetweaks.gschema.xml.in $(pca_schema)
gsettings_SCHEMAS = $(gsettings_in_files:.xml.in=.xml)
@INTLTOOL_XML_NOMERGE_RULE@
@GSETTINGS_RULES@
diff --git a/data/org.gnome.pointer-capture.gschema.xml.in b/data/org.gnome.pointer-capture.gschema.xml.in
new file mode 100644
index 0000000..a9f5cf1
--- /dev/null
+++ b/data/org.gnome.pointer-capture.gschema.xml.in
@@ -0,0 +1,26 @@
+<schemalist>
+ <schema id="org.gnome.pointer-capture" path="/apps/pointer-capture/" gettext-domain="mousetweaks">
+ <key name="size" type="i">
+ <default>70</default>
+ <_summary>Size of capture area</_summary>
+ <_description>Width of the capture area in pixels.</_description>
+ </key>
+ <key name="mouse-button" type="i">
+ <default>1</default>
+ <_summary>Mouse button</_summary>
+ <_description>Mouse button used to capture or release the pointer.</_description>
+ </key>
+ <key name="modifier-shift" type="b">
+ <default>false</default>
+ <_summary>"Shift" keyboard modifier</_summary>
+ </key>
+ <key name="modifier-alt" type="b">
+ <default>false</default>
+ <_summary>"Alt" keyboard modifier</_summary>
+ </key>
+ <key name="modifier-control" type="b">
+ <default>false</default>
+ <_summary>"Control" keyboard modifier</_summary>
+ </key>
+ </schema>
+</schemalist>
diff --git a/data/pointer-capture-applet.ui b/data/pointer-capture-applet.ui
index 0f25f58..d3e7be5 100644
--- a/data/pointer-capture-applet.ui
+++ b/data/pointer-capture-applet.ui
@@ -1,24 +1,18 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy toplevel-contextual -->
- <object class="GtkAdjustment" id="adjustment1">
- <property name="value">1</property>
- <property name="upper">3</property>
- <property name="step_increment">1</property>
- <property name="page_increment">1</property>
- </object>
- <object class="GtkAdjustment" id="adjustment2">
+ <object class="GtkAdjustment" id="adj_mouse_button">
<property name="value">1</property>
<property name="lower">1</property>
<property name="upper">3</property>
<property name="step_increment">1</property>
<property name="page_increment">1</property>
</object>
- <object class="GtkAdjustment" id="adjustment3">
+ <object class="GtkAdjustment" id="adj_size">
<property name="value">20</property>
<property name="lower">20</property>
- <property name="upper">200</property>
+ <property name="upper">500</property>
<property name="step_increment">1</property>
<property name="page_increment">1</property>
</object>
@@ -30,8 +24,7 @@
<property name="window_position">center-on-parent</property>
<property name="icon_name">input-mouse</property>
<property name="type_hint">dialog</property>
- <property name="has_separator">False</property>
- <property name="copyright">Copyright 2007-2010 © Gerd Kohlberger</property>
+ <property name="copyright">Copyright 2007-2010 © Gerd Kohlberger</property>
<property name="comments" translatable="yes">Area to lock the pointer on the panel.
Part of Mousetweaks</property>
<property name="authors">Gerd Kohlberger <gerdko gmail com></property>
@@ -88,7 +81,7 @@ Part of Mousetweaks</property>
<object class="GtkAlignment" id="alignment1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="top_padding">8</property>
+ <property name="top_padding">12</property>
<property name="left_padding">18</property>
<child>
<object class="GtkTable" id="table1">
@@ -103,13 +96,13 @@ Part of Mousetweaks</property>
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
- <object class="GtkSpinButton" id="cap_button">
+ <object class="GtkSpinButton" id="mouse_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="tooltip_text" translatable="yes">Selecting Button 0 will capture the pointer immediately</property>
<property name="max_length">1</property>
- <property name="adjustment">adjustment1</property>
+ <property name="adjustment">adj_mouse_button</property>
<property name="numeric">True</property>
<property name="update_policy">if-valid</property>
</object>
@@ -139,7 +132,7 @@ Part of Mousetweaks</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="spacing">12</property>
<child>
- <object class="GtkCheckButton" id="cap_ctrl">
+ <object class="GtkCheckButton" id="modifier_control">
<property name="label" translatable="yes">C_trl</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -154,7 +147,7 @@ Part of Mousetweaks</property>
</packing>
</child>
<child>
- <object class="GtkCheckButton" id="cap_alt">
+ <object class="GtkCheckButton" id="modifier_alt">
<property name="label" translatable="yes">_Alt</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -169,8 +162,8 @@ Part of Mousetweaks</property>
</packing>
</child>
<child>
- <object class="GtkCheckButton" id="cap_shift">
- <property name="label" translatable="yes">S_hift</property>
+ <object class="GtkCheckButton" id="modifier_shift">
+ <property name="label" translatable="yes">_Shift</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
@@ -197,7 +190,7 @@ Part of Mousetweaks</property>
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0</property>
- <property name="label" translatable="yes">Modifier:</property>
+ <property name="label" translatable="yes">Keyboard modifier:</property>
</object>
<packing>
<property name="top_attach">1</property>
@@ -210,9 +203,9 @@ Part of Mousetweaks</property>
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0</property>
- <property name="label" translatable="yes">Mouse _button:</property>
+ <property name="label" translatable="yes">_Mouse button:</property>
<property name="use_underline">True</property>
- <property name="mnemonic_widget">cap_button</property>
+ <property name="mnemonic_widget">mouse_button</property>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
@@ -226,7 +219,7 @@ Part of Mousetweaks</property>
<object class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="label" translatable="yes">Capture Pointer</property>
+ <property name="label" translatable="yes">Capture and Release Controls</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
@@ -239,165 +232,6 @@ Part of Mousetweaks</property>
</packing>
</child>
<child>
- <object class="GtkFrame" id="frame3">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="label_xalign">0</property>
- <property name="shadow_type">none</property>
- <child>
- <object class="GtkAlignment" id="alignment3">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="top_padding">8</property>
- <property name="left_padding">18</property>
- <child>
- <object class="GtkTable" id="table5">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="n_rows">2</property>
- <property name="n_columns">2</property>
- <property name="column_spacing">12</property>
- <property name="row_spacing">8</property>
- <child>
- <object class="GtkHBox" id="hbox6">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <child>
- <object class="GtkSpinButton" id="rel_button">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="max_length">1</property>
- <property name="adjustment">adjustment2</property>
- <property name="numeric">True</property>
- <property name="update_policy">if-valid</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label4">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkHBox" id="hbox4">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkCheckButton" id="rel_ctrl">
- <property name="label" translatable="yes">Ct_rl</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="rel_alt">
- <property name="label" translatable="yes">A_lt</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="rel_shift">
- <property name="label" translatable="yes">Sh_ift</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="position">2</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label20">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Modifier:</property>
- </object>
- <packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label19">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Mouse b_utton:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">rel_button</property>
- </object>
- <packing>
- <property name="x_options">GTK_FILL</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- </child>
- <child type="label">
- <object class="GtkLabel" id="label21">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="label" translatable="yes">Release Pointer</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
<object class="GtkFrame" id="frame4">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
@@ -407,7 +241,7 @@ Part of Mousetweaks</property>
<object class="GtkAlignment" id="alignment4">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="top_padding">8</property>
+ <property name="top_padding">12</property>
<property name="left_padding">18</property>
<child>
<object class="GtkHBox" id="hbox5">
@@ -439,7 +273,7 @@ Part of Mousetweaks</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="max_length">3</property>
- <property name="adjustment">adjustment3</property>
+ <property name="adjustment">adj_size</property>
<property name="snap_to_ticks">True</property>
<property name="numeric">True</property>
<property name="update_policy">if-valid</property>
@@ -482,7 +316,7 @@ Part of Mousetweaks</property>
</object>
<packing>
<property name="expand">False</property>
- <property name="position">2</property>
+ <property name="position">1</property>
</packing>
</child>
</object>
@@ -536,8 +370,9 @@ Part of Mousetweaks</property>
</object>
</child>
</object>
- <object class="GtkSizeGroup" id="sizegroup">
+ <object class="GtkSizeGroup" id="group_label">
<widgets>
+ <widget name="label9"/>
<widget name="label10"/>
<widget name="label3"/>
</widgets>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index aa2bc27..36068a1 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -6,7 +6,7 @@ data/PointerCapture_Factory.server.in.in
data/DwellClick.xml
data/PointerCapture.xml
data/org.gnome.mousetweaks.gschema.xml.in
-data/pointer-capture-applet.schemas.in
+data/org.gnome.pointer-capture.gschema.xml.in
src/mt-main.c
src/mt-ctw.c
src/mt-common.c
diff --git a/src/pointer-capture-applet.c b/src/pointer-capture-applet.c
index 4cea0ca..7567013 100644
--- a/src/pointer-capture-applet.c
+++ b/src/pointer-capture-applet.c
@@ -18,7 +18,6 @@
#include <stdlib.h>
#include <gtk/gtk.h>
#include <panel-applet.h>
-#include <panel-applet-gconf.h>
#include "mt-common.h"
@@ -28,29 +27,33 @@
#define WID(n) (GTK_WIDGET (gtk_builder_get_object (pc->ui, (n))))
+#define PC_MOD_MASK (GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK)
+
typedef PanelAppletClass PcAppletClass;
typedef struct _PcApplet
{
PanelApplet parent;
+ GSettings *settings;
GtkBuilder *ui;
GtkWidget *area;
GtkWidget *box;
GtkWidget *label;
GtkWidget *icon;
- GdkCursor *blank;
+ GdkCursor *blank;
gboolean pointer_locked;
gint pointer_x;
gint pointer_y;
gint center_x;
gint center_y;
+ gboolean horizontal;
- gint size;
- gint cap_button;
- guint cap_mask;
- gint rel_button;
- guint rel_mask;
+ GtkSpinButton *size;
+ GtkSpinButton *mouse_button;
+ GtkToggleButton *modifier_shift;
+ GtkToggleButton *modifier_alt;
+ GtkToggleButton *modifier_control;
} PcApplet;
GType pc_applet_get_type (void) G_GNUC_CONST;
@@ -69,23 +72,13 @@ pc_applet_init (PcApplet *pc)
atk_object_set_description (atk, _("Temporarily lock the mouse pointer"));
}
- pc->ui = NULL;
- pc->area = NULL;
- pc->box = NULL;
- pc->label = NULL;
- pc->icon = NULL;
+ pc->settings = g_settings_new ("org.gnome.pointer-capture");
pc->blank = gdk_cursor_new (GDK_BLANK_CURSOR);
pc->pointer_locked = FALSE;
pc->pointer_x = 0;
pc->pointer_y = 0;
pc->center_x = 0;
pc->center_y = 0;
-
- pc->size = 70;
- pc->cap_button = 1;
- pc->cap_mask = 0;
- pc->rel_button = 1;
- pc->rel_mask = 0;
}
static void
@@ -93,27 +86,32 @@ pc_applet_change_orient (PanelApplet *applet,
PanelAppletOrient orient)
{
PcApplet *pc = PC_APPLET (applet);
+ gint size;
+
+ pc->horizontal = orient == PANEL_APPLET_ORIENT_UP ||
+ orient == PANEL_APPLET_ORIENT_DOWN;
if (pc->area || pc->label)
{
- if (orient == PANEL_APPLET_ORIENT_UP ||
- orient == PANEL_APPLET_ORIENT_DOWN)
+ size = gtk_spin_button_get_value_as_int (pc->size);
+
+ if (pc->horizontal)
{
- gtk_widget_set_size_request (pc->area, pc->size, -1);
+ gtk_widget_set_size_request (pc->area, size, -1);
gtk_label_set_angle (GTK_LABEL (pc->label), 0);
}
else
{
- gtk_widget_set_size_request (pc->area, -1, pc->size);
+ gtk_widget_set_size_request (pc->area, -1, size);
gtk_label_set_angle (GTK_LABEL (pc->label), 90);
}
}
}
static void
-pc_applet_destroy (GtkWidget *widget)
+pc_applet_destroy (GtkObject *object)
{
- PcApplet *pc = PC_APPLET (widget);
+ PcApplet *pc = PC_APPLET (object);
if (pc->blank)
{
@@ -128,17 +126,19 @@ pc_applet_destroy (GtkWidget *widget)
g_object_unref (pc->ui);
pc->ui = NULL;
}
+
+ if (pc->settings)
+ {
+ g_object_unref (pc->settings);
+ pc->settings = NULL;
+ }
}
static void
pc_applet_class_init (PcAppletClass *klass)
{
- GtkWidgetClass *widget_class;
PanelAppletClass *applet_class;
- widget_class = GTK_WIDGET_CLASS (klass);
- widget_class->destroy = pc_applet_destroy;
-
applet_class = PANEL_APPLET_CLASS (klass);
applet_class->change_orient = pc_applet_change_orient;
}
@@ -224,21 +224,6 @@ unlock_pointer (PcApplet *pc)
}
static gboolean
-pc_applet_enter_notify (GtkWidget *widget,
- GdkEventCrossing *event,
- PcApplet *pc)
-{
- /* lock the pointer immediately if we have no button */
- if (!pc->cap_button && event->mode == GDK_CROSSING_NORMAL)
- {
- pc->pointer_x = event->x_root;
- pc->pointer_y = event->y_root;
- lock_pointer (pc);
- }
- return FALSE;
-}
-
-static gboolean
pc_applet_leave_notify (GtkWidget *widget,
GdkEventCrossing *event,
PcApplet *pc)
@@ -260,23 +245,34 @@ pc_applet_button_press (GtkWidget *widget,
GdkEventButton *event,
PcApplet *pc)
{
- if (event->button == pc->cap_button &&
- (event->state & pc->cap_mask) == pc->cap_mask &&
- !pc->pointer_locked)
- {
- pc->pointer_x = event->x_root;
- pc->pointer_y = event->y_root;
- lock_pointer (pc);
- return TRUE;
- }
- else if (event->button == pc->rel_button &&
- (event->state & pc->rel_mask) == pc->rel_mask &&
- pc->pointer_locked)
+ gint button;
+ guint mask = 0;
+
+ button = gtk_spin_button_get_value_as_int (pc->mouse_button);
+
+ if (gtk_toggle_button_get_active (pc->modifier_shift))
+ mask |= GDK_SHIFT_MASK;
+ if (gtk_toggle_button_get_active (pc->modifier_control))
+ mask |= GDK_CONTROL_MASK;
+ if (gtk_toggle_button_get_active (pc->modifier_alt))
+ mask |= GDK_MOD1_MASK;
+
+ if (event->button == button && (event->state & PC_MOD_MASK) == mask)
{
- unlock_pointer (pc);
+ if (pc->pointer_locked)
+ {
+ unlock_pointer (pc);
+ }
+ else
+ {
+ pc->pointer_x = event->x_root;
+ pc->pointer_y = event->y_root;
+ lock_pointer (pc);
+ }
return TRUE;
}
- return FALSE;
+
+ return pc->pointer_locked;
}
static gboolean
@@ -342,12 +338,18 @@ about_response (GtkButton *button, gint response, PcApplet *pc)
static void
prefs_size_changed (GtkSpinButton *spin, PcApplet *pc)
{
- PanelApplet *applet = PANEL_APPLET (pc);
+ gint size;
- pc->size = gtk_spin_button_get_value_as_int (spin);
- panel_applet_gconf_set_int (applet, "size", pc->size, NULL);
+ size = gtk_spin_button_get_value_as_int (pc->size);
- pc_applet_change_orient (applet, panel_applet_get_orient (applet));
+ if (pc->horizontal)
+ {
+ gtk_widget_set_size_request (pc->area, size, -1);
+ }
+ else
+ {
+ gtk_widget_set_size_request (pc->area, -1, size);
+ }
}
static void
@@ -363,90 +365,9 @@ prefs_help (GtkButton *button, gpointer data)
gtk_get_current_event_time ());
}
-static void
-prefs_cap_button (GtkSpinButton *spin, PcApplet *pc)
-{
- pc->cap_button = gtk_spin_button_get_value_as_int (spin);
- panel_applet_gconf_set_int (PANEL_APPLET (pc),
- "capture_button",
- pc->cap_button,
- NULL);
-}
-
-static void
-prefs_cap_alt (GtkToggleButton *toggle, PcApplet *pc)
-{
- pc->cap_mask ^= GDK_MOD1_MASK;
- panel_applet_gconf_set_bool (PANEL_APPLET (pc),
- "capture_mod_alt",
- gtk_toggle_button_get_active (toggle),
- NULL);
-}
-
-static void
-prefs_cap_shift (GtkToggleButton *toggle, PcApplet *pc)
-{
- pc->cap_mask ^= GDK_SHIFT_MASK;
- panel_applet_gconf_set_bool (PANEL_APPLET (pc),
- "capture_mod_shift",
- gtk_toggle_button_get_active (toggle),
- NULL);
-}
-
-static void
-prefs_cap_ctrl (GtkToggleButton *toggle, PcApplet *pc)
-{
- pc->cap_mask ^= GDK_CONTROL_MASK;
- panel_applet_gconf_set_bool (PANEL_APPLET (pc),
- "capture_mod_ctrl",
- gtk_toggle_button_get_active (toggle),
- NULL);
-}
-
-static void
-prefs_rel_button (GtkSpinButton *spin, PcApplet *pc)
-{
- pc->rel_button = gtk_spin_button_get_value_as_int (spin);
- panel_applet_gconf_set_int (PANEL_APPLET (pc),
- "release_button",
- pc->rel_button,
- NULL);
-}
-
-static void
-prefs_rel_alt (GtkToggleButton *toggle, PcApplet *pc)
-{
- pc->rel_mask ^= GDK_MOD1_MASK;
- panel_applet_gconf_set_bool (PANEL_APPLET (pc),
- "release_mod_alt",
- gtk_toggle_button_get_active (toggle),
- NULL);
-}
-
-static void
-prefs_rel_shift (GtkToggleButton *toggle, PcApplet *pc)
-{
- pc->rel_mask ^= GDK_SHIFT_MASK;
- panel_applet_gconf_set_bool (PANEL_APPLET (pc),
- "release_mod_shift",
- gtk_toggle_button_get_active (toggle),
- NULL);
-}
-
-static void
-prefs_rel_ctrl (GtkToggleButton *toggle, PcApplet *pc)
-{
- pc->rel_mask ^= GDK_CONTROL_MASK;
- panel_applet_gconf_set_bool (PANEL_APPLET (pc),
- "release_mod_ctrl",
- gtk_toggle_button_get_active (toggle),
- NULL);
-}
-
static gboolean
init_preferences (PcApplet *pc)
{
- GtkWidget *w;
GError *error = NULL;
pc->ui = gtk_builder_new ();
@@ -467,52 +388,35 @@ init_preferences (PcApplet *pc)
g_signal_connect (WID ("help"), "clicked",
G_CALLBACK (prefs_help), NULL);
- /* size */
- w = WID ("size");
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (w), pc->size);
- g_signal_connect (w, "value_changed",
+ /* settings */
+ pc->size = GTK_SPIN_BUTTON (WID ("size"));
+ g_settings_bind (pc->settings, "size",
+ pc->size, "value",
+ G_SETTINGS_BIND_DEFAULT);
+
+ pc->mouse_button = GTK_SPIN_BUTTON (WID ("mouse_button"));
+ g_settings_bind (pc->settings, "mouse-button",
+ pc->mouse_button, "value",
+ G_SETTINGS_BIND_DEFAULT);
+
+ pc->modifier_shift = GTK_TOGGLE_BUTTON (WID ("modifier_shift"));
+ g_settings_bind (pc->settings, "modifier-shift",
+ pc->modifier_shift, "active",
+ G_SETTINGS_BIND_DEFAULT);
+
+ pc->modifier_alt = GTK_TOGGLE_BUTTON (WID ("modifier_alt"));
+ g_settings_bind (pc->settings, "modifier-alt",
+ pc->modifier_alt, "active",
+ G_SETTINGS_BIND_DEFAULT);
+
+ pc->modifier_control = GTK_TOGGLE_BUTTON (WID ("modifier_control"));
+ g_settings_bind (pc->settings, "modifier-control",
+ pc->modifier_control, "active",
+ G_SETTINGS_BIND_DEFAULT);
+
+ g_signal_connect (pc->size, "value_changed",
G_CALLBACK (prefs_size_changed), pc);
- /* capture modifier */
- w = WID ("cap_button");
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (w), pc->cap_button);
- g_signal_connect (w, "value_changed", G_CALLBACK (prefs_cap_button), pc);
-
- w = WID ("cap_alt");
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w),
- pc->cap_mask & GDK_MOD1_MASK);
- g_signal_connect (w, "toggled", G_CALLBACK (prefs_cap_alt), pc);
-
- w = WID ("cap_shift");
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w),
- pc->cap_mask & GDK_SHIFT_MASK);
- g_signal_connect (w, "toggled", G_CALLBACK (prefs_cap_shift), pc);
-
- w = WID ("cap_ctrl");
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w),
- pc->cap_mask & GDK_CONTROL_MASK);
- g_signal_connect (w, "toggled", G_CALLBACK (prefs_cap_ctrl), pc);
-
- /* release modifier */
- w = WID ("rel_button");
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (w), pc->rel_button);
- g_signal_connect (w, "value_changed", G_CALLBACK (prefs_rel_button), pc);
-
- w = WID ("rel_alt");
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w),
- pc->rel_mask & GDK_MOD1_MASK);
- g_signal_connect (w, "toggled", G_CALLBACK (prefs_rel_alt), pc);
-
- w = WID ("rel_shift");
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w),
- pc->rel_mask & GDK_SHIFT_MASK);
- g_signal_connect (w, "toggled", G_CALLBACK (prefs_rel_shift), pc);
-
- w = WID ("rel_ctrl");
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w),
- pc->rel_mask & GDK_CONTROL_MASK);
- g_signal_connect (w, "toggled", G_CALLBACK (prefs_rel_ctrl), pc);
-
return TRUE;
}
@@ -527,29 +431,9 @@ fill_applet (PanelApplet *applet)
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
- g_set_application_name (_("Pointer Capture"));
+ g_set_application_name (_("Pointer Capture Applet"));
gtk_window_set_default_icon_name (MT_ICON_NAME);
- /* gconf settings */
- panel_applet_add_preferences (applet, "/schemas/apps/pointer-capture", NULL);
-
- pc->size = panel_applet_gconf_get_int (applet, "size", NULL);
- pc->cap_button = panel_applet_gconf_get_int (applet, "capture_button", NULL);
- pc->rel_button = panel_applet_gconf_get_int (applet, "release_button", NULL);
-
- if (panel_applet_gconf_get_bool (applet, "capture_mod_shift", NULL))
- pc->cap_mask |= GDK_SHIFT_MASK;
- if (panel_applet_gconf_get_bool (applet, "capture_mod_ctrl", NULL))
- pc->cap_mask |= GDK_CONTROL_MASK;
- if (panel_applet_gconf_get_bool (applet, "capture_mod_alt", NULL))
- pc->cap_mask |= GDK_MOD1_MASK;
- if (panel_applet_gconf_get_bool (applet, "release_mod_shift", NULL))
- pc->rel_mask |= GDK_SHIFT_MASK;
- if (panel_applet_gconf_get_bool (applet, "release_mod_ctrl", NULL))
- pc->rel_mask |= GDK_CONTROL_MASK;
- if (panel_applet_gconf_get_bool (applet, "release_mod_alt", NULL))
- pc->rel_mask |= GDK_MOD1_MASK;
-
/* preferences dialog */
if (!init_preferences (pc))
return FALSE;
@@ -568,8 +452,8 @@ fill_applet (PanelApplet *applet)
panel_applet_setup_menu_from_file (applet, DATADIR, "PointerCapture.xml",
NULL, menu_verb, pc);
- g_signal_connect (pc, "enter-notify-event",
- G_CALLBACK (pc_applet_enter_notify), pc);
+ g_signal_connect (pc, "destroy",
+ G_CALLBACK (pc_applet_destroy), NULL);
g_signal_connect (pc, "leave-notify-event",
G_CALLBACK (pc_applet_leave_notify), pc);
g_signal_connect (pc, "button-press-event",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]