mousetweaks r147 - in trunk: . src
- From: gerdk svn gnome org
- To: svn-commits-list gnome org
- Subject: mousetweaks r147 - in trunk: . src
- Date: Thu, 8 May 2008 07:41:04 +0100 (BST)
Author: gerdk
Date: Thu May 8 06:41:04 2008
New Revision: 147
URL: http://svn.gnome.org/viewvc/mousetweaks?rev=147&view=rev
Log:
2008-05-08 Gerd Kohlberger <gerdk svn gnome org>
* src/mt-common.c:
* src/mt-common.h:
Add more dialog types.
* src/pointer-capture-applet.c:
* src/dwell-click-applet.c:
Switch to new dialog function.
* src/mt-main.c:
Improve the Assistive Technology warning dialog and add an
'Enable and Log Out' button, similar to GOK. (Bug #531693)
Modified:
trunk/ChangeLog
trunk/src/dwell-click-applet.c
trunk/src/mt-common.c
trunk/src/mt-common.h
trunk/src/mt-main.c
trunk/src/pointer-capture-applet.c
Modified: trunk/src/dwell-click-applet.c
==============================================================================
--- trunk/src/dwell-click-applet.c (original)
+++ trunk/src/dwell-click-applet.c Thu May 8 06:41:04 2008
@@ -217,9 +217,9 @@
"mousetweaks",
NULL,
&error)) {
- mt_show_dialog (_("Couldn't display help"),
- error->message,
- GTK_MESSAGE_ERROR);
+ mt_common_show_dialog (_("Couldn't display help"),
+ error->message,
+ MT_MESSAGE_WARNING);
g_error_free (error);
}
}
Modified: trunk/src/mt-common.c
==============================================================================
--- trunk/src/mt-common.c (original)
+++ trunk/src/mt-common.c Thu May 8 06:41:04 2008
@@ -22,34 +22,48 @@
#include "mt-common.h"
gint
-mt_show_dialog (const gchar *primary,
- const gchar *secondary,
- GtkMessageType type)
+mt_common_show_dialog (const gchar *primary,
+ const gchar *secondary,
+ MtMessageType type)
{
GtkWidget *dialog;
gint ret;
- dialog = gtk_message_dialog_new (NULL,
- GTK_DIALOG_MODAL,
- type,
- GTK_BUTTONS_NONE,
- primary);
- gtk_window_set_title (GTK_WINDOW(dialog), "Mousetweaks");
- gtk_window_set_icon_name (GTK_WINDOW(dialog), MT_ICON_NAME);
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG(dialog),
+ dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_NONE, 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),
secondary);
-
- if (type == GTK_MESSAGE_QUESTION)
- gtk_dialog_add_buttons (GTK_DIALOG(dialog),
+ 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);
- else
- gtk_dialog_add_button (GTK_DIALOG(dialog),
+ 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);
+ }
- gtk_widget_show_all (dialog);
- ret = gtk_dialog_run (GTK_DIALOG(dialog));
+ ret = gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
return ret;
Modified: trunk/src/mt-common.h
==============================================================================
--- trunk/src/mt-common.h (original)
+++ trunk/src/mt-common.h Thu May 8 06:41:04 2008
@@ -45,6 +45,8 @@
#define OPT_STYLE MT_GCONF_HOME "/button_layout"
#define OPT_ANIMATE MT_GCONF_HOME "/animate_cursor"
+#define GNOME_A11Y_KEY "/desktop/gnome/interface/accessibility"
+
enum {
DWELL_MODE_CTW = 0,
DWELL_MODE_GESTURE
@@ -66,9 +68,16 @@
DIRECTION_DISABLE
};
-gint mt_show_dialog (const gchar *primary,
- const gchar *secondary,
- GtkMessageType type);
+typedef enum {
+ MT_MESSAGE_ERROR = 0,
+ MT_MESSAGE_WARNING,
+ MT_MESSAGE_QUESTION,
+ MT_MESSAGE_LOGOUT
+} MtMessageType;
+
+gint mt_common_show_dialog (const gchar *primary,
+ const gchar *secondary,
+ MtMessageType type);
G_END_DECLS
Modified: trunk/src/mt-main.c
==============================================================================
--- trunk/src/mt-main.c (original)
+++ trunk/src/mt-main.c Thu May 8 06:41:04 2008
@@ -27,6 +27,10 @@
#include <gdk/gdkx.h>
#include <cspi/spi.h>
+#include <libgnome/gnome-program.h>
+#include <libgnomeui/gnome-ui-init.h>
+#include <libgnomeui/gnome-client.h>
+
#include "mt-common.h"
#include "mt-service.h"
#include "mt-pidfile.h"
@@ -338,8 +342,10 @@
return FALSE;
cr = cairo_create (surface);
- if (cairo_status (cr) != CAIRO_STATUS_SUCCESS)
+ if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) {
+ cairo_surface_destroy (surface);
return FALSE;
+ }
target = mt_timer_get_target (timer);
cairo_set_operator (cr, CAIRO_OPERATOR_ATOP);
@@ -509,6 +515,36 @@
gconf_client_get_int (mt->client, OPT_G_RIGHT, NULL);
}
+static gboolean
+accessibility_enabled (MTClosure *mt,
+ gint spi_status)
+{
+ gboolean a11y;
+
+ a11y = gconf_client_get_bool (mt->client, GNOME_A11Y_KEY, NULL);
+ if (!a11y || spi_status != 0) {
+ gint ret;
+
+ ret = mt_common_show_dialog
+ (_("Assistive Technology Support Is Not Enabled"),
+ _("To enable support for assistive technologies "
+ "and log in to a new session with the change enabled, click:"
+ "\n\n"
+ "\"Enable and Log Out\""),
+ MT_MESSAGE_LOGOUT);
+ if (ret == GTK_RESPONSE_ACCEPT) {
+ GnomeClient *session;
+
+ gconf_client_set_bool (mt->client, GNOME_A11Y_KEY, TRUE, NULL);
+ if ((session = gnome_master_client ()))
+ gnome_client_request_save (session, GNOME_SAVE_GLOBAL, TRUE,
+ GNOME_INTERACT_ANY, FALSE, TRUE);
+ }
+ return FALSE;
+ }
+ return TRUE;
+}
+
static MTClosure *
mt_closure_init (void)
{
@@ -559,13 +595,11 @@
int
main (int argc, char **argv)
{
- MTClosure *mt;
- MtCursorManager *manager;
- AccessibleEventListener *bl, *ml;
pid_t pid;
gboolean shutdown = FALSE, ctw = FALSE;
gchar *mode = NULL, *enable = NULL;
gint pos_x = -1, pos_y = -1;
+ GnomeProgram *program;
GOptionContext *context;
GOptionEntry entries[] = {
{"enable", 'e', 0, G_OPTION_ARG_STRING, &enable,
@@ -589,9 +623,11 @@
context = g_option_context_new (_("- GNOME mousetweaks daemon"));
g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
- g_option_context_add_group (context, gtk_get_option_group (FALSE));
- g_option_context_parse (context, &argc, &argv, NULL);
- g_option_context_free (context);
+ program = gnome_program_init (PACKAGE, VERSION, LIBGNOMEUI_MODULE,
+ argc, argv,
+ GNOME_PARAM_GOPTION_CONTEXT, context,
+ GNOME_PARAM_NONE);
+ g_set_application_name ("Mousetweaks");
if (shutdown) {
int ret;
@@ -601,11 +637,13 @@
else
g_print ("Shutdown successful.\n");
+ g_object_unref (program);
return ret < 0 ? 1 : 0;
}
- if ((pid = mt_pidfile_is_running()) >= 0) {
+ if ((pid = mt_pidfile_is_running ()) >= 0) {
g_print ("Daemon is already running. (PID %u)\n", pid);
+ g_object_unref (program);
return 1;
}
@@ -613,12 +651,20 @@
if ((pid = fork ()) < 0) {
g_print ("Fork failed.\n");
+ g_object_unref (program);
return 1;
}
else if (pid) {
+ /* Parent return */
return 0;
}
else {
+ /* Child process */
+ MTClosure *mt;
+ MtCursorManager *manager;
+ AccessibleEventListener *bl, *ml;
+ gint spi_status;
+
if (mt_pidfile_create () < 0)
goto FINISH;
@@ -627,21 +673,15 @@
signal (SIGQUIT, signal_handler);
signal (SIGHUP, signal_handler);
- gtk_init (&argc, &argv);
-
mt = mt_closure_init ();
if (!mt)
goto FINISH;
- if (SPI_init () != 0) {
- mt_show_dialog (_("Assistive Technologies not enabled"),
- _("Mousetweaks requires Assistive Technologies."),
- GTK_MESSAGE_ERROR);
-
- /* make sure we leave in a clean state */
+ spi_status = SPI_init ();
+ if (!accessibility_enabled (mt, spi_status)) {
+ /* disable options again */
gconf_client_set_bool (mt->client, OPT_DELAY, FALSE, NULL);
gconf_client_set_bool (mt->client, OPT_DWELL, FALSE, NULL);
-
mt_closure_free (mt);
goto FINISH;
}
@@ -694,18 +734,17 @@
mt_cursor_manager_restore_all (manager);
g_object_unref (manager);
- }
-
-CLEANUP:
- SPI_deregisterGlobalEventListenerAll (bl);
- AccessibleDeviceListener_unref (bl);
- SPI_deregisterGlobalEventListenerAll (ml);
- AccessibleEventListener_unref (ml);
- SPI_exit ();
- mt_closure_free (mt);
-
-FINISH:
- mt_pidfile_remove ();
+ CLEANUP:
+ SPI_deregisterGlobalEventListenerAll (bl);
+ AccessibleDeviceListener_unref (bl);
+ SPI_deregisterGlobalEventListenerAll (ml);
+ AccessibleEventListener_unref (ml);
+ SPI_exit ();
+ mt_closure_free (mt);
+ FINISH:
+ mt_pidfile_remove ();
+ g_object_unref (program);
+ }
return 0;
}
Modified: trunk/src/pointer-capture-applet.c
==============================================================================
--- trunk/src/pointer-capture-applet.c (original)
+++ trunk/src/pointer-capture-applet.c Thu May 8 06:41:04 2008
@@ -70,9 +70,9 @@
"mousetweaks",
NULL,
&error)) {
- mt_show_dialog (_("Couldn't display help"),
- error->message,
- GTK_MESSAGE_ERROR);
+ mt_common_show_dialog (_("Couldn't display help"),
+ error->message,
+ MT_MESSAGE_WARNING);
g_error_free (error);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]