[mousetweaks] Unify coding style
- From: Gerd Kohlberger <gerdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mousetweaks] Unify coding style
- Date: Tue, 22 Jun 2010 14:15:06 +0000 (UTC)
commit c6eec99f33fb0a185290e81155d1c2bdf294301b
Author: Gerd Kohlberger <gerdk src gnome org>
Date: Tue Jun 22 15:33:14 2010 +0200
Unify coding style
- Tabs suck.
- Move opening brackets to new line.
- Use the same gobject conventions across files.
- Trailing white space.
src/dwell-click-applet.c | 403 +++++++++++++-----------
src/mt-common.c | 72 +++--
src/mt-common.h | 19 +-
src/mt-ctw.c | 133 +++++----
src/mt-ctw.h | 10 +-
src/mt-cursor-manager.h | 17 +-
src/mt-cursor.c | 67 ++--
src/mt-cursor.h | 36 +-
src/mt-listener.h | 1 +
src/mt-main.c | 699 +++++++++++++++++++++++-------------------
src/mt-main.h | 3 +-
src/mt-pidfile.c | 145 +++++----
src/mt-pidfile.h | 11 +-
src/mt-service.h | 2 +-
src/mt-timer.c | 96 +++---
src/mt-timer.h | 35 +-
src/pointer-capture-applet.c | 313 ++++++++++---------
17 files changed, 1100 insertions(+), 962 deletions(-)
---
diff --git a/src/dwell-click-applet.c b/src/dwell-click-applet.c
index 62c83b3..84b3d78 100644
--- a/src/dwell-click-applet.c
+++ b/src/dwell-click-applet.c
@@ -26,7 +26,8 @@
#define WID(n) (GTK_WIDGET (gtk_builder_get_object (dd->ui, n)))
typedef struct _DwellData DwellData;
-struct _DwellData {
+struct _DwellData
+{
GConfClient *client;
GDBusProxy *proxy;
GtkBuilder *ui;
@@ -45,14 +46,16 @@ struct _DwellData {
gdouble elapsed;
};
-static const gchar *img_widgets[] = {
+static const gchar *img_widgets[] =
+{
"right_click_img",
"drag_click_img",
"double_click_img",
"single_click_img"
};
-static const gchar *img_widgets_v[] = {
+static const gchar *img_widgets_v[] =
+{
"right_click_img_v",
"drag_click_img_v",
"double_click_img_v",
@@ -60,16 +63,17 @@ static const gchar *img_widgets_v[] = {
};
static void preferences_dialog (BonoboUIComponent *component,
- gpointer data,
- const char *cname);
+ gpointer data,
+ const char *cname);
static void help_dialog (BonoboUIComponent *component,
- gpointer data,
- const char *cname);
+ gpointer data,
+ const char *cname);
static void about_dialog (BonoboUIComponent *component,
- gpointer data,
- const char *cname);
+ gpointer data,
+ const char *cname);
-static const BonoboUIVerb menu_verb[] = {
+static const BonoboUIVerb menu_verb[] =
+{
BONOBO_UI_UNSAFE_VERB ("PropertiesVerb", preferences_dialog),
BONOBO_UI_UNSAFE_VERB ("HelpVerb", help_dialog),
BONOBO_UI_UNSAFE_VERB ("AboutVerb", about_dialog),
@@ -205,7 +209,7 @@ static gboolean
do_not_eat (GtkWidget *widget, GdkEventButton *bev, gpointer user)
{
if (bev->button != 1)
- g_signal_stop_emission_by_name (widget, "button_press_event");
+ g_signal_stop_emission_by_name (widget, "button_press_event");
return FALSE;
}
@@ -219,9 +223,9 @@ enable_dwell_changed (GtkToggleButton *button, gpointer data)
gconf_client_set_bool (dd->client, OPT_CTW, FALSE, NULL);
gconf_client_set_bool (dd->client,
- OPT_DWELL,
- gtk_toggle_button_get_active (button),
- NULL);
+ OPT_DWELL,
+ gtk_toggle_button_get_active (button),
+ NULL);
}
static gboolean
@@ -231,12 +235,15 @@ activation_timeout (gpointer data)
gboolean stop;
if ((dd->elapsed = g_timer_elapsed (dd->timer, NULL)) < dd->delay)
- stop = TRUE;
- else {
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dd->enable), TRUE);
- dd->tid = 0;
- dd->elapsed = 0.0;
- stop = FALSE;
+ {
+ stop = TRUE;
+ }
+ else
+ {
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dd->enable), TRUE);
+ dd->tid = 0;
+ dd->elapsed = 0.0;
+ stop = FALSE;
}
gtk_widget_queue_draw (dd->enable);
@@ -245,40 +252,45 @@ activation_timeout (gpointer data)
static gboolean
enable_dwell_crossing (GtkWidget *widget,
- GdkEventCrossing *event,
- gpointer data)
+ GdkEventCrossing *event,
+ gpointer data)
{
DwellData *dd = data;
GError *error = NULL;
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dd->enable)))
- return FALSE;
-
- if (event->type == GDK_ENTER_NOTIFY) {
- if (!dd->tid) {
- dd->delay = gconf_client_get_float (dd->client, OPT_DWELL_T, &error);
- if (error) {
- g_error_free (error);
- dd->delay = 1.2;
- }
- g_timer_start (dd->timer);
- dd->tid = g_timeout_add (100, activation_timeout, dd);
- }
+ return FALSE;
+
+ if (event->type == GDK_ENTER_NOTIFY)
+ {
+ if (!dd->tid)
+ {
+ dd->delay = gconf_client_get_float (dd->client, OPT_DWELL_T, &error);
+ if (error)
+ {
+ g_error_free (error);
+ dd->delay = 1.2;
+ }
+ g_timer_start (dd->timer);
+ dd->tid = g_timeout_add (100, activation_timeout, dd);
+ }
}
- else {
- if (dd->tid) {
- g_source_remove (dd->tid);
- dd->tid = 0;
- dd->elapsed = 0.0;
- }
+ else
+ {
+ if (dd->tid)
+ {
+ g_source_remove (dd->tid);
+ dd->tid = 0;
+ dd->elapsed = 0.0;
+ }
}
return FALSE;
}
static gboolean
enable_dwell_exposed (GtkWidget *widget,
- GdkEventExpose *event,
- gpointer data)
+ GdkEventExpose *event,
+ gpointer data)
{
DwellData *dd = data;
cairo_t *cr;
@@ -291,9 +303,9 @@ enable_dwell_exposed (GtkWidget *widget,
style = gtk_widget_get_style (widget);
c = style->bg[GTK_STATE_SELECTED];
gtk_widget_style_get (widget,
- "focus-line-width", &fwidth,
- "focus-padding", &fpad,
- NULL);
+ "focus-line-width", &fwidth,
+ "focus-padding", &fpad,
+ NULL);
gtk_widget_get_allocation (widget, &allocation);
x = allocation.x + fwidth + fpad;
@@ -303,10 +315,10 @@ enable_dwell_exposed (GtkWidget *widget,
cr = gdk_cairo_create (gtk_widget_get_window (widget));
cairo_set_source_rgba (cr,
- c.red / 65535.,
- c.green / 65535.,
- c.blue / 65535.,
- 0.5);
+ c.red / 65535.,
+ c.green / 65535.,
+ c.blue / 65535.,
+ 0.5);
cairo_rectangle (cr, x, y, w, h * dd->elapsed / dd->delay);
cairo_fill (cr);
cairo_destroy (cr);
@@ -329,8 +341,8 @@ button_cb (GtkToggleButton *button, DwellData *dd)
static void
button_size_allocate (GtkWidget *widget,
- GtkAllocation *alloc,
- gpointer data)
+ GtkAllocation *alloc,
+ gpointer data)
{
DwellData *dd = data;
GtkWidget *w;
@@ -338,44 +350,52 @@ button_size_allocate (GtkWidget *widget,
gint i;
if (dd->button_width == alloc->width &&
- dd->button_height == alloc->height)
- return;
-
- if (g_str_equal (gtk_widget_get_name (dd->box), "box_vert")) {
- /* vertical */
- for (i = 0; i < N_CLICK_TYPES; i++) {
- w = WID (img_widgets_v[i]);
- if (alloc->width < 32) {
- tmp = gdk_pixbuf_scale_simple (dd->click[i],
- alloc->width - 7,
- alloc->width - 7,
- GDK_INTERP_HYPER);
- if (tmp) {
- gtk_image_set_from_pixbuf (GTK_IMAGE (w), tmp);
- g_object_unref (tmp);
- }
- }
- else
- gtk_image_set_from_pixbuf (GTK_IMAGE (w), dd->click[i]);
- }
+ dd->button_height == alloc->height)
+ return;
+
+ if (g_str_equal (gtk_widget_get_name (dd->box), "box_vert"))
+ {
+ /* vertical */
+ for (i = 0; i < N_CLICK_TYPES; i++)
+ {
+ w = WID (img_widgets_v[i]);
+ if (alloc->width < 32)
+ {
+ tmp = gdk_pixbuf_scale_simple (dd->click[i],
+ alloc->width - 7,
+ alloc->width - 7,
+ GDK_INTERP_HYPER);
+ if (tmp)
+ {
+ gtk_image_set_from_pixbuf (GTK_IMAGE (w), tmp);
+ g_object_unref (tmp);
+ }
+ }
+ else
+ gtk_image_set_from_pixbuf (GTK_IMAGE (w), dd->click[i]);
+ }
}
- else {
- /* horizontal */
- for (i = 0; i < N_CLICK_TYPES; i++) {
- w = WID (img_widgets[i]);
- if (alloc->height < 32) {
- tmp = gdk_pixbuf_scale_simple (dd->click[i],
- alloc->height - 7,
- alloc->height - 7,
- GDK_INTERP_HYPER);
- if (tmp) {
- gtk_image_set_from_pixbuf (GTK_IMAGE (w), tmp);
- g_object_unref (tmp);
- }
- }
- else
- gtk_image_set_from_pixbuf (GTK_IMAGE (w), dd->click[i]);
- }
+ else
+ {
+ /* horizontal */
+ for (i = 0; i < N_CLICK_TYPES; i++)
+ {
+ w = WID (img_widgets[i]);
+ if (alloc->height < 32)
+ {
+ tmp = gdk_pixbuf_scale_simple (dd->click[i],
+ alloc->height - 7,
+ alloc->height - 7,
+ GDK_INTERP_HYPER);
+ if (tmp)
+ {
+ gtk_image_set_from_pixbuf (GTK_IMAGE (w), tmp);
+ g_object_unref (tmp);
+ }
+ }
+ else
+ gtk_image_set_from_pixbuf (GTK_IMAGE (w), dd->click[i]);
+ }
}
dd->button_width = alloc->width;
dd->button_height = alloc->height;
@@ -390,29 +410,33 @@ applet_orient_changed (PanelApplet *applet, guint orient, gpointer data)
gtk_container_remove (GTK_CONTAINER (applet), g_object_ref (dd->box));
- switch (orient) {
- case PANEL_APPLET_ORIENT_UP:
- case PANEL_APPLET_ORIENT_DOWN:
- dd->box = WID ("box_hori");
- dd->ct_box = WID ("ct_box");
- dd->enable = WID ("enable");
- dd->button = WID ("single_click");
- break;
- case PANEL_APPLET_ORIENT_LEFT:
- case PANEL_APPLET_ORIENT_RIGHT:
- dd->box = WID ("box_vert");
- dd->ct_box = WID ("ct_box_v");
- dd->enable = WID ("enable_v");
- dd->button = WID ("single_click_v");
- default:
- break;
+ switch (orient)
+ {
+ case PANEL_APPLET_ORIENT_UP:
+ case PANEL_APPLET_ORIENT_DOWN:
+ dd->box = WID ("box_hori");
+ dd->ct_box = WID ("ct_box");
+ dd->enable = WID ("enable");
+ dd->button = WID ("single_click");
+ break;
+ case PANEL_APPLET_ORIENT_LEFT:
+ case PANEL_APPLET_ORIENT_RIGHT:
+ dd->box = WID ("box_vert");
+ dd->ct_box = WID ("ct_box_v");
+ dd->enable = WID ("enable_v");
+ dd->button = WID ("single_click_v");
+ default:
+ break;
}
if (gtk_widget_get_parent (dd->box))
- gtk_widget_reparent (dd->box, GTK_WIDGET (applet));
- else {
- gtk_container_add (GTK_CONTAINER (applet), dd->box);
- g_object_unref (dd->box);
+ {
+ gtk_widget_reparent (dd->box, GTK_WIDGET (applet));
+ }
+ else
+ {
+ gtk_container_add (GTK_CONTAINER (applet), dd->box);
+ g_object_unref (dd->box);
}
dwell = gconf_client_get_bool (dd->client, OPT_DWELL, NULL);
@@ -427,8 +451,8 @@ applet_unrealized (GtkWidget *widget, gpointer data)
gint i;
for (i = 0; i < N_CLICK_TYPES; i++)
- if (dd->click[i])
- g_object_unref (dd->click[i]);
+ if (dd->click[i])
+ g_object_unref (dd->click[i]);
g_object_unref (dd->ui);
g_object_unref (dd->client);
@@ -440,35 +464,36 @@ applet_unrealized (GtkWidget *widget, gpointer data)
static void
preferences_dialog (BonoboUIComponent *component,
- gpointer data,
- const char *cname)
+ gpointer data,
+ const char *cname)
{
GError *error = NULL;
if (!g_spawn_command_line_async ("gnome-mouse-properties -p accessibility",
- &error)) {
- mt_common_show_dialog (_("Failed to Launch Mouse Preferences"),
- error->message,
- MT_MESSAGE_WARNING);
- g_error_free (error);
+ &error))
+ {
+ mt_common_show_dialog (_("Failed to Launch Mouse Preferences"),
+ error->message,
+ MT_MESSAGE_WARNING);
+ g_error_free (error);
}
}
static void
help_dialog (BonoboUIComponent *component,
- gpointer data,
- const char *cname)
+ gpointer data,
+ const char *cname)
{
DwellData *dd = data;
mt_common_show_help (gtk_widget_get_screen (dd->box),
- gtk_get_current_event_time ());
+ gtk_get_current_event_time ());
}
static void
about_dialog (BonoboUIComponent *component,
- gpointer data,
- const char *cname)
+ gpointer data,
+ const char *cname)
{
DwellData *dd = data;
@@ -488,9 +513,9 @@ init_button (DwellData *dd, GtkWidget *button)
{
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);
g_signal_connect (button, "button-press-event",
- G_CALLBACK (do_not_eat), NULL);
+ G_CALLBACK (do_not_eat), NULL);
g_signal_connect (button, "toggled",
- G_CALLBACK (button_cb), dd);
+ G_CALLBACK (button_cb), dd);
}
static void
@@ -506,7 +531,7 @@ setup_box (DwellData *dd)
init_button (dd, widget);
gtk_size_group_add_widget (hgroup, widget);
g_signal_connect (widget, "size-allocate",
- G_CALLBACK (button_size_allocate), dd);
+ G_CALLBACK (button_size_allocate), dd);
init_button (dd, WID ("double_click"));
init_button (dd, WID ("drag_click"));
@@ -515,15 +540,15 @@ setup_box (DwellData *dd)
widget = WID ("enable");
gtk_size_group_add_widget (hgroup, widget);
g_signal_connect (widget, "button-press-event",
- G_CALLBACK (do_not_eat), NULL);
+ G_CALLBACK (do_not_eat), NULL);
g_signal_connect (widget, "toggled",
- G_CALLBACK (enable_dwell_changed), dd);
+ G_CALLBACK (enable_dwell_changed), dd);
g_signal_connect (widget, "enter-notify-event",
- G_CALLBACK (enable_dwell_crossing), dd);
+ G_CALLBACK (enable_dwell_crossing), dd);
g_signal_connect (widget, "leave-notify-event",
- G_CALLBACK (enable_dwell_crossing), dd);
+ G_CALLBACK (enable_dwell_crossing), dd);
g_signal_connect_after (widget, "expose-event",
- G_CALLBACK (enable_dwell_exposed), dd);
+ G_CALLBACK (enable_dwell_exposed), dd);
/* vertical */
vgroup = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
@@ -531,7 +556,7 @@ setup_box (DwellData *dd)
gtk_size_group_add_widget (vgroup, widget);
init_button (dd, widget);
g_signal_connect (WID ("single_click_v"), "size-allocate",
- G_CALLBACK (button_size_allocate), dd);
+ G_CALLBACK (button_size_allocate), dd);
init_button (dd, WID ("double_click_v"));
init_button (dd, WID ("drag_click_v"));
init_button (dd, WID ("right_click_v"));
@@ -539,39 +564,42 @@ setup_box (DwellData *dd)
widget = WID ("enable_v");
gtk_size_group_add_widget (vgroup, widget);
g_signal_connect (widget, "button-press-event",
- G_CALLBACK (do_not_eat), NULL);
+ G_CALLBACK (do_not_eat), NULL);
g_signal_connect (widget, "toggled",
- G_CALLBACK (enable_dwell_changed), dd);
+ G_CALLBACK (enable_dwell_changed), dd);
g_signal_connect (widget, "enter-notify-event",
- G_CALLBACK (enable_dwell_crossing), dd);
+ G_CALLBACK (enable_dwell_crossing), dd);
g_signal_connect (widget, "leave-notify-event",
- G_CALLBACK (enable_dwell_crossing), dd);
+ G_CALLBACK (enable_dwell_crossing), dd);
g_signal_connect_after (widget, "expose-event",
- G_CALLBACK (enable_dwell_exposed), dd);
+ G_CALLBACK (enable_dwell_exposed), dd);
- for (i = 0; i < N_CLICK_TYPES; i++) {
- gtk_image_set_from_pixbuf (GTK_IMAGE (WID (img_widgets[i])),
- dd->click[i]);
- gtk_image_set_from_pixbuf (GTK_IMAGE (WID (img_widgets_v[i])),
- dd->click[i]);
+ for (i = 0; i < N_CLICK_TYPES; i++)
+ {
+ gtk_image_set_from_pixbuf (GTK_IMAGE (WID (img_widgets[i])),
+ dd->click[i]);
+ gtk_image_set_from_pixbuf (GTK_IMAGE (WID (img_widgets_v[i])),
+ dd->click[i]);
}
}
static void
gconf_value_changed (GConfClient *client,
- const gchar *key,
- GConfValue *value,
- gpointer data)
+ const gchar *key,
+ GConfValue *value,
+ gpointer data)
{
DwellData *dd = data;
- if (g_str_equal (key, OPT_MODE)) {
- update_sensitivity (dd);
+ if (g_str_equal (key, OPT_MODE))
+ {
+ update_sensitivity (dd);
}
- else if (g_str_equal (key, OPT_DWELL) && value->type == GCONF_VALUE_BOOL) {
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dd->enable),
- gconf_value_get_bool (value));
- update_sensitivity (dd);
+ else if (g_str_equal (key, OPT_DWELL) && value->type == GCONF_VALUE_BOOL)
+ {
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dd->enable),
+ gconf_value_get_bool (value));
+ update_sensitivity (dd);
}
}
@@ -596,14 +624,15 @@ fill_applet (PanelApplet *applet)
/* user interface */
dd->ui = gtk_builder_new ();
gtk_builder_add_from_file (dd->ui, DATADIR "/dwell-click-applet.ui", &error);
- if (error) {
- g_print ("%s\n", error->message);
- g_error_free (error);
+ if (error)
+ {
+ g_print ("%s\n", error->message);
+ g_error_free (error);
- g_object_unref (dd->ui);
- g_slice_free (DwellData, dd);
+ g_object_unref (dd->ui);
+ g_slice_free (DwellData, dd);
- return FALSE;
+ return FALSE;
}
/* dbus */
@@ -616,55 +645,57 @@ fill_applet (PanelApplet *applet)
about = WID ("about");
g_object_set (about, "version", VERSION, NULL);
g_signal_connect (about, "delete-event",
- G_CALLBACK (gtk_widget_hide_on_delete), NULL);
+ G_CALLBACK (gtk_widget_hide_on_delete), NULL);
g_signal_connect (about, "response",
- G_CALLBACK (about_response), dd);
+ G_CALLBACK (about_response), dd);
/* gconf */
dd->client = gconf_client_get_default ();
gconf_client_add_dir (dd->client, MT_GCONF_HOME,
- GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
+ GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
g_signal_connect (dd->client, "value_changed",
- G_CALLBACK (gconf_value_changed), dd);
+ G_CALLBACK (gconf_value_changed), dd);
/* icons */
dd->click[DWELL_CLICK_TYPE_SINGLE] =
- gdk_pixbuf_new_from_file (DATADIR "/single-click.png", NULL);
+ gdk_pixbuf_new_from_file (DATADIR "/single-click.png", NULL);
dd->click[DWELL_CLICK_TYPE_DOUBLE] =
- gdk_pixbuf_new_from_file (DATADIR "/double-click.png", NULL);
+ gdk_pixbuf_new_from_file (DATADIR "/double-click.png", NULL);
dd->click[DWELL_CLICK_TYPE_DRAG] =
- gdk_pixbuf_new_from_file (DATADIR "/drag-click.png", NULL);
+ gdk_pixbuf_new_from_file (DATADIR "/drag-click.png", NULL);
dd->click[DWELL_CLICK_TYPE_RIGHT] =
- gdk_pixbuf_new_from_file (DATADIR "/right-click.png", NULL);
+ gdk_pixbuf_new_from_file (DATADIR "/right-click.png", NULL);
/* applet initialization */
panel_applet_set_flags (applet,
- PANEL_APPLET_EXPAND_MINOR |
- PANEL_APPLET_HAS_HANDLE);
+ PANEL_APPLET_EXPAND_MINOR |
+ PANEL_APPLET_HAS_HANDLE);
panel_applet_set_background_widget (applet, GTK_WIDGET(applet));
panel_applet_setup_menu_from_file (applet,
- DATADIR, "DwellClick.xml",
- NULL, menu_verb, dd);
+ DATADIR, "DwellClick.xml",
+ NULL, menu_verb, dd);
g_signal_connect (applet, "change-orient",
- G_CALLBACK (applet_orient_changed), dd);
+ G_CALLBACK (applet_orient_changed), dd);
g_signal_connect (applet, "unrealize",
- G_CALLBACK (applet_unrealized), dd);
+ G_CALLBACK (applet_unrealized), dd);
/* check initial orientation */
orient = panel_applet_get_orient (applet);
if (orient == PANEL_APPLET_ORIENT_UP ||
- orient == PANEL_APPLET_ORIENT_DOWN) {
- dd->box = WID ("box_hori");
- dd->ct_box = WID ("ct_box");
- dd->enable = WID ("enable");
- dd->button = WID ("single_click");
+ orient == PANEL_APPLET_ORIENT_DOWN)
+ {
+ dd->box = WID ("box_hori");
+ dd->ct_box = WID ("ct_box");
+ dd->enable = WID ("enable");
+ dd->button = WID ("single_click");
}
- else {
- dd->box = WID ("box_vert");
- dd->ct_box = WID ("ct_box_v");
- dd->enable = WID ("enable_v");
- dd->button = WID ("single_click_v");
+ else
+ {
+ dd->box = WID ("box_vert");
+ dd->ct_box = WID ("ct_box_v");
+ dd->enable = WID ("enable_v");
+ dd->button = WID ("single_click_v");
}
dwell = gconf_client_get_bool (dd->client, OPT_DWELL, NULL);
@@ -682,14 +713,14 @@ static gboolean
applet_factory (PanelApplet *applet, const gchar *iid, gpointer data)
{
if (!g_str_equal (iid, "OAFIID:DwellClickApplet"))
- return FALSE;
+ return FALSE;
return fill_applet (applet);
}
PANEL_APPLET_BONOBO_FACTORY ("OAFIID:DwellClickApplet_Factory",
- PANEL_TYPE_APPLET,
- "Dwell Click Factory",
- VERSION,
- applet_factory,
- NULL);
+ PANEL_TYPE_APPLET,
+ "Dwell Click Factory",
+ VERSION,
+ applet_factory,
+ NULL);
diff --git a/src/mt-common.c b/src/mt-common.c
index 6797017..69efdcd 100644
--- a/src/mt-common.c
+++ b/src/mt-common.c
@@ -1,5 +1,5 @@
/*
- * Copyright © 2007-2009 Gerd Kohlberger <lowfi chello at>
+ * Copyright © 2007-2010 Gerd Kohlberger <gerdko gmail com>
*
* This file is part of Mousetweaks.
*
@@ -26,53 +26,57 @@ mt_common_show_help (GdkScreen *screen, guint32 timestamp)
{
GError *error = NULL;
- if (!gtk_show_uri (screen, "ghelp:mousetweaks", timestamp, &error)) {
- mt_common_show_dialog (_("Failed to Display Help"),
- error->message, MT_MESSAGE_WARNING);
- g_error_free (error);
+ if (!gtk_show_uri (screen, "ghelp:mousetweaks", timestamp, &error))
+ {
+ mt_common_show_dialog (_("Failed to Display Help"),
+ error->message, MT_MESSAGE_WARNING);
+ g_error_free (error);
}
}
gint
mt_common_show_dialog (const gchar *primary,
- const gchar *secondary,
- MtMessageType type)
+ const gchar *secondary,
+ MtMessageType type)
{
GtkWidget *dialog;
gint ret;
dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR,
- GTK_BUTTONS_NONE, "%s", primary);
+ GTK_BUTTONS_NONE, "%s", primary);
+
gtk_window_set_title (GTK_WINDOW (dialog), g_get_application_name ());
gtk_window_set_icon_name (GTK_WINDOW (dialog), MT_ICON_NAME);
gtk_window_set_keep_above (GTK_WINDOW (dialog), TRUE);
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- "%s", secondary);
- switch (type) {
- case MT_MESSAGE_QUESTION:
- g_object_set (dialog, "message-type", GTK_MESSAGE_QUESTION, NULL);
- gtk_dialog_add_buttons (GTK_DIALOG (dialog),
- GTK_STOCK_YES, GTK_RESPONSE_YES,
- GTK_STOCK_NO, GTK_RESPONSE_NO,
- NULL);
- break;
- case MT_MESSAGE_WARNING:
- g_object_set (dialog, "message-type", GTK_MESSAGE_WARNING, NULL);
- gtk_dialog_add_button (GTK_DIALOG (dialog),
- GTK_STOCK_OK, GTK_RESPONSE_OK);
- break;
- case MT_MESSAGE_LOGOUT:
- gtk_dialog_add_buttons (GTK_DIALOG (dialog),
- _("Enable and Log Out"), GTK_RESPONSE_ACCEPT,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- NULL);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog),
- GTK_RESPONSE_ACCEPT);
- break;
- case MT_MESSAGE_ERROR:
- default:
- gtk_dialog_add_button (GTK_DIALOG (dialog),
- GTK_STOCK_OK, GTK_RESPONSE_OK);
+ "%s", secondary);
+
+ switch (type)
+ {
+ case MT_MESSAGE_QUESTION:
+ g_object_set (dialog, "message-type", GTK_MESSAGE_QUESTION, NULL);
+ gtk_dialog_add_buttons (GTK_DIALOG (dialog),
+ GTK_STOCK_YES, GTK_RESPONSE_YES,
+ GTK_STOCK_NO, GTK_RESPONSE_NO,
+ NULL);
+ break;
+ case MT_MESSAGE_WARNING:
+ g_object_set (dialog, "message-type", GTK_MESSAGE_WARNING, NULL);
+ gtk_dialog_add_button (GTK_DIALOG (dialog),
+ GTK_STOCK_OK, GTK_RESPONSE_OK);
+ break;
+ case MT_MESSAGE_LOGOUT:
+ gtk_dialog_add_buttons (GTK_DIALOG (dialog),
+ _("Enable and Log Out"), GTK_RESPONSE_ACCEPT,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ NULL);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog),
+ GTK_RESPONSE_ACCEPT);
+ break;
+ case MT_MESSAGE_ERROR:
+ default:
+ gtk_dialog_add_button (GTK_DIALOG (dialog),
+ GTK_STOCK_OK, GTK_RESPONSE_OK);
}
ret = gtk_dialog_run (GTK_DIALOG (dialog));
diff --git a/src/mt-common.h b/src/mt-common.h
index f89496b..c752250 100644
--- a/src/mt-common.h
+++ b/src/mt-common.h
@@ -53,7 +53,8 @@ G_BEGIN_DECLS
#define GNOME_MOUSE_DIR "/desktop/gnome/peripherals/mouse"
#define GNOME_MOUSE_ORIENT GNOME_MOUSE_DIR "/left_handed"
-enum {
+enum
+{
DWELL_MODE_CTW = 0,
DWELL_MODE_GESTURE
};
@@ -67,7 +68,8 @@ typedef enum
N_CLICK_TYPES
} MtClickType;
-enum {
+enum
+{
DIRECTION_LEFT = 0,
DIRECTION_RIGHT,
DIRECTION_UP,
@@ -75,18 +77,19 @@ enum {
DIRECTION_DISABLE
};
-typedef enum {
+typedef enum
+{
MT_MESSAGE_ERROR = 0,
MT_MESSAGE_WARNING,
MT_MESSAGE_QUESTION,
MT_MESSAGE_LOGOUT
} MtMessageType;
-void mt_common_show_help (GdkScreen *screen,
- guint32 timestamp);
-gint mt_common_show_dialog (const gchar *primary,
- const gchar *secondary,
- MtMessageType type);
+void mt_common_show_help (GdkScreen *screen,
+ guint32 timestamp);
+gint mt_common_show_dialog (const gchar *primary,
+ const gchar *secondary,
+ MtMessageType type);
G_END_DECLS
diff --git a/src/mt-ctw.c b/src/mt-ctw.c
index 4fa7c61..82b607c 100644
--- a/src/mt-ctw.c
+++ b/src/mt-ctw.c
@@ -1,5 +1,5 @@
/*
- * Copyright © 2007-2009 Gerd Kohlberger <lowfi chello at>
+ * Copyright © 2007-2010 Gerd Kohlberger <gerdko gmail com>
*
* This file is part of Mousetweaks.
*
@@ -26,7 +26,8 @@
#define WID(n) (GTK_WIDGET (gtk_builder_get_object (mt->ui, n)))
-enum {
+enum
+{
BUTTON_STYLE_TEXT = 0,
BUTTON_STYLE_ICON,
BUTTON_STYLE_BOTH
@@ -52,16 +53,19 @@ mt_ctw_update_visibility (MtData *mt)
ctw = mt_ctw_get_window (mt);
- if (mt->dwell_enabled && mt->dwell_show_ctw) {
- if (mt->n_screens > 1) {
- gdk_display_get_pointer (gdk_display_get_default (),
- &screen, NULL, NULL, NULL);
- gtk_window_set_screen (GTK_WINDOW (ctw), screen);
- }
- gtk_widget_show (ctw);
+ if (mt->dwell_enabled && mt->dwell_show_ctw)
+ {
+ if (mt->n_screens > 1)
+ {
+ gdk_display_get_pointer (gdk_display_get_default (),
+ &screen, NULL, NULL, NULL);
+ gtk_window_set_screen (GTK_WINDOW (ctw), screen);
+ }
+ gtk_widget_show (ctw);
}
- else {
- gtk_widget_hide (ctw);
+ else
+ {
+ gtk_widget_hide (ctw);
}
}
@@ -82,31 +86,33 @@ mt_ctw_update_style (MtData *mt, gint style)
const gchar *img[] = { "single_i", "double_i", "drag_i", "right_i" };
gint i;
- for (i = 0; i < N_CLICK_TYPES; i++) {
- label = WID (l[i]);
- icon = WID (img[i]);
-
- switch (style) {
- case BUTTON_STYLE_BOTH:
- g_object_set (icon, "yalign", 1.0, NULL);
- gtk_widget_show (icon);
- g_object_set (label, "yalign", 0.0, NULL);
- gtk_widget_show (label);
- break;
- case BUTTON_STYLE_TEXT:
- gtk_widget_hide (icon);
- g_object_set (icon, "yalign", 0.5, NULL);
- gtk_widget_show (label);
- g_object_set (label, "yalign", 0.5, NULL);
- break;
- case BUTTON_STYLE_ICON:
- gtk_widget_show (icon);
- g_object_set (icon, "yalign", 0.5, NULL);
- gtk_widget_hide (label);
- g_object_set (label, "yalign", 0.5, NULL);
- default:
- break;
- }
+ for (i = 0; i < N_CLICK_TYPES; i++)
+ {
+ label = WID (l[i]);
+ icon = WID (img[i]);
+
+ switch (style)
+ {
+ case BUTTON_STYLE_BOTH:
+ g_object_set (icon, "yalign", 1.0, NULL);
+ gtk_widget_show (icon);
+ g_object_set (label, "yalign", 0.0, NULL);
+ gtk_widget_show (label);
+ break;
+ case BUTTON_STYLE_TEXT:
+ gtk_widget_hide (icon);
+ g_object_set (icon, "yalign", 0.5, NULL);
+ gtk_widget_show (label);
+ g_object_set (label, "yalign", 0.5, NULL);
+ break;
+ case BUTTON_STYLE_ICON:
+ gtk_widget_show (icon);
+ g_object_set (icon, "yalign", 0.5, NULL);
+ gtk_widget_hide (label);
+ g_object_set (label, "yalign", 0.5, NULL);
+ default:
+ break;
+ }
}
}
@@ -115,11 +121,12 @@ ctw_button_cb (GtkToggleButton *button, gpointer data)
{
MtData *mt = data;
- if (gtk_toggle_button_get_active (button)) {
- GSList *group;
+ if (gtk_toggle_button_get_active (button))
+ {
+ GSList *group;
- group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
- mt_service_set_click_type (mt->service, g_slist_index (group, button));
+ group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
+ mt_service_set_click_type (mt->service, g_slist_index (group, button));
}
}
@@ -128,12 +135,12 @@ ctw_context_menu (GtkWidget *widget, GdkEventButton *bev, gpointer data)
{
MtData *mt = data;
- if (bev->button == 3) {
- gtk_menu_popup (GTK_MENU (WID ("popup")),
- 0, 0, 0, 0, bev->button, bev->time);
- return TRUE;
+ if (bev->button == 3)
+ {
+ gtk_menu_popup (GTK_MENU (WID ("popup")),
+ 0, 0, 0, 0, bev->button, bev->time);
+ return TRUE;
}
-
return FALSE;
}
@@ -145,7 +152,7 @@ ctw_menu_toggled (GtkCheckMenuItem *item, gpointer data)
gint index;
if (!gtk_check_menu_item_get_active (item))
- return;
+ return;
group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (item));
index = g_slist_index (group, item);
@@ -180,14 +187,15 @@ mt_ctw_init (MtData *mt, gint x, gint y)
mt->ui = gtk_builder_new ();
gtk_builder_add_from_file (mt->ui, DATADIR "/mousetweaks.ui", &error);
- if (error) {
- g_print ("%s\n", error->message);
- g_error_free (error);
+ if (error)
+ {
+ g_print ("%s\n", error->message);
+ g_error_free (error);
- g_object_unref (mt->ui);
- mt->ui = NULL;
+ g_object_unref (mt->ui);
+ mt->ui = NULL;
- return FALSE;
+ return FALSE;
}
ctw = mt_ctw_get_window (mt);
@@ -195,21 +203,22 @@ mt_ctw_init (MtData *mt, gint x, gint y)
gtk_window_set_keep_above (GTK_WINDOW (ctw), TRUE);
g_signal_connect (ctw, "delete-event", G_CALLBACK (ctw_delete_cb), mt);
- for (i = 0; i < N_CLICK_TYPES; i++) {
- w = WID (b[i]);
- gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (w), FALSE);
- g_signal_connect (w, "toggled", G_CALLBACK (ctw_button_cb), mt);
- g_signal_connect (w, "button-press-event",
- G_CALLBACK (ctw_context_menu), mt);
+ for (i = 0; i < N_CLICK_TYPES; i++)
+ {
+ w = WID (b[i]);
+ gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (w), FALSE);
+ g_signal_connect (w, "toggled", G_CALLBACK (ctw_button_cb), mt);
+ g_signal_connect (w, "button-press-event",
+ G_CALLBACK (ctw_context_menu), mt);
}
g_signal_connect (WID ("text"), "toggled",
- G_CALLBACK (ctw_menu_toggled), mt);
+ G_CALLBACK (ctw_menu_toggled), mt);
g_signal_connect (WID ("icon"), "toggled",
- G_CALLBACK (ctw_menu_toggled), mt);
+ G_CALLBACK (ctw_menu_toggled), mt);
w = WID ("both");
g_signal_connect (w, "toggled",
- G_CALLBACK (ctw_menu_toggled), mt);
+ G_CALLBACK (ctw_menu_toggled), mt);
group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (w));
data = g_slist_nth_data (group, mt->style);
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (data), TRUE);
@@ -220,7 +229,7 @@ mt_ctw_init (MtData *mt, gint x, gint y)
mt_ctw_update_visibility (mt);
if (x != -1 && y != -1)
- gtk_window_move (GTK_WINDOW (ctw), x, y);
+ gtk_window_move (GTK_WINDOW (ctw), x, y);
return TRUE;
}
diff --git a/src/mt-ctw.h b/src/mt-ctw.h
index 3c41187..b4063ce 100644
--- a/src/mt-ctw.h
+++ b/src/mt-ctw.h
@@ -1,5 +1,5 @@
/*
- * Copyright © 2007-2009 Gerd Kohlberger <lowfi chello at>
+ * Copyright © 2007-2010 Gerd Kohlberger <gerdko gmail com>
*
* This file is part of Mousetweaks.
*
@@ -25,15 +25,15 @@
G_BEGIN_DECLS
gboolean mt_ctw_init (MtData *mt,
- gint x,
- gint y);
+ gint x,
+ gint y);
GtkWidget * mt_ctw_get_window (MtData *mt);
void mt_ctw_set_clicktype (MtData *mt,
- guint ct);
+ guint ct);
void mt_ctw_update_sensitivity (MtData *mt);
void mt_ctw_update_visibility (MtData *mt);
void mt_ctw_update_style (MtData *mt,
- gint style);
+ gint style);
G_END_DECLS
diff --git a/src/mt-cursor-manager.h b/src/mt-cursor-manager.h
index e68f214..95f62dc 100644
--- a/src/mt-cursor-manager.h
+++ b/src/mt-cursor-manager.h
@@ -26,15 +26,12 @@
G_BEGIN_DECLS
-#define MT_TYPE_CURSOR_MANAGER (mt_cursor_manager_get_type ())
-#define MT_CURSOR_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MT_TYPE_CURSOR_MANAGER, MtCursorManager))
-#define MT_CURSOR_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), MT_TYPE_CURSOR_MANAGER, MtCursorManagerClass))
-#define MT_IS_CURSOR_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MT_TYPE_CURSOR_MANAGER))
-#define MT_IS_CURSOR_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MT_TYPE_CURSOR_MANAGER))
-#define MT_CURSOR_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MT_TYPE_CURSOR_MANAGER, MtCursorManagerClass))
+#define MT_TYPE_CURSOR_MANAGER (mt_cursor_manager_get_type ())
+#define MT_CURSOR_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MT_TYPE_CURSOR_MANAGER, MtCursorManager))
+#define MT_IS_CURSOR_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MT_TYPE_CURSOR_MANAGER))
+typedef GObjectClass MtCursorManagerClass;
typedef struct _MtCursorManager MtCursorManager;
-typedef struct _MtCursorManagerClass MtCursorManagerClass;
typedef struct _MtCursorManagerPrivate MtCursorManagerPrivate;
struct _MtCursorManager
@@ -43,12 +40,8 @@ struct _MtCursorManager
MtCursorManagerPrivate *priv;
};
-struct _MtCursorManagerClass
-{
- GObjectClass parent;
-};
-
GType mt_cursor_manager_get_type (void) G_GNUC_CONST;
+
MtCursorManager * mt_cursor_manager_get_default (void);
MtCursor * mt_cursor_manager_current_cursor (MtCursorManager *manager);
MtCursor * mt_cursor_manager_lookup_cursor (MtCursorManager *manager,
diff --git a/src/mt-cursor.c b/src/mt-cursor.c
index d90031a..8057b5d 100644
--- a/src/mt-cursor.c
+++ b/src/mt-cursor.c
@@ -1,5 +1,5 @@
/*
- * Copyright © 2008-2009 Gerd Kohlberger <lowfi chello at>
+ * Copyright © 2008-2010 Gerd Kohlberger <gerdko gmail com>
*
* This file is part of Mousetweaks.
*
@@ -21,33 +21,24 @@
#include "mt-cursor.h"
-struct _MtCursorPrivate {
- gchar *name;
- guchar *image;
- gushort width;
- gushort height;
- gushort xhot;
- gushort yhot;
+struct _MtCursorPrivate
+{
+ gchar *name;
+ guchar *image;
+ gushort width;
+ gushort height;
+ gushort xhot;
+ gushort yhot;
};
G_DEFINE_TYPE (MtCursor, mt_cursor, G_TYPE_OBJECT)
-static void mt_cursor_finalize (GObject *object);
-
-static void
-mt_cursor_class_init (MtCursorClass *klass)
-{
- G_OBJECT_CLASS (klass)->finalize = mt_cursor_finalize;
-
- g_type_class_add_private (klass, sizeof (MtCursorPrivate));
-}
-
static void
mt_cursor_init (MtCursor *cursor)
{
cursor->priv = G_TYPE_INSTANCE_GET_PRIVATE (cursor,
- MT_TYPE_CURSOR,
- MtCursorPrivate);
+ MT_TYPE_CURSOR,
+ MtCursorPrivate);
}
static void
@@ -61,13 +52,21 @@ mt_cursor_finalize (GObject *object)
G_OBJECT_CLASS (mt_cursor_parent_class)->finalize (object);
}
+static void
+mt_cursor_class_init (MtCursorClass *klass)
+{
+ G_OBJECT_CLASS (klass)->finalize = mt_cursor_finalize;
+
+ g_type_class_add_private (klass, sizeof (MtCursorPrivate));
+}
+
MtCursor *
mt_cursor_new (const gchar *name,
- guchar *image,
- gushort width,
- gushort height,
- gushort xhot,
- gushort yhot)
+ guchar *image,
+ gushort width,
+ gushort height,
+ gushort xhot,
+ gushort yhot)
{
MtCursor *cursor;
MtCursorPrivate *priv;
@@ -78,7 +77,7 @@ mt_cursor_new (const gchar *name,
g_return_val_if_fail (xhot <= width && yhot <= height, NULL);
if (*name == 0)
- return NULL;
+ return NULL;
cursor = g_object_new (MT_TYPE_CURSOR, NULL);
priv = cursor->priv;
@@ -122,26 +121,26 @@ mt_cursor_get_image_copy (MtCursor *cursor)
void
mt_cursor_get_hotspot (MtCursor *cursor,
- gushort *xhot,
- gushort *yhot)
+ gushort *xhot,
+ gushort *yhot)
{
g_return_if_fail (MT_IS_CURSOR (cursor));
if (xhot)
- *xhot = cursor->priv->xhot;
+ *xhot = cursor->priv->xhot;
if (yhot)
- *yhot = cursor->priv->yhot;
+ *yhot = cursor->priv->yhot;
}
void
mt_cursor_get_dimension (MtCursor *cursor,
- gushort *width,
- gushort *height)
+ gushort *width,
+ gushort *height)
{
g_return_if_fail (MT_IS_CURSOR (cursor));
if (width)
- *width = cursor->priv->width;
+ *width = cursor->priv->width;
if (height)
- *height = cursor->priv->height;
+ *height = cursor->priv->height;
}
diff --git a/src/mt-cursor.h b/src/mt-cursor.h
index 5e37152..89f5ab8 100644
--- a/src/mt-cursor.h
+++ b/src/mt-cursor.h
@@ -1,5 +1,5 @@
/*
- * Copyright © 2008-2009 Gerd Kohlberger <lowfi chello at>
+ * Copyright © 2008-2010 Gerd Kohlberger <gerdko gmail com>
*
* This file is part of Mousetweaks.
*
@@ -24,38 +24,38 @@
G_BEGIN_DECLS
-#define MT_TYPE_CURSOR (mt_cursor_get_type ())
-#define MT_CURSOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MT_TYPE_CURSOR, MtCursor))
-#define MT_CURSOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), MT_TYPE_CURSOR, MtCursorClass))
-#define MT_IS_CURSOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MT_TYPE_CURSOR))
-#define MT_IS_CURSOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MT_TYPE_CURSOR))
-#define MT_CURSOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MT_TYPE_CURSOR, MtCursorClass))
+#define MT_TYPE_CURSOR (mt_cursor_get_type ())
+#define MT_CURSOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MT_TYPE_CURSOR, MtCursor))
+#define MT_IS_CURSOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MT_TYPE_CURSOR))
typedef GObjectClass MtCursorClass;
typedef struct _MtCursor MtCursor;
typedef struct _MtCursorPrivate MtCursorPrivate;
-struct _MtCursor {
+struct _MtCursor
+{
GObject parent;
MtCursorPrivate *priv;
};
GType mt_cursor_get_type (void) G_GNUC_CONST;
-MtCursor * mt_cursor_new (const gchar *name,
- guchar *image,
- gushort width,
- gushort height,
- gushort xhot,
- gushort yhot);
+
+MtCursor * mt_cursor_new (const gchar *name,
+ guchar *image,
+ gushort width,
+ gushort height,
+ gushort xhot,
+ gushort yhot);
+
const gchar * mt_cursor_get_name (MtCursor *cursor);
const guchar * mt_cursor_get_image (MtCursor *cursor);
guchar * mt_cursor_get_image_copy (MtCursor *cursor);
void mt_cursor_get_hotspot (MtCursor *cursor,
- gushort *xhot,
- gushort *yhot);
+ gushort *xhot,
+ gushort *yhot);
void mt_cursor_get_dimension (MtCursor *cursor,
- gushort *width,
- gushort *height);
+ gushort *width,
+ gushort *height);
G_END_DECLS
diff --git a/src/mt-listener.h b/src/mt-listener.h
index d5e9f0a..29681ed 100644
--- a/src/mt-listener.h
+++ b/src/mt-listener.h
@@ -57,6 +57,7 @@ struct _MtEvent
GType mt_event_get_type (void) G_GNUC_CONST;
GType mt_listener_get_type (void) G_GNUC_CONST;
+
MtListener * mt_listener_get_default (void);
G_END_DECLS
diff --git a/src/mt-main.c b/src/mt-main.c
index bd19111..b6e5912 100644
--- a/src/mt-main.c
+++ b/src/mt-main.c
@@ -36,14 +36,16 @@
#include "mt-main.h"
#include "mt-listener.h"
-enum {
+enum
+{
PRESS = 0,
RELEASE,
CLICK,
DOUBLE_CLICK
};
-typedef struct _MtCliArgs {
+typedef struct _MtCliArgs
+{
gdouble ssc_time;
gdouble dwell_time;
gchar *mode;
@@ -71,10 +73,10 @@ mt_main_current_screen (MtData *mt)
GdkScreen *screen;
if (mt->n_screens > 1)
- gdk_display_get_pointer (gdk_display_get_default (),
- &screen, NULL, NULL, NULL);
+ gdk_display_get_pointer (gdk_display_get_default (),
+ &screen, NULL, NULL, NULL);
else
- screen = gdk_screen_get_default ();
+ screen = gdk_screen_get_default ();
return screen;
}
@@ -91,11 +93,12 @@ mt_main_generate_motion_event (GdkScreen *screen, gint x, gint y)
static guint
mt_main_check_mouse_orientation (MtData *mt, guint button)
{
- if (mt->left_handed) {
- if (button == 1)
- return 3;
- else if (button == 3)
- return 1;
+ if (mt->left_handed)
+ {
+ if (button == 1)
+ return 3;
+ else if (button == 3)
+ return 1;
}
return button;
}
@@ -112,7 +115,8 @@ mt_main_generate_button_event (MtData *mt,
button = mt_main_check_mouse_orientation (mt, button);
gdk_error_trap_push ();
- switch (type) {
+ switch (type)
+ {
case PRESS:
XTestFakeButtonEvent (dpy, button, True, delay);
break;
@@ -145,9 +149,10 @@ mt_main_set_cursor (MtData *mt, GdkCursorType type)
gint i;
cursor = gdk_cursor_new (type);
- for (i = 0; i < mt->n_screens; ++i) {
- screen = gdk_display_get_screen (gdk_display_get_default (), i);
- gdk_window_set_cursor (gdk_screen_get_root_window (screen), cursor);
+ for (i = 0; i < mt->n_screens; ++i)
+ {
+ screen = gdk_display_get_screen (gdk_display_get_default (), i);
+ gdk_window_set_cursor (gdk_screen_get_root_window (screen), cursor);
}
gdk_cursor_unref (cursor);
}
@@ -169,38 +174,43 @@ mt_main_do_dwell_click (MtData *mt)
click_type = mt_service_get_click_type (mt->service);
if (mt->dwell_mode == DWELL_MODE_GESTURE && !mt->dwell_drag_started)
- mt_main_generate_motion_event (mt_main_current_screen (mt),
- mt->pointer_x, mt->pointer_y);
+ {
+ mt_main_generate_motion_event (mt_main_current_screen (mt),
+ mt->pointer_x,
+ mt->pointer_y);
+ }
switch (click_type)
{
- case DWELL_CLICK_TYPE_SINGLE:
- mt_main_generate_button_event (mt, 1, CLICK, 60);
- break;
- case DWELL_CLICK_TYPE_DOUBLE:
- mt_main_generate_button_event (mt, 1, DOUBLE_CLICK, 10);
- dwell_restore_single_click (mt);
- break;
- case DWELL_CLICK_TYPE_DRAG:
- if (!mt->dwell_drag_started) {
- mt_main_generate_button_event (mt, 1, PRESS, CurrentTime);
- mt_main_set_cursor (mt, GDK_FLEUR);
- mt->dwell_drag_started = TRUE;
- }
- else {
- mt_main_generate_button_event (mt, 1, RELEASE, CurrentTime);
- mt_main_set_cursor (mt, GDK_LEFT_PTR);
- mt->dwell_drag_started = FALSE;
- dwell_restore_single_click (mt);
- }
- break;
- case DWELL_CLICK_TYPE_RIGHT:
- mt_main_generate_button_event (mt, 3, CLICK, 10);
- dwell_restore_single_click (mt);
- break;
- default:
- g_warning ("Unknown click-type.");
- break;
+ case DWELL_CLICK_TYPE_SINGLE:
+ mt_main_generate_button_event (mt, 1, CLICK, 60);
+ break;
+ case DWELL_CLICK_TYPE_DOUBLE:
+ mt_main_generate_button_event (mt, 1, DOUBLE_CLICK, 10);
+ dwell_restore_single_click (mt);
+ break;
+ case DWELL_CLICK_TYPE_DRAG:
+ if (!mt->dwell_drag_started)
+ {
+ mt_main_generate_button_event (mt, 1, PRESS, CurrentTime);
+ mt_main_set_cursor (mt, GDK_FLEUR);
+ mt->dwell_drag_started = TRUE;
+ }
+ else
+ {
+ mt_main_generate_button_event (mt, 1, RELEASE, CurrentTime);
+ mt_main_set_cursor (mt, GDK_LEFT_PTR);
+ mt->dwell_drag_started = FALSE;
+ dwell_restore_single_click (mt);
+ }
+ break;
+ case DWELL_CLICK_TYPE_RIGHT:
+ mt_main_generate_button_event (mt, 3, CLICK, 10);
+ dwell_restore_single_click (mt);
+ break;
+ default:
+ g_warning ("Unknown click-type.");
+ break;
}
}
@@ -221,45 +231,50 @@ mt_main_analyze_gesture (MtData *mt)
gint x, y, gd, i, dx, dy;
if (mt_service_get_click_type (mt->service) == DWELL_CLICK_TYPE_DRAG)
- return TRUE;
+ return TRUE;
gdk_display_get_pointer (gdk_display_get_default (), NULL, &x, &y, NULL);
if (below_threshold (mt, x, y))
- return FALSE;
+ return FALSE;
dx = ABS (x - mt->pointer_x);
dy = ABS (y - mt->pointer_y);
/* find direction */
if (x < mt->pointer_x)
- if (y < mt->pointer_y)
- if (dx < dy)
- gd = DIRECTION_UP;
- else
- gd = DIRECTION_LEFT;
- else
- if (dx < dy)
- gd = DIRECTION_DOWN;
- else
- gd = DIRECTION_LEFT;
+ {
+ if (y < mt->pointer_y)
+ if (dx < dy)
+ gd = DIRECTION_UP;
+ else
+ gd = DIRECTION_LEFT;
+ else
+ if (dx < dy)
+ gd = DIRECTION_DOWN;
+ else
+ gd = DIRECTION_LEFT;
+ }
else
- if (y < mt->pointer_y)
- if (dx < dy)
- gd = DIRECTION_UP;
- else
- gd = DIRECTION_RIGHT;
- else
- if (dx < dy)
- gd = DIRECTION_DOWN;
- else
- gd = DIRECTION_RIGHT;
-
+ {
+ if (y < mt->pointer_y)
+ if (dx < dy)
+ gd = DIRECTION_UP;
+ else
+ gd = DIRECTION_RIGHT;
+ else
+ if (dx < dy)
+ gd = DIRECTION_DOWN;
+ else
+ gd = DIRECTION_RIGHT;
+ }
/* get click type for direction */
- for (i = 0; i < N_CLICK_TYPES; i++) {
- if (mt->dwell_dirs[i] == gd) {
- mt_service_set_click_type (mt->service, i);
- return TRUE;
- }
+ for (i = 0; i < N_CLICK_TYPES; i++)
+ {
+ if (mt->dwell_dirs[i] == gd)
+ {
+ mt_service_set_click_type (mt->service, i);
+ return TRUE;
+ }
}
return FALSE;
}
@@ -275,9 +290,9 @@ mt_main_draw_line (MtData *mt, gint x1, gint y1, gint x2, gint y2)
gdk_gc_set_subwindow (gc, GDK_INCLUDE_INFERIORS);
gdk_gc_set_function (gc, GDK_INVERT);
gdk_gc_set_line_attributes (gc, 1,
- GDK_LINE_SOLID,
- GDK_CAP_ROUND,
- GDK_JOIN_ROUND);
+ GDK_LINE_SOLID,
+ GDK_CAP_ROUND,
+ GDK_JOIN_ROUND);
gdk_draw_arc (root, gc, TRUE, x1 - 4, y1 - 4, 8, 8, 0, 23040);
gdk_draw_line (root, gc, x1, y1, x2, y2);
g_object_unref (gc);
@@ -289,17 +304,19 @@ dwell_start_gesture (MtData *mt)
GdkCursor *cursor;
GdkWindow *root;
- if (mt->override_cursor) {
- cursor = gdk_cursor_new (GDK_CROSS);
- root = gdk_screen_get_root_window (mt_main_current_screen (mt));
- gdk_pointer_grab (root, FALSE,
- GDK_POINTER_MOTION_MASK,
- NULL, cursor,
- gtk_get_current_event_time ());
- gdk_cursor_unref (cursor);
+ if (mt->override_cursor)
+ {
+ cursor = gdk_cursor_new (GDK_CROSS);
+ root = gdk_screen_get_root_window (mt_main_current_screen (mt));
+ gdk_pointer_grab (root, FALSE,
+ GDK_POINTER_MOTION_MASK,
+ NULL, cursor,
+ gtk_get_current_event_time ());
+ gdk_cursor_unref (cursor);
}
- else {
- mt_main_set_cursor (mt, GDK_CROSS);
+ else
+ {
+ mt_main_set_cursor (mt, GDK_CROSS);
}
mt->dwell_gesture_started = TRUE;
@@ -310,16 +327,17 @@ static void
dwell_stop_gesture (MtData *mt)
{
if (mt->override_cursor)
- gdk_pointer_ungrab (gtk_get_current_event_time ());
+ gdk_pointer_ungrab (gtk_get_current_event_time ());
else
- mt_main_set_cursor (mt, GDK_LEFT_PTR);
+ mt_main_set_cursor (mt, GDK_LEFT_PTR);
- if (mt->x_old > -1 && mt->y_old > -1) {
- mt_main_draw_line (mt,
- mt->pointer_x, mt->pointer_y,
- mt->x_old, mt->y_old);
- mt->x_old = -1;
- mt->y_old = -1;
+ if (mt->x_old > -1 && mt->y_old > -1)
+ {
+ mt_main_draw_line (mt,
+ mt->pointer_x, mt->pointer_y,
+ mt->x_old, mt->y_old);
+ mt->x_old = -1;
+ mt->y_old = -1;
}
mt->dwell_gesture_started = FALSE;
@@ -333,22 +351,28 @@ dwell_timer_finished (MtTimer *timer, gpointer data)
mt_cursor_manager_restore_all (mt_cursor_manager_get_default ());
- if (mt->dwell_mode == DWELL_MODE_CTW) {
- mt_main_do_dwell_click (mt);
+ if (mt->dwell_mode == DWELL_MODE_CTW)
+ {
+ mt_main_do_dwell_click (mt);
}
- else {
- if (mt->dwell_gesture_started) {
- dwell_stop_gesture (mt);
-
- if (mt_main_analyze_gesture (mt))
- mt_main_do_dwell_click (mt);
- }
- /* if a drag action is in progress stop it */
- else if (mt->dwell_drag_started) {
- mt_main_do_dwell_click (mt);
- }
- else
- dwell_start_gesture (mt);
+ else
+ {
+ if (mt->dwell_gesture_started)
+ {
+ dwell_stop_gesture (mt);
+
+ if (mt_main_analyze_gesture (mt))
+ mt_main_do_dwell_click (mt);
+ }
+ /* if a drag action is in progress stop it */
+ else if (mt->dwell_drag_started)
+ {
+ mt_main_do_dwell_click (mt);
+ }
+ else
+ {
+ dwell_start_gesture (mt);
+ }
}
}
@@ -368,17 +392,19 @@ mt_main_do_secondary_click (MtData *mt)
static void
mt_dwell_click_cancel (MtData *mt)
{
- if (mt->dwell_gesture_started) {
- dwell_stop_gesture (mt);
- return;
+ if (mt->dwell_gesture_started)
+ {
+ dwell_stop_gesture (mt);
+ return;
}
mt_timer_stop (mt->dwell_timer);
mt_cursor_manager_restore_all (mt_cursor_manager_get_default ());
- if (mt->dwell_drag_started) {
- mt_main_set_cursor (mt, GDK_LEFT_PTR);
- mt->dwell_drag_started = FALSE;
+ if (mt->dwell_drag_started)
+ {
+ mt_main_set_cursor (mt, GDK_LEFT_PTR);
+ mt->dwell_drag_started = FALSE;
}
dwell_restore_single_click (mt);
@@ -386,85 +412,95 @@ mt_dwell_click_cancel (MtData *mt)
static void
global_motion_event (MtListener *listener,
- MtEvent *event,
- gpointer data)
+ MtEvent *event,
+ gpointer data)
{
MtData *mt = data;
- if (mt->ssc_enabled) {
- if (!below_threshold (mt, event->x, event->y)) {
- mt_cursor_manager_restore_all (mt_cursor_manager_get_default ());
+ if (mt->ssc_enabled)
+ {
+ if (!below_threshold (mt, event->x, event->y))
+ {
+ mt_cursor_manager_restore_all (mt_cursor_manager_get_default ());
- if (mt_timer_is_running (mt->ssc_timer))
- mt_timer_stop (mt->ssc_timer);
+ if (mt_timer_is_running (mt->ssc_timer))
+ mt_timer_stop (mt->ssc_timer);
- if (mt->ssc_finished)
- mt->ssc_finished = FALSE;
- }
+ if (mt->ssc_finished)
+ mt->ssc_finished = FALSE;
+ }
}
- if (mt->dwell_enabled) {
- if (!below_threshold (mt, event->x, event->y) &&
- !mt->dwell_gesture_started) {
- mt->pointer_x = event->x;
- mt->pointer_y = event->y;
- mt_timer_start (mt->dwell_timer);
- }
-
- if (mt->dwell_gesture_started) {
- if (mt->x_old > -1 && mt->y_old > -1) {
- mt_main_draw_line (mt,
- mt->pointer_x, mt->pointer_y,
- mt->x_old, mt->y_old);
- }
- mt_main_draw_line (mt,
- mt->pointer_x, mt->pointer_y,
- event->x, event->y);
- mt->x_old = event->x;
- mt->y_old = event->y;
- }
+ if (mt->dwell_enabled)
+ {
+ if (!below_threshold (mt, event->x, event->y) &&
+ !mt->dwell_gesture_started)
+ {
+ mt->pointer_x = event->x;
+ mt->pointer_y = event->y;
+ mt_timer_start (mt->dwell_timer);
+ }
+
+ if (mt->dwell_gesture_started)
+ {
+ if (mt->x_old > -1 && mt->y_old > -1)
+ {
+ mt_main_draw_line (mt,
+ mt->pointer_x, mt->pointer_y,
+ mt->x_old, mt->y_old);
+ }
+ mt_main_draw_line (mt,
+ mt->pointer_x, mt->pointer_y,
+ event->x, event->y);
+ mt->x_old = event->x;
+ mt->y_old = event->y;
+ }
}
}
static void
global_button_event (MtListener *listener,
- MtEvent *event,
- gpointer data)
+ MtEvent *event,
+ gpointer data)
{
MtData *mt = data;
- if (mt->ssc_enabled && event->button == 1) {
- if (event->type == MT_EVENT_BUTTON_PRESS) {
- mt->pointer_x = event->x;
- mt->pointer_y = event->y;
- mt_timer_start (mt->ssc_timer);
- }
- else {
- mt_cursor_manager_restore_all (mt_cursor_manager_get_default ());
-
- if (mt->ssc_finished)
- mt_main_do_secondary_click (mt);
- else
- mt_timer_stop (mt->ssc_timer);
- }
+ if (mt->ssc_enabled && event->button == 1)
+ {
+ if (event->type == MT_EVENT_BUTTON_PRESS)
+ {
+ mt->pointer_x = event->x;
+ mt->pointer_y = event->y;
+ mt_timer_start (mt->ssc_timer);
+ }
+ else
+ {
+ mt_cursor_manager_restore_all (mt_cursor_manager_get_default ());
+
+ if (mt->ssc_finished)
+ mt_main_do_secondary_click (mt);
+ else
+ mt_timer_stop (mt->ssc_timer);
+ }
}
/*
* cancel a dwell-click in progress if a physical button
* is pressed - useful for mixed use-cases and testing
*/
if ((event->type == MT_EVENT_BUTTON_PRESS && mt_timer_is_running (mt->dwell_timer)) ||
- (event->type == MT_EVENT_BUTTON_RELEASE && mt->dwell_drag_started)) {
- mt_dwell_click_cancel (mt);
+ (event->type == MT_EVENT_BUTTON_RELEASE && mt->dwell_drag_started))
+ {
+ mt_dwell_click_cancel (mt);
}
}
static gboolean
cursor_overlay_time (MtData *mt,
- guchar *image,
- gint width,
- gint height,
- MtTimer *timer,
- gdouble time)
+ guchar *image,
+ gint width,
+ gint height,
+ MtTimer *timer,
+ gdouble time)
{
GtkWidget *ctw;
GdkColor c;
@@ -474,16 +510,17 @@ cursor_overlay_time (MtData *mt,
gdouble target;
surface = cairo_image_surface_create_for_data (image,
- CAIRO_FORMAT_ARGB32,
- width, height,
- width * 4);
+ CAIRO_FORMAT_ARGB32,
+ width, height,
+ width * 4);
if (cairo_surface_status (surface) != CAIRO_STATUS_SUCCESS)
- return FALSE;
+ return FALSE;
cr = cairo_create (surface);
- if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) {
- cairo_surface_destroy (surface);
- return FALSE;
+ if (cairo_status (cr) != CAIRO_STATUS_SUCCESS)
+ {
+ cairo_surface_destroy (surface);
+ return FALSE;
}
ctw = mt_ctw_get_window (mt);
@@ -494,10 +531,10 @@ cursor_overlay_time (MtData *mt,
cairo_set_operator (cr, CAIRO_OPERATOR_ATOP);
cairo_rectangle (cr, 0, 0, width, height / (target / time));
cairo_set_source_rgba (cr,
- c.red / 65535.,
- c.green / 65535.,
- c.blue / 65535.,
- 0.60);
+ c.red / 65535.,
+ c.green / 65535.,
+ c.blue / 65535.,
+ 0.60);
cairo_fill (cr);
cairo_destroy (cr);
cairo_surface_destroy (surface);
@@ -507,48 +544,49 @@ cursor_overlay_time (MtData *mt,
static void
mt_main_update_cursor (MtData *mt,
- MtTimer *timer,
- gdouble time)
+ MtTimer *timer,
+ gdouble time)
{
guchar *image;
gushort width, height;
image = mt_cursor_get_image_copy (mt->cursor);
if (!image)
- return;
+ return;
mt_cursor_get_dimension (mt->cursor, &width, &height);
- if (cursor_overlay_time (mt, image, width, height, timer, time)) {
- MtCursorManager *manager;
- MtCursor *new_cursor;
- const gchar *name;
- gushort xhot, yhot;
-
- name = mt_cursor_get_name (mt->cursor);
- mt_cursor_get_hotspot (mt->cursor, &xhot, &yhot);
- new_cursor = mt_cursor_new (name, image, width, height, xhot, yhot);
- manager = mt_cursor_manager_get_default ();
- mt_cursor_manager_set_cursor (manager, new_cursor);
- g_object_unref (new_cursor);
+ if (cursor_overlay_time (mt, image, width, height, timer, time))
+ {
+ MtCursorManager *manager;
+ MtCursor *new_cursor;
+ const gchar *name;
+ gushort xhot, yhot;
+
+ name = mt_cursor_get_name (mt->cursor);
+ mt_cursor_get_hotspot (mt->cursor, &xhot, &yhot);
+ new_cursor = mt_cursor_new (name, image, width, height, xhot, yhot);
+ manager = mt_cursor_manager_get_default ();
+ mt_cursor_manager_set_cursor (manager, new_cursor);
+ g_object_unref (new_cursor);
}
g_free (image);
}
static void
mt_main_timer_tick (MtTimer *timer,
- gdouble time,
- gpointer data)
+ gdouble time,
+ gpointer data)
{
MtData *mt = data;
if (mt->animate_cursor && mt->cursor)
- mt_main_update_cursor (mt, timer, time);
+ mt_main_update_cursor (mt, timer, time);
}
static void
cursor_cache_cleared (MtCursorManager *manager,
- gpointer data)
+ gpointer data)
{
MtData *mt = data;
@@ -557,13 +595,13 @@ cursor_cache_cleared (MtCursorManager *manager,
static void
cursor_changed (MtCursorManager *manager,
- const gchar *name,
- gpointer data)
+ const gchar *name,
+ gpointer data)
{
MtData *mt = data;
if (!mt->dwell_gesture_started)
- mt->override_cursor = !g_str_equal (name, "left_ptr");
+ mt->override_cursor = !g_str_equal (name, "left_ptr");
mt->cursor = mt_cursor_manager_lookup_cursor (manager, name);
}
@@ -576,59 +614,80 @@ signal_handler (int sig)
static void
gconf_value_changed (GConfClient *client,
- const gchar *key,
- GConfValue *value,
- gpointer data)
+ const gchar *key,
+ GConfValue *value,
+ gpointer data)
{
MtData *mt = data;
if (g_str_equal (key, OPT_THRESHOLD) && value->type == GCONF_VALUE_INT)
- mt->threshold = gconf_value_get_int (value);
+ {
+ mt->threshold = gconf_value_get_int (value);
+ }
else if (g_str_equal (key, OPT_SSC) && value->type == GCONF_VALUE_BOOL)
- mt->ssc_enabled = gconf_value_get_bool (value);
+ {
+ mt->ssc_enabled = gconf_value_get_bool (value);
+ }
else if (g_str_equal (key, OPT_SSC_T) && value->type == GCONF_VALUE_FLOAT)
- mt_timer_set_target (mt->ssc_timer, gconf_value_get_float (value));
- else if (g_str_equal (key, OPT_DWELL) && value->type == GCONF_VALUE_BOOL) {
- mt->dwell_enabled = gconf_value_get_bool (value);
- mt_ctw_update_sensitivity (mt);
- mt_ctw_update_visibility (mt);
+ {
+ mt_timer_set_target (mt->ssc_timer, gconf_value_get_float (value));
+ }
+ else if (g_str_equal (key, OPT_DWELL) && value->type == GCONF_VALUE_BOOL)
+ {
+ mt->dwell_enabled = gconf_value_get_bool (value);
+ mt_ctw_update_sensitivity (mt);
+ mt_ctw_update_visibility (mt);
}
else if (g_str_equal (key, OPT_DWELL_T) && value->type == GCONF_VALUE_FLOAT)
- mt_timer_set_target (mt->dwell_timer, gconf_value_get_float (value));
- else if (g_str_equal (key, OPT_CTW) && value->type == GCONF_VALUE_BOOL) {
- mt->dwell_show_ctw = gconf_value_get_bool (value);
- mt_ctw_update_visibility (mt);
+ {
+ mt_timer_set_target (mt->dwell_timer, gconf_value_get_float (value));
}
- else if (g_str_equal (key, OPT_MODE) && value->type == GCONF_VALUE_INT) {
- mt->dwell_mode = gconf_value_get_int (value);
- mt_ctw_update_sensitivity (mt);
+ else if (g_str_equal (key, OPT_CTW) && value->type == GCONF_VALUE_BOOL)
+ {
+ mt->dwell_show_ctw = gconf_value_get_bool (value);
+ mt_ctw_update_visibility (mt);
}
- else if (g_str_equal (key, OPT_STYLE) && value->type == GCONF_VALUE_INT) {
- mt->style = gconf_value_get_int (value);
- mt_ctw_update_style (mt, mt->style);
+ else if (g_str_equal (key, OPT_MODE) && value->type == GCONF_VALUE_INT)
+ {
+ mt->dwell_mode = gconf_value_get_int (value);
+ mt_ctw_update_sensitivity (mt);
+ }
+ else if (g_str_equal (key, OPT_STYLE) && value->type == GCONF_VALUE_INT)
+ {
+ mt->style = gconf_value_get_int (value);
+ mt_ctw_update_style (mt, mt->style);
}
else if (g_str_equal (key, OPT_G_SINGLE) && value->type == GCONF_VALUE_INT)
- mt->dwell_dirs[DWELL_CLICK_TYPE_SINGLE] = gconf_value_get_int (value);
+ {
+ mt->dwell_dirs[DWELL_CLICK_TYPE_SINGLE] = gconf_value_get_int (value);
+ }
else if (g_str_equal (key, OPT_G_DOUBLE) && value->type == GCONF_VALUE_INT)
- mt->dwell_dirs[DWELL_CLICK_TYPE_DOUBLE] = gconf_value_get_int (value);
+ {
+ mt->dwell_dirs[DWELL_CLICK_TYPE_DOUBLE] = gconf_value_get_int (value);
+ }
else if (g_str_equal (key, OPT_G_DRAG) && value->type == GCONF_VALUE_INT)
- mt->dwell_dirs[DWELL_CLICK_TYPE_DRAG] = gconf_value_get_int (value);
+ {
+ mt->dwell_dirs[DWELL_CLICK_TYPE_DRAG] = gconf_value_get_int (value);
+ }
else if (g_str_equal (key, OPT_G_RIGHT) && value->type == GCONF_VALUE_INT)
- mt->dwell_dirs[DWELL_CLICK_TYPE_RIGHT] = gconf_value_get_int (value);
- else if (g_str_equal (key, OPT_ANIMATE) && value->type == GCONF_VALUE_BOOL) {
- MtCursorManager *manager;
+ {
+ mt->dwell_dirs[DWELL_CLICK_TYPE_RIGHT] = gconf_value_get_int (value);
+ }
+ else if (g_str_equal (key, OPT_ANIMATE) && value->type == GCONF_VALUE_BOOL)
+ {
+ MtCursorManager *manager;
- manager = mt_cursor_manager_get_default ();
- mt->animate_cursor = gconf_value_get_bool (value);
+ manager = mt_cursor_manager_get_default ();
+ mt->animate_cursor = gconf_value_get_bool (value);
- if (mt->animate_cursor)
- mt->cursor = mt_cursor_manager_current_cursor (manager);
- else
- mt_cursor_manager_restore_all (manager);
+ if (mt->animate_cursor)
+ mt->cursor = mt_cursor_manager_current_cursor (manager);
+ else
+ mt_cursor_manager_restore_all (manager);
}
- else if (g_str_equal (key, GNOME_MOUSE_ORIENT) &&
- value->type == GCONF_VALUE_BOOL) {
- mt->left_handed = gconf_value_get_bool (value);
+ else if (g_str_equal (key, GNOME_MOUSE_ORIENT) && value->type == GCONF_VALUE_BOOL)
+ {
+ mt->left_handed = gconf_value_get_bool (value);
}
}
@@ -651,16 +710,18 @@ get_gconf_options (MtData *mt)
mt_timer_set_target (mt->dwell_timer, val);
mt->dwell_dirs[DWELL_CLICK_TYPE_SINGLE] =
- gconf_client_get_int (mt->client, OPT_G_SINGLE, NULL);
+ gconf_client_get_int (mt->client, OPT_G_SINGLE, NULL);
mt->dwell_dirs[DWELL_CLICK_TYPE_DOUBLE] =
- gconf_client_get_int (mt->client, OPT_G_DOUBLE, NULL);
+ gconf_client_get_int (mt->client, OPT_G_DOUBLE, NULL);
mt->dwell_dirs[DWELL_CLICK_TYPE_DRAG] =
- gconf_client_get_int (mt->client, OPT_G_DRAG, NULL);
+ gconf_client_get_int (mt->client, OPT_G_DRAG, NULL);
mt->dwell_dirs[DWELL_CLICK_TYPE_RIGHT] =
- gconf_client_get_int (mt->client, OPT_G_RIGHT, NULL);
+ gconf_client_get_int (mt->client, OPT_G_RIGHT, NULL);
/* mouse orientation */
- mt->left_handed = gconf_client_get_bool (mt->client, GNOME_MOUSE_ORIENT, NULL);
+ mt->left_handed = gconf_client_get_bool (mt->client,
+ GNOME_MOUSE_ORIENT,
+ NULL);
}
static MtData *
@@ -683,23 +744,23 @@ mt_data_init (void)
mt->client = gconf_client_get_default ();
gconf_client_add_dir (mt->client, GNOME_MOUSE_DIR,
- GCONF_CLIENT_PRELOAD_NONE, NULL);
+ GCONF_CLIENT_PRELOAD_NONE, NULL);
gconf_client_add_dir (mt->client, MT_GCONF_HOME,
- GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
+ GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
g_signal_connect (mt->client, "value_changed",
- G_CALLBACK (gconf_value_changed), mt);
+ G_CALLBACK (gconf_value_changed), mt);
mt->ssc_timer = mt_timer_new ();
g_signal_connect (mt->ssc_timer, "finished",
- G_CALLBACK (ssc_timer_finished), mt);
+ G_CALLBACK (ssc_timer_finished), mt);
g_signal_connect (mt->ssc_timer, "tick",
- G_CALLBACK (mt_main_timer_tick), mt);
+ G_CALLBACK (mt_main_timer_tick), mt);
mt->dwell_timer = mt_timer_new ();
g_signal_connect (mt->dwell_timer, "finished",
- G_CALLBACK (dwell_timer_finished), mt);
+ G_CALLBACK (dwell_timer_finished), mt);
g_signal_connect (mt->dwell_timer, "tick",
- G_CALLBACK (mt_main_timer_tick), mt);
+ G_CALLBACK (mt_main_timer_tick), mt);
mt->service = mt_service_get_default ();
mt->n_screens = gdk_display_get_n_screens (gdk_display_get_default ());
@@ -718,9 +779,10 @@ mt_data_free (MtData *mt)
g_object_unref (mt->service);
g_object_unref (mt->client);
- if (mt->ui) {
- gtk_widget_destroy (mt_ctw_get_window (mt));
- g_object_unref (mt->ui);
+ if (mt->ui)
+ {
+ gtk_widget_destroy (mt_ctw_get_window (mt));
+ g_object_unref (mt->ui);
}
g_slice_free (MtData, mt);
@@ -731,34 +793,35 @@ mt_parse_options (int *argc, char ***argv)
{
MtCliArgs ca;
GOptionContext *context;
- GOptionEntry entries[] = {
- {"dwell", 0, 0, G_OPTION_ARG_NONE, &ca.dwell_enabled,
- N_("Enable dwell click"), 0},
- {"ssc", 0, 0, G_OPTION_ARG_NONE, &ca.ssc_enabled,
- N_("Enable simulated secondary click"), 0},
- {"dwell-time", 0, 0, G_OPTION_ARG_DOUBLE, &ca.dwell_time,
- N_("Time to wait before a dwell click"), "[0.2-3.0]"},
- {"ssc-time", 0, 0, G_OPTION_ARG_DOUBLE, &ca.ssc_time,
- N_("Time to wait before a simulated secondary click"), "[0.5-3.0]"},
- {"dwell-mode", 'm', 0, G_OPTION_ARG_STRING, &ca.mode,
- N_("Set the active dwell mode"), "[window|gesture]"},
- {"show-ctw", 'c', 0, G_OPTION_ARG_NONE, &ca.ctw,
- N_("Show a click-type window"), 0},
- {"ctw-x", 'x', 0, G_OPTION_ARG_INT, &ca.pos_x,
- N_("Click-type window X position"), 0},
- {"ctw-y", 'y', 0, G_OPTION_ARG_INT, &ca.pos_y,
- N_("Click-type window Y position"), 0},
- {"threshold", 't', 0, G_OPTION_ARG_INT, &ca.threshold,
- N_("Ignore small pointer movements"), "[0-30]"},
- {"shutdown", 's', 0, G_OPTION_ARG_NONE, &ca.shutdown,
- N_("Shut down mousetweaks"), 0},
- {"disable-animation", 0, 0, G_OPTION_ARG_NONE, &ca.no_animation,
- N_("Disable cursor animations"), 0},
- {"daemonize", 0, 0, G_OPTION_ARG_NONE, &ca.daemonize,
- N_("Start mousetweaks as a daemon"), 0},
- {"login", 0, 0, G_OPTION_ARG_NONE, &ca.login,
- N_("Start mousetweaks in login mode"), 0},
- { NULL }
+ GOptionEntry entries[] =
+ {
+ {"dwell", 0, 0, G_OPTION_ARG_NONE, &ca.dwell_enabled,
+ N_("Enable dwell click"), 0},
+ {"ssc", 0, 0, G_OPTION_ARG_NONE, &ca.ssc_enabled,
+ N_("Enable simulated secondary click"), 0},
+ {"dwell-time", 0, 0, G_OPTION_ARG_DOUBLE, &ca.dwell_time,
+ N_("Time to wait before a dwell click"), "[0.2-3.0]"},
+ {"ssc-time", 0, 0, G_OPTION_ARG_DOUBLE, &ca.ssc_time,
+ N_("Time to wait before a simulated secondary click"), "[0.5-3.0]"},
+ {"dwell-mode", 'm', 0, G_OPTION_ARG_STRING, &ca.mode,
+ N_("Set the active dwell mode"), "[window|gesture]"},
+ {"show-ctw", 'c', 0, G_OPTION_ARG_NONE, &ca.ctw,
+ N_("Show a click-type window"), 0},
+ {"ctw-x", 'x', 0, G_OPTION_ARG_INT, &ca.pos_x,
+ N_("Click-type window X position"), 0},
+ {"ctw-y", 'y', 0, G_OPTION_ARG_INT, &ca.pos_y,
+ N_("Click-type window Y position"), 0},
+ {"threshold", 't', 0, G_OPTION_ARG_INT, &ca.threshold,
+ N_("Ignore small pointer movements"), "[0-30]"},
+ {"shutdown", 's', 0, G_OPTION_ARG_NONE, &ca.shutdown,
+ N_("Shut down mousetweaks"), 0},
+ {"disable-animation", 0, 0, G_OPTION_ARG_NONE, &ca.no_animation,
+ N_("Disable cursor animations"), 0},
+ {"daemonize", 0, 0, G_OPTION_ARG_NONE, &ca.daemonize,
+ N_("Start mousetweaks as a daemon"), 0},
+ {"login", 0, 0, G_OPTION_ARG_NONE, &ca.login,
+ N_("Start mousetweaks in login mode"), 0},
+ { NULL }
};
/* init cli arguments */
@@ -792,9 +855,10 @@ mt_main (int argc, char **argv, MtCliArgs cli_args)
MtCursorManager *manager;
MtListener *listener;
- if (mt_pidfile_create () < 0) {
- g_warning ("Couldn't create PID file.");
- return;
+ if (mt_pidfile_create () < 0)
+ {
+ g_warning ("Couldn't create PID file.");
+ return;
}
signal (SIGINT, signal_handler);
@@ -806,38 +870,39 @@ mt_main (int argc, char **argv, MtCliArgs cli_args)
mt = mt_data_init ();
if (!mt)
- goto FINISH;
+ goto FINISH;
/* load gconf settings */
get_gconf_options (mt);
/* override with CLI arguments */
if (cli_args.dwell_enabled)
- mt->dwell_enabled = cli_args.dwell_enabled;
+ mt->dwell_enabled = cli_args.dwell_enabled;
if (cli_args.ssc_enabled)
- mt->ssc_enabled = cli_args.ssc_enabled;
+ mt->ssc_enabled = cli_args.ssc_enabled;
if (cli_args.dwell_time >= .1 && cli_args.dwell_time <= 3.)
- mt_timer_set_target (mt->dwell_timer, cli_args.dwell_time);
+ mt_timer_set_target (mt->dwell_timer, cli_args.dwell_time);
if (cli_args.ssc_time >= .1 && cli_args.ssc_time <= 3.)
- mt_timer_set_target (mt->ssc_timer, cli_args.ssc_time);
+ mt_timer_set_target (mt->ssc_timer, cli_args.ssc_time);
if (cli_args.threshold >= 0 && cli_args.threshold <= 30)
- mt->threshold = cli_args.threshold;
+ mt->threshold = cli_args.threshold;
if (cli_args.ctw)
- mt->dwell_show_ctw = cli_args.ctw;
+ mt->dwell_show_ctw = cli_args.ctw;
if (cli_args.no_animation)
- mt->animate_cursor = !cli_args.no_animation;
- if (cli_args.mode) {
- if (g_str_equal (cli_args.mode, "gesture"))
- mt->dwell_mode = DWELL_MODE_GESTURE;
- else if (g_str_equal (cli_args.mode, "window"))
- mt->dwell_mode = DWELL_MODE_CTW;
+ mt->animate_cursor = !cli_args.no_animation;
+ if (cli_args.mode)
+ {
+ if (g_str_equal (cli_args.mode, "gesture"))
+ mt->dwell_mode = DWELL_MODE_GESTURE;
+ else if (g_str_equal (cli_args.mode, "window"))
+ mt->dwell_mode = DWELL_MODE_CTW;
- g_free (cli_args.mode);
+ g_free (cli_args.mode);
}
/* init click-type window */
if (!mt_ctw_init (mt, cli_args.pos_x, cli_args.pos_y))
- goto CLEANUP;
+ goto CLEANUP;
/* init cursor animation */
manager = mt_cursor_manager_get_default ();
@@ -881,28 +946,36 @@ main (int argc, char **argv)
g_set_application_name ("Mousetweaks");
cli_args = mt_parse_options (&argc, &argv);
- if (cli_args.shutdown) {
- int ret;
+ if (cli_args.shutdown)
+ {
+ int ret;
- if ((ret = mt_pidfile_kill_wait (SIGINT, 5)) < 0)
- g_print ("Shutdown failed or nothing to shut down.\n");
- else
- g_print ("Shutdown successful.\n");
+ if ((ret = mt_pidfile_kill_wait (SIGINT, 5)) < 0)
+ g_print ("Shutdown failed or nothing to shut down.\n");
+ else
+ g_print ("Shutdown successful.\n");
- return ret < 0 ? 1 : 0;
+ return ret < 0 ? 1 : 0;
}
- if ((pid = mt_pidfile_is_running ()) >= 0) {
- g_print ("Mousetweaks is already running. (PID %u)\n", pid);
- return 1;
+
+ if ((pid = mt_pidfile_is_running ()) >= 0)
+ {
+ g_print ("Mousetweaks is already running. (PID %u)\n", pid);
+ return 1;
}
- if (cli_args.daemonize) {
- g_print ("Starting daemon.\n");
- if ((pid = fork ()) < 0) {
- g_error ("fork() failed.");
- return 1;
- }
- else if (pid)
- return 0;
+
+ if (cli_args.daemonize)
+ {
+ g_print ("Starting daemon.\n");
+ if ((pid = fork ()) < 0)
+ {
+ g_error ("fork() failed.");
+ return 1;
+ }
+ else if (pid)
+ {
+ return 0;
+ }
}
mt_main (argc, argv, cli_args);
diff --git a/src/mt-main.h b/src/mt-main.h
index 7fea6e2..aae9f52 100644
--- a/src/mt-main.h
+++ b/src/mt-main.h
@@ -29,7 +29,8 @@
G_BEGIN_DECLS
typedef struct _MtData MtData;
-struct _MtData {
+struct _MtData
+{
GConfClient *client;
GtkBuilder *ui;
MtService *service;
diff --git a/src/mt-pidfile.c b/src/mt-pidfile.c
index 3fa9a75..cac3180 100644
--- a/src/mt-pidfile.c
+++ b/src/mt-pidfile.c
@@ -1,5 +1,5 @@
/*
- * Copyright © 2007-2009 Gerd Kohlberger <lowfi chello at>
+ * Copyright © 2007-2010 Gerd Kohlberger <gerdko gmail com>
*
* This file is part of Mousetweaks.
*
@@ -49,7 +49,7 @@ mt_pidfile_proc (void)
{
static char fn[512];
- snprintf (fn, sizeof(fn), "%s/.mousetweaks.pid", g_get_home_dir ());
+ snprintf (fn, sizeof (fn), "%s/.mousetweaks.pid", g_get_home_dir ());
return fn;
}
@@ -65,7 +65,7 @@ lock_file (int fd, int enable)
f.l_len = 0;
if (fcntl(fd, F_SETLKW, &f) < 0)
- return -1;
+ return -1;
return 0;
}
@@ -81,20 +81,22 @@ mt_pidfile_is_running (void)
long lpid;
char *e = NULL;
- if (!(fn = mt_pidfile_proc ())) {
- errno = EINVAL;
- goto FINISH;
+ if (!(fn = mt_pidfile_proc ()))
+ {
+ errno = EINVAL;
+ goto FINISH;
}
if ((fd = open (fn, O_RDWR, 0644)) < 0)
- goto FINISH;
+ goto FINISH;
if ((locked = lock_file (fd, 1)) < 0)
- goto FINISH;
+ goto FINISH;
- if ((l = read (fd, txt, sizeof(txt) - 1)) < 0) {
- unlink(fn);
- goto FINISH;
+ if ((l = read (fd, txt, sizeof(txt) - 1)) < 0)
+ {
+ unlink(fn);
+ goto FINISH;
}
txt[l] = 0;
@@ -104,28 +106,33 @@ mt_pidfile_is_running (void)
lpid = strtol(txt, &e, 10);
pid = (pid_t) lpid;
- if (errno != 0 || !e || *e || (long) pid != lpid) {
- unlink (fn);
- errno = EINVAL;
- goto FINISH;
+ if (errno != 0 || !e || *e || (long) pid != lpid)
+ {
+ unlink (fn);
+ errno = EINVAL;
+ goto FINISH;
}
- if (kill (pid, 0) != 0 && errno != EPERM) {
- int saved_errno = errno;
- unlink (fn);
- errno = saved_errno;
- goto FINISH;
+ if (kill (pid, 0) != 0 && errno != EPERM)
+ {
+ int saved_errno = errno;
+ unlink (fn);
+ errno = saved_errno;
+ goto FINISH;
}
ret = pid;
FINISH:
- if (fd >= 0) {
- int saved_errno = errno;
- if (locked >= 0)
- lock_file (fd, 0);
- errno = saved_errno;
- close (fd);
+ if (fd >= 0)
+ {
+ int saved_errno = errno;
+
+ if (locked >= 0)
+ lock_file (fd, 0);
+
+ errno = saved_errno;
+ close (fd);
}
return ret;
@@ -138,30 +145,31 @@ mt_pidfile_kill_wait (int signal, int sec)
time_t t;
if ((pid = mt_pidfile_is_running ()) < 0)
- return -1;
+ return -1;
if (kill (pid, signal) < 0)
- return -1;
+ return -1;
t = time (NULL) + sec;
+ for (;;)
+ {
+ int r;
+ struct timeval tv = { 0, 100000 };
- for (;;) {
- int r;
- struct timeval tv = { 0, 100000 };
+ if (time (NULL) > t)
+ {
+ errno = ETIME;
+ return -1;
+ }
- if (time (NULL) > t) {
- errno = ETIME;
- return -1;
- }
+ if ((r = kill (pid, 0)) < 0 && errno != ESRCH)
+ return -1;
- if ((r = kill (pid, 0)) < 0 && errno != ESRCH)
- return -1;
+ if (r)
+ return 0;
- if (r)
- return 0;
-
- if (select (0, NULL, NULL, NULL, &tv) < 0)
- return -1;
+ if (select (0, NULL, NULL, NULL, &tv) < 0)
+ return -1;
}
}
@@ -178,42 +186,46 @@ mt_pidfile_create (void)
u = umask(022);
- if (!(fn = mt_pidfile_proc ())) {
- errno = EINVAL;
- goto FINISH;
+ if (!(fn = mt_pidfile_proc ()))
+ {
+ errno = EINVAL;
+ goto FINISH;
}
if ((fd = open (fn, O_CREAT|O_RDWR|O_EXCL, 0644)) < 0)
- goto FINISH;
+ goto FINISH;
- if ((locked = lock_file (fd, 1)) < 0) {
- int saved_errno = errno;
- unlink (fn);
- errno = saved_errno;
- goto FINISH;
+ if ((locked = lock_file (fd, 1)) < 0)
+ {
+ int saved_errno = errno;
+ unlink (fn);
+ errno = saved_errno;
+ goto FINISH;
}
snprintf (t, sizeof(t), "%lu\n", (unsigned long) getpid ());
l = strlen (t);
- if (write (fd, t, l) != l) {
- int saved_errno = errno;
- unlink (fn);
- errno = saved_errno;
- goto FINISH;
+ if (write (fd, t, l) != l)
+ {
+ int saved_errno = errno;
+ unlink (fn);
+ errno = saved_errno;
+ goto FINISH;
}
ret = 0;
FINISH:
- if (fd >= 0) {
- int saved_errno = errno;
+ if (fd >= 0)
+ {
+ int saved_errno = errno;
- if (locked >= 0)
- lock_file (fd, 0);
+ if (locked >= 0)
+ lock_file (fd, 0);
- close (fd);
- errno = saved_errno;
+ close (fd);
+ errno = saved_errno;
}
umask(u);
@@ -226,13 +238,14 @@ mt_pidfile_remove (void)
{
const char *fn;
- if (!(fn = mt_pidfile_proc ())) {
- errno = EINVAL;
- return -1;
+ if (!(fn = mt_pidfile_proc ()))
+ {
+ errno = EINVAL;
+ return -1;
}
if (unlink (fn) < 0)
- return -1;
+ return -1;
return 0;
}
diff --git a/src/mt-pidfile.h b/src/mt-pidfile.h
index 12f7144..6380e64 100644
--- a/src/mt-pidfile.h
+++ b/src/mt-pidfile.h
@@ -1,5 +1,5 @@
/*
- * Copyright © 2007-2009 Gerd Kohlberger <lowfi chello at>
+ * Copyright © 2007-2010 Gerd Kohlberger <gerdko gmail com>
*
* This file is part of Mousetweaks.
*
@@ -22,11 +22,10 @@
G_BEGIN_DECLS
-int mt_pidfile_create (void);
-pid_t mt_pidfile_is_running (void);
-int mt_pidfile_kill_wait (int signal,
- int sec);
-int mt_pidfile_remove (void);
+int mt_pidfile_create (void);
+pid_t mt_pidfile_is_running (void);
+int mt_pidfile_kill_wait (int signal, int sec);
+int mt_pidfile_remove (void);
G_END_DECLS
diff --git a/src/mt-service.h b/src/mt-service.h
index b67ea46..40c4188 100644
--- a/src/mt-service.h
+++ b/src/mt-service.h
@@ -30,8 +30,8 @@ G_BEGIN_DECLS
#define MT_SERVICE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MT_TYPE_SERVICE, MtService))
#define MT_IS_SERVICE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MT_TYPE_SERVICE))
-typedef struct _MtService MtService;
typedef GObjectClass MtServiceClass;
+typedef struct _MtService MtService;
typedef struct _MtServicePrivate MtServicePrivate;
struct _MtService
diff --git a/src/mt-timer.c b/src/mt-timer.c
index bee3f2d..56d45a8 100644
--- a/src/mt-timer.c
+++ b/src/mt-timer.c
@@ -1,5 +1,5 @@
/*
- * Copyright © 2007-2009 Gerd Kohlberger <lowfi chello at>
+ * Copyright © 2007-2010 Gerd Kohlberger <gerdko gmail com>
*
* This file is part of Mousetweaks.
*
@@ -21,57 +21,31 @@
#include "mt-timer.h"
-struct _MtTimerPrivate {
+struct _MtTimerPrivate
+{
GTimer *timer;
guint tid;
gdouble elapsed;
gdouble target;
};
-enum {
+enum
+{
TICK,
FINISHED,
LAST_SIGNAL
};
-static guint signals[LAST_SIGNAL] = { 0 };
+static guint signals[LAST_SIGNAL] = { 0, };
G_DEFINE_TYPE (MtTimer, mt_timer, G_TYPE_OBJECT)
-static void mt_timer_finalize (GObject *object);
-
-static void
-mt_timer_class_init (MtTimerClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->finalize = mt_timer_finalize;
-
- signals[TICK] =
- g_signal_new (g_intern_static_string ("tick"),
- G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL,
- g_cclosure_marshal_VOID__DOUBLE,
- G_TYPE_NONE, 1, G_TYPE_DOUBLE);
-
- signals[FINISHED] =
- g_signal_new (g_intern_static_string ("finished"),
- G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- g_type_class_add_private (klass, sizeof (MtTimerPrivate));
-}
-
static void
mt_timer_init (MtTimer *timer)
{
timer->priv = G_TYPE_INSTANCE_GET_PRIVATE (timer,
- MT_TYPE_TIMER,
- MtTimerPrivate);
+ MT_TYPE_TIMER,
+ MtTimerPrivate);
timer->priv->timer = g_timer_new ();
timer->priv->target = 1.2;
}
@@ -82,13 +56,39 @@ mt_timer_finalize (GObject *object)
MtTimer *timer = MT_TIMER (object);
if (timer->priv->tid)
- g_source_remove (timer->priv->tid);
+ g_source_remove (timer->priv->tid);
g_timer_destroy (timer->priv->timer);
G_OBJECT_CLASS (mt_timer_parent_class)->finalize (object);
}
+static void
+mt_timer_class_init (MtTimerClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = mt_timer_finalize;
+
+ signals[TICK] =
+ g_signal_new (g_intern_static_string ("tick"),
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__DOUBLE,
+ G_TYPE_NONE, 1, G_TYPE_DOUBLE);
+
+ signals[FINISHED] =
+ g_signal_new (g_intern_static_string ("finished"),
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ g_type_class_add_private (klass, sizeof (MtTimerPrivate));
+}
+
static gboolean
mt_timer_check_time (gpointer data)
{
@@ -98,12 +98,13 @@ mt_timer_check_time (gpointer data)
priv->elapsed = g_timer_elapsed (priv->timer, NULL);
g_signal_emit (timer, signals[TICK], 0, priv->elapsed);
- if (priv->elapsed >= priv->target) {
- priv->tid = 0;
- priv->elapsed = 0.0;
- g_signal_emit (timer, signals[FINISHED], 0);
+ if (priv->elapsed >= priv->target)
+ {
+ priv->tid = 0;
+ priv->elapsed = 0.0;
+ g_signal_emit (timer, signals[FINISHED], 0);
- return FALSE;
+ return FALSE;
}
return TRUE;
@@ -123,7 +124,7 @@ mt_timer_start (MtTimer *timer)
g_timer_start (timer->priv->timer);
if (timer->priv->tid == 0)
- timer->priv->tid = g_timeout_add (100, mt_timer_check_time, timer);
+ timer->priv->tid = g_timeout_add (100, mt_timer_check_time, timer);
}
void
@@ -131,9 +132,10 @@ mt_timer_stop (MtTimer *timer)
{
g_return_if_fail (MT_IS_TIMER (timer));
- if (timer->priv->tid) {
- g_source_remove (timer->priv->tid);
- timer->priv->tid = 0;
+ if (timer->priv->tid)
+ {
+ g_source_remove (timer->priv->tid);
+ timer->priv->tid = 0;
}
}
@@ -162,10 +164,10 @@ mt_timer_get_target (MtTimer *timer)
}
void
-mt_timer_set_target (MtTimer *timer, gdouble time)
+mt_timer_set_target (MtTimer *timer, gdouble target)
{
g_return_if_fail (MT_IS_TIMER (timer));
- g_return_if_fail (time >= 0.0);
+ g_return_if_fail (target > 0.0);
- timer->priv->target = time;
+ timer->priv->target = target;
}
diff --git a/src/mt-timer.h b/src/mt-timer.h
index fd479ed..6abfc61 100644
--- a/src/mt-timer.h
+++ b/src/mt-timer.h
@@ -1,5 +1,5 @@
/*
- * Copyright © 2007-2009 Gerd Kohlberger <lowfi chello at>
+ * Copyright © 2007-2010 Gerd Kohlberger <gerdko gmail com>
*
* This file is part of Mousetweaks.
*
@@ -24,31 +24,32 @@
G_BEGIN_DECLS
-#define MT_TYPE_TIMER (mt_timer_get_type ())
-#define MT_TIMER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MT_TYPE_TIMER, MtTimer))
-#define MT_TIMER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), MT_TYPE_TIMER, MtTimerClass))
-#define MT_IS_TIMER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MT_TYPE_TIMER))
-#define MT_IS_TIMER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MT_TYPE_TIMER))
-#define MT_TIMER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MT_TYPE_TIMER, MtTimerClass))
+#define MT_TYPE_TIMER (mt_timer_get_type ())
+#define MT_TIMER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MT_TYPE_TIMER, MtTimer))
+#define MT_IS_TIMER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MT_TYPE_TIMER))
typedef GObjectClass MtTimerClass;
typedef struct _MtTimer MtTimer;
typedef struct _MtTimerPrivate MtTimerPrivate;
-struct _MtTimer {
+struct _MtTimer
+{
GObject parent;
MtTimerPrivate *priv;
};
-GType mt_timer_get_type (void) G_GNUC_CONST;
-MtTimer * mt_timer_new (void);
-void mt_timer_start (MtTimer *timer);
-void mt_timer_stop (MtTimer *timer);
-gboolean mt_timer_is_running (MtTimer *timer);
-gdouble mt_timer_elapsed (MtTimer *timer);
-gdouble mt_timer_get_target (MtTimer *timer);
-void mt_timer_set_target (MtTimer *timer,
- gdouble time);
+GType mt_timer_get_type (void) G_GNUC_CONST;
+
+MtTimer * mt_timer_new (void);
+
+void mt_timer_start (MtTimer *timer);
+void mt_timer_stop (MtTimer *timer);
+gboolean mt_timer_is_running (MtTimer *timer);
+
+gdouble mt_timer_elapsed (MtTimer *timer);
+gdouble mt_timer_get_target (MtTimer *timer);
+void mt_timer_set_target (MtTimer *timer,
+ gdouble target);
G_END_DECLS
diff --git a/src/pointer-capture-applet.c b/src/pointer-capture-applet.c
index 49cf382..db0c383 100644
--- a/src/pointer-capture-applet.c
+++ b/src/pointer-capture-applet.c
@@ -1,5 +1,5 @@
/*
- * Copyright © 2007-2009 Gerd Kohlberger <lowfi chello at>
+ * Copyright © 2007-2010 Gerd Kohlberger <gerdko gmail 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
@@ -15,6 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <stdlib.h>
#include <gtk/gtk.h>
#include <panel-applet.h>
#include <panel-applet-gconf.h>
@@ -28,7 +29,8 @@
#define TANGO_ALUMINIUM2_DARK 0.180f, 0.203f, 0.211f
typedef struct _CaptureData CaptureData;
-struct _CaptureData {
+struct _CaptureData
+{
PanelApplet *applet;
GtkBuilder *ui;
GtkWidget *area;
@@ -54,8 +56,8 @@ static void capture_data_free (CaptureData *cd);
static void
capture_preferences (BonoboUIComponent *component,
- gpointer data,
- const char *cname)
+ gpointer data,
+ const char *cname)
{
CaptureData *cd = data;
@@ -68,7 +70,7 @@ capture_help (BonoboUIComponent *component, gpointer data, const char *cname)
CaptureData *cd = data;
mt_common_show_help (gtk_widget_get_screen (cd->area),
- gtk_get_current_event_time ());
+ gtk_get_current_event_time ());
}
static void
@@ -79,7 +81,8 @@ capture_about (BonoboUIComponent *component, gpointer data, const char *cname)
gtk_window_present (GTK_WINDOW (WID ("about")));
}
-static const BonoboUIVerb menu_verb[] = {
+static const BonoboUIVerb menu_verb[] =
+{
BONOBO_UI_UNSAFE_VERB ("PropertiesVerb", capture_preferences),
BONOBO_UI_UNSAFE_VERB ("HelpVerb", capture_help),
BONOBO_UI_UNSAFE_VERB ("AboutVerb", capture_about),
@@ -117,19 +120,21 @@ unlock_pointer (CaptureData *cd)
/* move pointer to the position where it was locked */
gdk_display_warp_pointer (gdk_display_get_default (),
- gtk_widget_get_screen (cd->area),
- cd->pointer_x,
- cd->pointer_y);
+ gtk_widget_get_screen (cd->area),
+ cd->pointer_x,
+ cd->pointer_y);
/* restore cursor */
root = gdk_screen_get_root_window (gtk_widget_get_screen (cd->area));
- if (cd->root) {
- gdk_window_set_cursor (root, cd->root);
+ if (cd->root)
+ {
+ gdk_window_set_cursor (root, cd->root);
}
- else {
- cursor = gdk_cursor_new (GDK_LEFT_PTR);
- gdk_window_set_cursor (root, cursor);
- gdk_cursor_unref (cursor);
+ else
+ {
+ cursor = gdk_cursor_new (GDK_LEFT_PTR);
+ gdk_window_set_cursor (root, cursor);
+ gdk_cursor_unref (cursor);
}
/* update state */
@@ -144,10 +149,10 @@ area_entered (GtkWidget *widget, GdkEventCrossing *cev, gpointer data)
CaptureData *cd = data;
if (cev->mode != GDK_CROSSING_NORMAL)
- return FALSE;
+ return FALSE;
if (cd->cap_button)
- return FALSE;
+ return FALSE;
cd->pointer_x = cev->x_root;
cd->pointer_y = cev->y_root;
@@ -161,12 +166,13 @@ area_left (GtkWidget *widget, GdkEventCrossing *cev, gpointer data)
{
CaptureData *cd = data;
- if (cd->pointer_locked) {
- /* move pointer back to center */
- gdk_display_warp_pointer (gdk_display_get_default (),
- gtk_widget_get_screen (widget),
- cd->center_x,
- cd->center_y);
+ if (cd->pointer_locked)
+ {
+ /* move pointer back to center */
+ gdk_display_warp_pointer (gdk_display_get_default (),
+ gtk_widget_get_screen (widget),
+ cd->center_x,
+ cd->center_y);
}
return FALSE;
}
@@ -178,24 +184,24 @@ area_button_press (GtkWidget *widget, GdkEventButton *bev, gpointer data)
CaptureData *cd = data;
if (bev->button == cd->cap_button &&
- (bev->state & cd->cap_mask) == cd->cap_mask &&
- !cd->pointer_locked) {
-
- cd->pointer_x = bev->x_root;
- cd->pointer_y = bev->y_root;
- lock_pointer (cd);
+ (bev->state & cd->cap_mask) == cd->cap_mask &&
+ !cd->pointer_locked)
+ {
+ cd->pointer_x = bev->x_root;
+ cd->pointer_y = bev->y_root;
+ lock_pointer (cd);
}
else if (bev->button == cd->rel_button &&
- (bev->state & cd->rel_mask) == cd->rel_mask &&
- cd->pointer_locked) {
-
- unlock_pointer (cd);
+ (bev->state & cd->rel_mask) == cd->rel_mask &&
+ cd->pointer_locked)
+ {
+ unlock_pointer (cd);
}
- else if (!cd->pointer_locked && bev->button != 1) {
- g_signal_stop_emission_by_name (widget, "button_press_event");
- return FALSE;
+ else if (!cd->pointer_locked && bev->button != 1)
+ {
+ g_signal_stop_emission_by_name (widget, "button_press_event");
+ return FALSE;
}
-
return TRUE;
}
@@ -210,16 +216,16 @@ render_text (cairo_t *cr, CaptureData *cd)
layout = pango_cairo_create_layout (cr);
if (cd->size >= 60)
- pango_layout_set_text (layout, _("Locked"), -1);
+ pango_layout_set_text (layout, _("Locked"), -1);
else
- /* l10n: the first letter of 'Locked' */
- pango_layout_set_text (layout, _("L"), -1);
+ /* l10n: the first letter of 'Locked' */
+ pango_layout_set_text (layout, _("L"), -1);
desc = pango_font_description_new ();
pango_font_description_set_family (desc, "Bitstream Vera Sans");
if (cd->vertical)
- pango_font_description_set_gravity (desc, PANGO_GRAVITY_EAST);
+ pango_font_description_set_gravity (desc, PANGO_GRAVITY_EAST);
size = panel_applet_get_size (cd->applet) / 3;
pango_font_description_set_size (desc, size * PANGO_SCALE);
@@ -228,18 +234,19 @@ render_text (cairo_t *cr, CaptureData *cd)
pango_layout_get_pixel_extents (layout, &rect, NULL);
/* check font size */
- while ((rect.width - 8) > cd->size) {
- pango_font_description_set_size (desc, (--size) * PANGO_SCALE);
- pango_layout_set_font_description (layout, desc);
- pango_layout_get_pixel_extents (layout, &rect, NULL);
+ while ((rect.width - 8) > cd->size)
+ {
+ pango_font_description_set_size (desc, (--size) * PANGO_SCALE);
+ pango_layout_set_font_description (layout, desc);
+ pango_layout_get_pixel_extents (layout, &rect, NULL);
}
if (cd->vertical)
- cairo_rotate (cr, -pango_gravity_to_rotation (PANGO_GRAVITY_EAST));
+ cairo_rotate (cr, -pango_gravity_to_rotation (PANGO_GRAVITY_EAST));
cairo_rel_move_to (cr,
- -rect.x - rect.width / 2,
- -rect.y - rect.height / 2);
+ -rect.x - rect.width / 2,
+ -rect.y - rect.height / 2);
pango_cairo_layout_path (cr, layout);
pango_font_description_free (desc);
@@ -264,21 +271,21 @@ area_exposed (GtkWidget *widget, GdkEventExpose *eev, gpointer data)
cairo_rectangle (cr, 0.0, 0.0, w, h);
if (cd->pointer_locked)
- cairo_set_source_rgb (cr, TANGO_SCARLETRED_DARK);
+ cairo_set_source_rgb (cr, TANGO_SCARLETRED_DARK);
else
- cairo_set_source_rgb (cr, TANGO_CHAMELEON_DARK);
+ cairo_set_source_rgb (cr, TANGO_CHAMELEON_DARK);
cairo_paint (cr);
cairo_set_source_rgb (cr, TANGO_ALUMINIUM2_DARK);
cairo_stroke (cr);
- if (cd->pointer_locked) {
- cairo_move_to (cr, w / 2, h / 2);
- render_text (cr, cd);
- cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
- cairo_fill (cr);
+ if (cd->pointer_locked)
+ {
+ cairo_move_to (cr, w / 2, h / 2);
+ render_text (cr, cd);
+ cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
+ cairo_fill (cr);
}
-
cairo_destroy (cr);
return TRUE;
@@ -287,18 +294,19 @@ area_exposed (GtkWidget *widget, GdkEventExpose *eev, gpointer data)
static void
update_orientation (CaptureData *cd, PanelAppletOrient orient)
{
- switch (orient) {
- case PANEL_APPLET_ORIENT_UP:
- case PANEL_APPLET_ORIENT_DOWN:
- gtk_widget_set_size_request (cd->area, cd->size, 0);
- cd->vertical = FALSE;
- break;
- case PANEL_APPLET_ORIENT_LEFT:
- case PANEL_APPLET_ORIENT_RIGHT:
- gtk_widget_set_size_request (cd->area, 0, cd->size);
- cd->vertical = TRUE;
- default:
- break;
+ switch (orient)
+ {
+ case PANEL_APPLET_ORIENT_UP:
+ case PANEL_APPLET_ORIENT_DOWN:
+ gtk_widget_set_size_request (cd->area, cd->size, 0);
+ cd->vertical = FALSE;
+ break;
+ case PANEL_APPLET_ORIENT_LEFT:
+ case PANEL_APPLET_ORIENT_RIGHT:
+ gtk_widget_set_size_request (cd->area, 0, cd->size);
+ cd->vertical = TRUE;
+ default:
+ break;
}
}
@@ -347,7 +355,7 @@ static void
prefs_help (GtkButton *button, gpointer data)
{
mt_common_show_help (gtk_widget_get_screen (GTK_WIDGET (button)),
- gtk_get_current_event_time ());
+ gtk_get_current_event_time ());
}
static void
@@ -357,9 +365,9 @@ prefs_cap_button (GtkSpinButton *spin, gpointer data)
cd->cap_button = gtk_spin_button_get_value_as_int (spin);
panel_applet_gconf_set_int (cd->applet,
- "capture_button",
- cd->cap_button,
- NULL);
+ "capture_button",
+ cd->cap_button,
+ NULL);
}
static void
@@ -369,9 +377,9 @@ prefs_cap_alt (GtkToggleButton *toggle, gpointer data)
cd->cap_mask ^= GDK_MOD1_MASK;
panel_applet_gconf_set_bool (cd->applet,
- "capture_mod_alt",
- gtk_toggle_button_get_active (toggle),
- NULL);
+ "capture_mod_alt",
+ gtk_toggle_button_get_active (toggle),
+ NULL);
}
static void
@@ -381,9 +389,9 @@ prefs_cap_shift (GtkToggleButton *toggle, gpointer data)
cd->cap_mask ^= GDK_SHIFT_MASK;
panel_applet_gconf_set_bool (cd->applet,
- "capture_mod_shift",
- gtk_toggle_button_get_active (toggle),
- NULL);
+ "capture_mod_shift",
+ gtk_toggle_button_get_active (toggle),
+ NULL);
}
static void
@@ -393,9 +401,9 @@ prefs_cap_ctrl (GtkToggleButton *toggle, gpointer data)
cd->cap_mask ^= GDK_CONTROL_MASK;
panel_applet_gconf_set_bool (cd->applet,
- "capture_mod_ctrl",
- gtk_toggle_button_get_active (toggle),
- NULL);
+ "capture_mod_ctrl",
+ gtk_toggle_button_get_active (toggle),
+ NULL);
}
static void
@@ -405,9 +413,9 @@ prefs_rel_button (GtkSpinButton *spin, gpointer data)
cd->rel_button = gtk_spin_button_get_value_as_int (spin);
panel_applet_gconf_set_int (cd->applet,
- "release_button",
- cd->rel_button,
- NULL);
+ "release_button",
+ cd->rel_button,
+ NULL);
}
static void
@@ -417,9 +425,9 @@ prefs_rel_alt (GtkToggleButton *toggle, gpointer data)
cd->rel_mask ^= GDK_MOD1_MASK;
panel_applet_gconf_set_bool (cd->applet,
- "release_mod_alt",
- gtk_toggle_button_get_active (toggle),
- NULL);
+ "release_mod_alt",
+ gtk_toggle_button_get_active (toggle),
+ NULL);
}
static void
@@ -429,9 +437,9 @@ prefs_rel_shift (GtkToggleButton *toggle, gpointer data)
cd->rel_mask ^= GDK_SHIFT_MASK;
panel_applet_gconf_set_bool (cd->applet,
- "release_mod_shift",
- gtk_toggle_button_get_active (toggle),
- NULL);
+ "release_mod_shift",
+ gtk_toggle_button_get_active (toggle),
+ NULL);
}
static void
@@ -441,9 +449,9 @@ prefs_rel_ctrl (GtkToggleButton *toggle, gpointer data)
cd->rel_mask ^= GDK_CONTROL_MASK;
panel_applet_gconf_set_bool (cd->applet,
- "release_mod_ctrl",
- gtk_toggle_button_get_active (toggle),
- NULL);
+ "release_mod_ctrl",
+ gtk_toggle_button_get_active (toggle),
+ NULL);
}
static gboolean
@@ -454,73 +462,74 @@ init_preferences (CaptureData *cd)
cd->ui = gtk_builder_new ();
gtk_builder_add_from_file (cd->ui,
- DATADIR "/pointer-capture-applet.ui",
- &error);
- if (error) {
- g_print ("%s\n", error->message);
- g_error_free (error);
- return FALSE;
+ DATADIR "/pointer-capture-applet.ui",
+ &error);
+ if (error)
+ {
+ g_print ("%s\n", error->message);
+ g_error_free (error);
+ return FALSE;
}
g_signal_connect (WID ("capture_preferences"), "delete-event",
- G_CALLBACK (gtk_widget_hide_on_delete), NULL);
+ G_CALLBACK (gtk_widget_hide_on_delete), NULL);
g_signal_connect (WID ("close"), "clicked",
- G_CALLBACK (prefs_closed), cd);
+ G_CALLBACK (prefs_closed), cd);
g_signal_connect (WID ("help"), "clicked",
- G_CALLBACK (prefs_help), NULL);
+ G_CALLBACK (prefs_help), NULL);
w = WID ("size");
gtk_spin_button_set_value (GTK_SPIN_BUTTON (w), cd->size);
g_signal_connect (w, "value_changed",
- G_CALLBACK (prefs_size_changed), cd);
+ G_CALLBACK (prefs_size_changed), cd);
/* capture modifier signals */
w = WID ("cap_button");
gtk_spin_button_set_value (GTK_SPIN_BUTTON (w), cd->cap_button);
g_signal_connect (w, "value_changed",
- G_CALLBACK (prefs_cap_button), cd);
+ G_CALLBACK (prefs_cap_button), cd);
w = WID ("cap_alt");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w),
- (cd->cap_mask & GDK_MOD1_MASK));
+ (cd->cap_mask & GDK_MOD1_MASK));
g_signal_connect (w, "toggled",
- G_CALLBACK (prefs_cap_alt), cd);
+ G_CALLBACK (prefs_cap_alt), cd);
w = WID ("cap_shift");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w),
- (cd->cap_mask & GDK_SHIFT_MASK));
+ (cd->cap_mask & GDK_SHIFT_MASK));
g_signal_connect (w, "toggled",
- G_CALLBACK (prefs_cap_shift), cd);
+ G_CALLBACK (prefs_cap_shift), cd);
w = WID ("cap_ctrl");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w),
- (cd->cap_mask & GDK_CONTROL_MASK));
+ (cd->cap_mask & GDK_CONTROL_MASK));
g_signal_connect (w, "toggled",
- G_CALLBACK (prefs_cap_ctrl), cd);
+ G_CALLBACK (prefs_cap_ctrl), cd);
/* release modifier signals */
w = WID ("rel_button");
gtk_spin_button_set_value (GTK_SPIN_BUTTON (w), cd->rel_button);
g_signal_connect (w, "value_changed",
- G_CALLBACK (prefs_rel_button), cd);
+ G_CALLBACK (prefs_rel_button), cd);
w = WID ("rel_alt");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w),
- (cd->rel_mask & GDK_MOD1_MASK));
+ (cd->rel_mask & GDK_MOD1_MASK));
g_signal_connect (w, "toggled",
- G_CALLBACK (prefs_rel_alt), cd);
+ G_CALLBACK (prefs_rel_alt), cd);
w = WID ("rel_shift");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w),
- (cd->rel_mask & GDK_SHIFT_MASK));
+ (cd->rel_mask & GDK_SHIFT_MASK));
g_signal_connect (w, "toggled",
- G_CALLBACK (prefs_rel_shift), cd);
+ G_CALLBACK (prefs_rel_shift), cd);
w = WID ("rel_ctrl");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w),
- (cd->rel_mask & GDK_CONTROL_MASK));
+ (cd->rel_mask & GDK_CONTROL_MASK));
g_signal_connect (w, "toggled",
- G_CALLBACK (prefs_rel_ctrl), cd);
+ G_CALLBACK (prefs_rel_ctrl), cd);
return TRUE;
}
@@ -543,10 +552,10 @@ static void
capture_data_free (CaptureData *cd)
{
if (cd->blank)
- gdk_cursor_unref (cd->blank);
+ gdk_cursor_unref (cd->blank);
if (cd->ui)
- g_object_unref (cd->ui);
+ g_object_unref (cd->ui);
g_slice_free (CaptureData, cd);
}
@@ -569,48 +578,48 @@ fill_applet (PanelApplet *applet)
/* gconf settings */
panel_applet_add_preferences (applet,
- "/schemas/apps/pointer-capture",
- NULL);
+ "/schemas/apps/pointer-capture",
+ NULL);
cd->size = panel_applet_gconf_get_int (applet, "size", NULL);
cd->cap_button = panel_applet_gconf_get_int (applet,
- "capture_button", NULL);
+ "capture_button", NULL);
cd->rel_button = panel_applet_gconf_get_int (applet,
- "release_button", NULL);
+ "release_button", NULL);
if (panel_applet_gconf_get_bool (applet, "capture_mod_shift", NULL))
- cd->cap_mask |= GDK_SHIFT_MASK;
+ cd->cap_mask |= GDK_SHIFT_MASK;
if (panel_applet_gconf_get_bool (applet, "capture_mod_ctrl", NULL))
- cd->cap_mask |= GDK_CONTROL_MASK;
+ cd->cap_mask |= GDK_CONTROL_MASK;
if (panel_applet_gconf_get_bool (applet, "capture_mod_alt", NULL))
- cd->cap_mask |= GDK_MOD1_MASK;
+ cd->cap_mask |= GDK_MOD1_MASK;
if (panel_applet_gconf_get_bool (applet, "release_mod_shift", NULL))
- cd->rel_mask |= GDK_SHIFT_MASK;
+ cd->rel_mask |= GDK_SHIFT_MASK;
if (panel_applet_gconf_get_bool (applet, "release_mod_ctrl", NULL))
- cd->rel_mask |= GDK_CONTROL_MASK;
+ cd->rel_mask |= GDK_CONTROL_MASK;
if (panel_applet_gconf_get_bool (applet, "release_mod_alt", NULL))
- cd->rel_mask |= GDK_MOD1_MASK;
+ cd->rel_mask |= GDK_MOD1_MASK;
/* preferences dialog */
if (!init_preferences (cd)) {
- capture_data_free (cd);
- return FALSE;
+ capture_data_free (cd);
+ return FALSE;
}
/* capture area */
cd->area = gtk_drawing_area_new ();
gtk_widget_add_events (cd->area,
- GDK_ENTER_NOTIFY_MASK |
- GDK_LEAVE_NOTIFY_MASK |
- GDK_BUTTON_PRESS_MASK);
+ GDK_ENTER_NOTIFY_MASK |
+ GDK_LEAVE_NOTIFY_MASK |
+ GDK_BUTTON_PRESS_MASK);
g_signal_connect (cd->area, "enter-notify-event",
- G_CALLBACK (area_entered), cd);
+ G_CALLBACK (area_entered), cd);
g_signal_connect (cd->area, "leave-notify-event",
- G_CALLBACK (area_left), cd);
+ G_CALLBACK (area_left), cd);
g_signal_connect (cd->area, "expose-event",
- G_CALLBACK (area_exposed), cd);
+ G_CALLBACK (area_exposed), cd);
g_signal_connect (cd->area, "button-press-event",
- G_CALLBACK (area_button_press), cd);
+ G_CALLBACK (area_button_press), cd);
update_orientation (cd, panel_applet_get_orient (applet));
gtk_widget_show (cd->area);
@@ -620,23 +629,23 @@ fill_applet (PanelApplet *applet)
g_object_set (about, "version", VERSION, NULL);
g_signal_connect (about, "delete-event",
- G_CALLBACK (gtk_widget_hide_on_delete), NULL);
+ G_CALLBACK (gtk_widget_hide_on_delete), NULL);
g_signal_connect (about, "response",
- G_CALLBACK (about_response), cd);
+ G_CALLBACK (about_response), cd);
/* applet initialisation */
panel_applet_set_flags (applet,
- PANEL_APPLET_EXPAND_MINOR |
- PANEL_APPLET_HAS_HANDLE);
+ PANEL_APPLET_EXPAND_MINOR |
+ PANEL_APPLET_HAS_HANDLE);
panel_applet_set_background_widget (applet, GTK_WIDGET (applet));
panel_applet_setup_menu_from_file (applet,
- DATADIR, "PointerCapture.xml",
- NULL, menu_verb, cd);
+ DATADIR, "PointerCapture.xml",
+ NULL, menu_verb, cd);
g_signal_connect (applet, "change-orient",
- G_CALLBACK (applet_orient_changed), cd);
+ G_CALLBACK (applet_orient_changed), cd);
g_signal_connect (applet, "unrealize",
- G_CALLBACK (applet_unrealize), cd);
+ G_CALLBACK (applet_unrealize), cd);
obj = gtk_widget_get_accessible (GTK_WIDGET (applet));
atk_object_set_name (obj, _("Capture area"));
@@ -652,14 +661,14 @@ static gboolean
applet_factory (PanelApplet *applet, const gchar *iid, gpointer data)
{
if (!g_str_equal (iid, "OAFIID:PointerCaptureApplet"))
- return FALSE;
+ return FALSE;
return fill_applet (applet);
}
PANEL_APPLET_BONOBO_FACTORY ("OAFIID:PointerCaptureApplet_Factory",
- PANEL_TYPE_APPLET,
- "Pointer Capture Factory",
- VERSION,
- applet_factory,
- NULL);
+ PANEL_TYPE_APPLET,
+ "Pointer Capture Factory",
+ VERSION,
+ applet_factory,
+ NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]