Utility file to register the images used by capplets as stock-icons
2003-01-08 Rajkumar Sivasamy <rajkumar.siva@wipro.com> * capplets/common/capplet-stock-icons.[ch]: Utility file to register the images used by capplets as stock-icons * capplets/common/Makefile.am: Changes to include the above file * capplets/keyboard/gnome-keyboard-properties.c: * capplets/accessibility/keyboard/accessibility-keyboard.c: Use stock-icons * capplets/mouse/Makefile.am: * capplets/mouse/gnome-mouse-properties.c: Use stock-icons. Also register the icons through capplet-stock-icons.[ch] instead of doing it here. Fixes Bug 101977
This commit is contained in:
parent
564733fb5d
commit
b0184362c0
8 changed files with 255 additions and 140 deletions
18
ChangeLog
18
ChangeLog
|
@ -1,3 +1,21 @@
|
||||||
|
2003-01-08 Rajkumar Sivasamy <rajkumar.siva@wipro.com>
|
||||||
|
|
||||||
|
* capplets/common/capplet-stock-icons.[ch]: Utility file to register
|
||||||
|
the images used by capplets as stock-icons
|
||||||
|
|
||||||
|
* capplets/common/Makefile.am: Changes to include the above file
|
||||||
|
|
||||||
|
* capplets/keyboard/gnome-keyboard-properties.c:
|
||||||
|
* capplets/accessibility/keyboard/accessibility-keyboard.c:
|
||||||
|
Use stock-icons
|
||||||
|
|
||||||
|
* capplets/mouse/Makefile.am:
|
||||||
|
* capplets/mouse/gnome-mouse-properties.c:
|
||||||
|
Use stock-icons. Also register the icons through capplet-stock-icons.[ch]
|
||||||
|
instead of doing it here.
|
||||||
|
|
||||||
|
Fixes Bug 101977
|
||||||
|
|
||||||
2002-11-29 Remi Cohen-Scali <remi@cohen-scali.com>
|
2002-11-29 Remi Cohen-Scali <remi@cohen-scali.com>
|
||||||
|
|
||||||
Reviewed by: Jody Goldberg <jody@gnome.org>
|
Reviewed by: Jody Goldberg <jody@gnome.org>
|
||||||
|
|
|
@ -33,10 +33,10 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "capplet-util.h"
|
#include "capplet-util.h"
|
||||||
|
#include "capplet-stock-icons.h"
|
||||||
#include "gconf-property-editor.h"
|
#include "gconf-property-editor.h"
|
||||||
#include "activate-settings-daemon.h"
|
#include "activate-settings-daemon.h"
|
||||||
|
|
||||||
#define IDIR GNOMECC_DATA_DIR "/pixmaps/"
|
|
||||||
#define CONFIG_ROOT "/desktop/gnome/accessibility/keyboard"
|
#define CONFIG_ROOT "/desktop/gnome/accessibility/keyboard"
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
|
@ -47,22 +47,22 @@ static struct {
|
||||||
char const * const content [3];
|
char const * const content [3];
|
||||||
gboolean always_enabled;
|
gboolean always_enabled;
|
||||||
} const features [] = {
|
} const features [] = {
|
||||||
{ "repeatkeys_enable", "repeatkeys_image", IDIR "keyboard-repeat.png",
|
{ "repeatkeys_enable", "repeatkeys_image", KEYBOARD_REPEAT,
|
||||||
"/desktop/gnome/peripherals/keyboard/repeat",
|
"/desktop/gnome/peripherals/keyboard/repeat",
|
||||||
{ "repeatkeys_table", NULL, NULL }, TRUE },
|
{ "repeatkeys_table", NULL, NULL }, TRUE },
|
||||||
{ "bouncekeys_enable", "bouncekeys_image", IDIR "accessibility-keyboard-bouncekey.png",
|
{ "bouncekeys_enable", "bouncekeys_image", ACCESSX_KEYBOARD_BOUNCE,
|
||||||
CONFIG_ROOT "/bouncekeys_enable",
|
CONFIG_ROOT "/bouncekeys_enable",
|
||||||
{ "bouncekey_table", NULL, NULL }, FALSE },
|
{ "bouncekey_table", NULL, NULL }, FALSE },
|
||||||
{ "slowkeys_enable", "slowkeys_image", IDIR "accessibility-keyboard-slowkey.png",
|
{ "slowkeys_enable", "slowkeys_image", ACCESSX_KEYBOARD_SLOW,
|
||||||
CONFIG_ROOT "/slowkeys_enable",
|
CONFIG_ROOT "/slowkeys_enable",
|
||||||
{ "slowkeys_table", NULL, NULL }, FALSE },
|
{ "slowkeys_table", NULL, NULL }, FALSE },
|
||||||
{ "mousekeys_enable", "mousekeys_image", IDIR "accessibility-keyboard-mousekey.png",
|
{ "mousekeys_enable", "mousekeys_image", ACCESSX_KEYBOARD_MOUSE,
|
||||||
CONFIG_ROOT "/mousekeys_enable",
|
CONFIG_ROOT "/mousekeys_enable",
|
||||||
{ "mousekeys_table", NULL, NULL }, FALSE },
|
{ "mousekeys_table", NULL, NULL }, FALSE },
|
||||||
{ "stickykeys_enable", "stickykeys_image", IDIR "accessibility-keyboard-stickykey.png",
|
{ "stickykeys_enable", "stickykeys_image", ACCESSX_KEYBOARD_STICK,
|
||||||
CONFIG_ROOT "/stickykeys_enable",
|
CONFIG_ROOT "/stickykeys_enable",
|
||||||
{ "stickeykeys_table", NULL, NULL }, FALSE },
|
{ "stickeykeys_table", NULL, NULL }, FALSE },
|
||||||
{ "togglekeys_enable", "togglekeys_image", IDIR "accessibility-keyboard-togglekey.png",
|
{ "togglekeys_enable", "togglekeys_image", ACCESSX_KEYBOARD_TOGGLE,
|
||||||
CONFIG_ROOT "/togglekeys_enable",
|
CONFIG_ROOT "/togglekeys_enable",
|
||||||
{ NULL, NULL, NULL }, FALSE },
|
{ NULL, NULL, NULL }, FALSE },
|
||||||
{ "timeout_enable", NULL, NULL,
|
{ "timeout_enable", NULL, NULL,
|
||||||
|
@ -224,8 +224,9 @@ setup_images (GladeXML *dialog)
|
||||||
int i = G_N_ELEMENTS (features);
|
int i = G_N_ELEMENTS (features);
|
||||||
while (i-- > 0)
|
while (i-- > 0)
|
||||||
if (features [i].image != NULL)
|
if (features [i].image != NULL)
|
||||||
gtk_image_set_from_file (GTK_IMAGE (WID (features [i].image)),
|
gtk_image_set_from_stock (GTK_IMAGE (WID (features [i].image)),
|
||||||
features [i].image_file);
|
features [i].image_file,
|
||||||
|
keyboard_capplet_icon_get_size ());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -258,6 +259,8 @@ static void
|
||||||
setup_dialog (GladeXML *dialog, GConfChangeSet *changeset)
|
setup_dialog (GladeXML *dialog, GConfChangeSet *changeset)
|
||||||
{
|
{
|
||||||
GtkWidget *master_enable = WID ("master_enable");
|
GtkWidget *master_enable = WID ("master_enable");
|
||||||
|
|
||||||
|
capplet_init_stock_icons ();
|
||||||
setup_images (dialog);
|
setup_images (dialog);
|
||||||
setup_ranges (dialog, changeset);
|
setup_ranges (dialog, changeset);
|
||||||
setup_toggles (dialog, changeset);
|
setup_toggles (dialog, changeset);
|
||||||
|
|
|
@ -19,6 +19,7 @@ libcommon_la_SOURCES = \
|
||||||
gconf-property-editor-marshal.c gconf-property-editor-marshal.h \
|
gconf-property-editor-marshal.c gconf-property-editor-marshal.h \
|
||||||
file-transfer-dialog.c file-transfer-dialog.h \
|
file-transfer-dialog.c file-transfer-dialog.h \
|
||||||
gnome-theme-info.c gnome-theme-info.h \
|
gnome-theme-info.c gnome-theme-info.h \
|
||||||
wm-common.c wm-common.h
|
wm-common.c wm-common.h \
|
||||||
|
capplet-stock-icons.c capplet-stock-icons.h
|
||||||
|
|
||||||
libcommon_la_LIBADD = $(top_builddir)/libbackground/libbackground.la
|
libcommon_la_LIBADD = $(top_builddir)/libbackground/libbackground.la
|
||||||
|
|
137
capplets/common/capplet-stock-icons.c
Normal file
137
capplets/common/capplet-stock-icons.c
Normal file
|
@ -0,0 +1,137 @@
|
||||||
|
/*
|
||||||
|
* capplet-stock-icons.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2002 Sun Microsystems, Inc.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* Rajkumar Sivasamy <rajkumar.siva@wipro.com>
|
||||||
|
* Taken bits of code from panel-stock-icons.c, Thanks Mark <mark@skynet.ie>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <gtk/gtkstock.h>
|
||||||
|
#include <gtk/gtkiconfactory.h>
|
||||||
|
#include <gnome.h>
|
||||||
|
|
||||||
|
#include "capplet-stock-icons.h"
|
||||||
|
|
||||||
|
static GtkIconSize keyboard_capplet_icon_size = 0;
|
||||||
|
static GtkIconSize mouse_capplet_icon_size = 0;
|
||||||
|
static GtkIconSize mouse_capplet_dblclck_icon_size = 0;
|
||||||
|
|
||||||
|
GtkIconSize
|
||||||
|
keyboard_capplet_icon_get_size (void)
|
||||||
|
{
|
||||||
|
return keyboard_capplet_icon_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkIconSize
|
||||||
|
mouse_capplet_icon_get_size (void)
|
||||||
|
{
|
||||||
|
return mouse_capplet_icon_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkIconSize
|
||||||
|
mouse_capplet_dblclck_icon_get_size (void)
|
||||||
|
{
|
||||||
|
return mouse_capplet_dblclck_icon_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
char *stock_id;
|
||||||
|
char *name;
|
||||||
|
} CappletStockIcon;
|
||||||
|
|
||||||
|
|
||||||
|
static CappletStockIcon items [] = {
|
||||||
|
{ KEYBOARD_REPEAT, "keyboard-repeat.png" },
|
||||||
|
{ KEYBOARD_CURSOR, "keyboard-cursor.png" },
|
||||||
|
{ KEYBOARD_VOLUME, "keyboard-volume.png" },
|
||||||
|
{ KEYBOARD_BELL, "keyboard-bell.png" },
|
||||||
|
{ ACCESSX_KEYBOARD_BOUNCE, "accessibility-keyboard-bouncekey.png"},
|
||||||
|
{ ACCESSX_KEYBOARD_SLOW, "accessibility-keyboard-slowkey.png"},
|
||||||
|
{ ACCESSX_KEYBOARD_MOUSE, "accessibility-keyboard-mousekey.png"},
|
||||||
|
{ ACCESSX_KEYBOARD_STICK, "accessibility-keyboard-stickykey.png"},
|
||||||
|
{ ACCESSX_KEYBOARD_TOGGLE, "accessibility-keyboard-togglekey.png"},
|
||||||
|
{ MOUSE_DBLCLCK_MAYBE, "double-click-maybe.png"},
|
||||||
|
{ MOUSE_DBLCLCK_ON, "double-click-on.png"},
|
||||||
|
{ MOUSE_DBLCLCK_OFF, "double-click-off.png"},
|
||||||
|
{ MOUSE_RIGHT_HANDED, "mouse-right.png"},
|
||||||
|
{ MOUSE_LEFT_HANDED, "mouse-left.png"}
|
||||||
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
capplet_register_stock_icons (GtkIconFactory *factory)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
GtkIconSource *source;
|
||||||
|
GnomeProgram *program;
|
||||||
|
|
||||||
|
source = gtk_icon_source_new ();
|
||||||
|
program = gnome_program_get ();
|
||||||
|
|
||||||
|
for (i = 0; i < G_N_ELEMENTS (items); ++i) {
|
||||||
|
GtkIconSet *icon_set;
|
||||||
|
char *filename;
|
||||||
|
filename = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_APP_PIXMAP, items[i].name, TRUE, NULL);
|
||||||
|
|
||||||
|
if (!filename) {
|
||||||
|
g_warning (_("Unable to load capplet stock icon '%s'\n"), items[i].name);
|
||||||
|
icon_set = gtk_icon_factory_lookup_default (GTK_STOCK_MISSING_IMAGE);
|
||||||
|
gtk_icon_factory_add (factory, items[i].stock_id, icon_set);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_icon_source_set_filename (source, filename);
|
||||||
|
g_free (filename);
|
||||||
|
|
||||||
|
icon_set = gtk_icon_set_new ();
|
||||||
|
gtk_icon_set_add_source (icon_set, source);
|
||||||
|
gtk_icon_factory_add (factory, items[i].stock_id, icon_set);
|
||||||
|
gtk_icon_set_unref (icon_set);
|
||||||
|
}
|
||||||
|
gtk_icon_source_free (source);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
capplet_init_stock_icons (void)
|
||||||
|
{
|
||||||
|
GtkIconFactory *factory;
|
||||||
|
static gboolean initialized = FALSE;
|
||||||
|
|
||||||
|
if (initialized)
|
||||||
|
return;
|
||||||
|
initialized = TRUE;
|
||||||
|
|
||||||
|
factory = gtk_icon_factory_new ();
|
||||||
|
gtk_icon_factory_add_default (factory);
|
||||||
|
capplet_register_stock_icons (factory);
|
||||||
|
|
||||||
|
keyboard_capplet_icon_size = gtk_icon_size_register ("keyboard-capplet",
|
||||||
|
KEYBOARD_CAPPLET_DEFAULT_ICON_SIZE,
|
||||||
|
KEYBOARD_CAPPLET_DEFAULT_ICON_SIZE);
|
||||||
|
|
||||||
|
mouse_capplet_icon_size = gtk_icon_size_register ("mouse-capplet",
|
||||||
|
MOUSE_CAPPLET_DEFAULT_WIDTH,
|
||||||
|
MOUSE_CAPPLET_DEFAULT_HEIGHT);
|
||||||
|
|
||||||
|
mouse_capplet_dblclck_icon_size = gtk_icon_size_register ("mouse-capplet-dblclck-icon",
|
||||||
|
MOUSE_CAPPLET_DBLCLCK_ICON_SIZE,
|
||||||
|
MOUSE_CAPPLET_DBLCLCK_ICON_SIZE);
|
||||||
|
g_object_unref (factory);
|
||||||
|
}
|
62
capplets/common/capplet-stock-icons.h
Normal file
62
capplets/common/capplet-stock-icons.h
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
/*
|
||||||
|
* capplet-stock-icons.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 2002 Sun Microsystems, Inc.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* Rajkumar Sivasamy <rajkumar.siva@wipro.com>
|
||||||
|
* Taken bits of code from panel-stock-icons.h, Thanks Mark <mark@skynet.ie>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __CAPPLET_STOCK_ICONS_H__
|
||||||
|
#define __CAPPLET_STOCK_ICONS_H__
|
||||||
|
|
||||||
|
#include <glib/gmacros.h>
|
||||||
|
#include <gtk/gtkenums.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define KEYBOARD_CAPPLET_DEFAULT_ICON_SIZE 48
|
||||||
|
#define MOUSE_CAPPLET_DEFAULT_WIDTH 120
|
||||||
|
#define MOUSE_CAPPLET_DEFAULT_HEIGHT 100
|
||||||
|
#define MOUSE_CAPPLET_DBLCLCK_ICON_SIZE 100
|
||||||
|
|
||||||
|
/* stock icons */
|
||||||
|
#define KEYBOARD_REPEAT "keyboard-repeat"
|
||||||
|
#define KEYBOARD_CURSOR "keyboard-cursor"
|
||||||
|
#define KEYBOARD_VOLUME "keyboard-volume"
|
||||||
|
#define KEYBOARD_BELL "keyboard-bell"
|
||||||
|
#define ACCESSX_KEYBOARD_BOUNCE "accessibility-keyboard-bouncekey"
|
||||||
|
#define ACCESSX_KEYBOARD_SLOW "accessibility-keyboard-slowkey"
|
||||||
|
#define ACCESSX_KEYBOARD_MOUSE "accessibility-keyboard-mousekey"
|
||||||
|
#define ACCESSX_KEYBOARD_STICK "accessibility-keyboard-stickykey"
|
||||||
|
#define ACCESSX_KEYBOARD_TOGGLE "accessibility-keyboard-togglekey"
|
||||||
|
#define MOUSE_DBLCLCK_MAYBE "mouse-dblclck-maybe"
|
||||||
|
#define MOUSE_DBLCLCK_ON "mouse-dblclck-on"
|
||||||
|
#define MOUSE_DBLCLCK_OFF "mouse-dblclck-off"
|
||||||
|
#define MOUSE_RIGHT_HANDED "mouse-right-handed"
|
||||||
|
#define MOUSE_LEFT_HANDED "mouse-left-handed"
|
||||||
|
|
||||||
|
void capplet_init_stock_icons (void);
|
||||||
|
GtkIconSize keyboard_capplet_icon_get_size (void);
|
||||||
|
GtkIconSize mouse_capplet_icon_get_size (void);
|
||||||
|
GtkIconSize mouse_capplet_dblclck_icon_get_size (void);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __CAPPLET_STOCK_ICONS_H__ */
|
|
@ -35,8 +35,10 @@
|
||||||
#include "capplet-util.h"
|
#include "capplet-util.h"
|
||||||
#include "gconf-property-editor.h"
|
#include "gconf-property-editor.h"
|
||||||
#include "activate-settings-daemon.h"
|
#include "activate-settings-daemon.h"
|
||||||
|
#include "capplet-stock-icons.h"
|
||||||
#include <../accessibility/keyboard/accessibility-keyboard.h>
|
#include <../accessibility/keyboard/accessibility-keyboard.h>
|
||||||
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
RESPONSE_APPLY = 1,
|
RESPONSE_APPLY = 1,
|
||||||
|
@ -186,18 +188,12 @@ setup_dialog (GladeXML *dialog,
|
||||||
|
|
||||||
/* load all the images */
|
/* load all the images */
|
||||||
program = gnome_program_get ();
|
program = gnome_program_get ();
|
||||||
filename = gnome_program_locate_file (program, GNOME_FILE_DOMAIN_APP_PIXMAP, "keyboard-repeat.png", TRUE, NULL);
|
|
||||||
gtk_image_set_from_file (GTK_IMAGE (WID ("repeat_image")), filename);
|
capplet_init_stock_icons ();
|
||||||
g_free (filename);
|
gtk_image_set_from_stock (GTK_IMAGE (WID ("repeat_image")), KEYBOARD_REPEAT, keyboard_capplet_icon_get_size());
|
||||||
filename = gnome_program_locate_file (program, GNOME_FILE_DOMAIN_APP_PIXMAP, "keyboard-cursor.png", TRUE, NULL);
|
gtk_image_set_from_stock (GTK_IMAGE (WID ("cursor_image")), KEYBOARD_CURSOR, keyboard_capplet_icon_get_size());
|
||||||
gtk_image_set_from_file (GTK_IMAGE (WID ("cursor_image")), filename);
|
gtk_image_set_from_stock (GTK_IMAGE (WID ("volume_image")), KEYBOARD_VOLUME, keyboard_capplet_icon_get_size());
|
||||||
g_free (filename);
|
gtk_image_set_from_stock (GTK_IMAGE (WID ("bell_image")), KEYBOARD_BELL, keyboard_capplet_icon_get_size());
|
||||||
filename = gnome_program_locate_file (program, GNOME_FILE_DOMAIN_APP_PIXMAP, "keyboard-volume.png", TRUE, NULL);
|
|
||||||
gtk_image_set_from_file (GTK_IMAGE (WID ("volume_image")), filename);
|
|
||||||
g_free (filename);
|
|
||||||
filename = gnome_program_locate_file (program, GNOME_FILE_DOMAIN_APP_PIXMAP, "keyboard-bell.png", TRUE, NULL);
|
|
||||||
gtk_image_set_from_file (GTK_IMAGE (WID ("bell_image")), filename);
|
|
||||||
g_free (filename);
|
|
||||||
|
|
||||||
peditor = gconf_peditor_new_boolean
|
peditor = gconf_peditor_new_boolean
|
||||||
(changeset, "/desktop/gnome/peripherals/keyboard/repeat", WID ("repeat_toggle"), NULL);
|
(changeset, "/desktop/gnome/peripherals/keyboard/repeat", WID ("repeat_toggle"), NULL);
|
||||||
|
|
|
@ -37,20 +37,6 @@ desktopdir = $(GNOMECC_DESKTOP_DIR)
|
||||||
Desktop_in_files = mouse.desktop.in
|
Desktop_in_files = mouse.desktop.in
|
||||||
desktop_DATA = $(Desktop_in_files:.desktop.in=.desktop)
|
desktop_DATA = $(Desktop_in_files:.desktop.in=.desktop)
|
||||||
|
|
||||||
IMAGES = double-click-maybe.png double-click-off.png double-click-on.png
|
|
||||||
|
|
||||||
VARIABLES=mouse_dblclck_maybe_data $(srcdir)/double-click-maybe.png \
|
|
||||||
mouse_dblclck_on_data $(srcdir)/double-click-on.png \
|
|
||||||
mouse_dblclck_off_data $(srcdir)/double-click-off.png
|
|
||||||
|
|
||||||
BUILT_SOURCES = inlinepixbufs.h
|
|
||||||
CLEANFILES = inlinepixbufs.h
|
|
||||||
|
|
||||||
inlinepixbufs.h: $(IMAGES)
|
|
||||||
$(GDK_PIXBUF_CSOURCE) --raw --build-list $(VARIABLES) >$(srcdir)/inlinepixbufs.h
|
|
||||||
|
|
||||||
$(OBJECTS): inlinepixbufs.h
|
|
||||||
|
|
||||||
INCLUDES = $(GNOMECC_CAPPLETS_CFLAGS)
|
INCLUDES = $(GNOMECC_CAPPLETS_CFLAGS)
|
||||||
CLEANFILES = $(GNOMECC_CAPPLETS_CLEANFILES)
|
CLEANFILES = $(GNOMECC_CAPPLETS_CLEANFILES)
|
||||||
EXTRA_DIST = $(Glade_DATA) $(icons_DATA) $(Desktop_in_files) $(pixmap_DATA) $(cursorfont_DATA) $(IMAGES)
|
EXTRA_DIST = $(Glade_DATA) $(icons_DATA) $(Desktop_in_files) $(pixmap_DATA) $(cursorfont_DATA)
|
||||||
|
|
|
@ -37,23 +37,12 @@
|
||||||
#include "capplet-util.h"
|
#include "capplet-util.h"
|
||||||
#include "gconf-property-editor.h"
|
#include "gconf-property-editor.h"
|
||||||
#include "activate-settings-daemon.h"
|
#include "activate-settings-daemon.h"
|
||||||
#include "inlinepixbufs.h"
|
#include "capplet-stock-icons.h"
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
|
||||||
#define MOUSE_DBLCLCK_MAYBE "mouse-dblclck-maybe"
|
|
||||||
#define MOUSE_DBLCLCK_ON "mouse-dblclck-on"
|
|
||||||
#define MOUSE_DBLCLCK_OFF "mouse-dblclck-off"
|
|
||||||
|
|
||||||
#define MOUSE_CAPPLET_DEFAULT_ICON_SIZE 100
|
|
||||||
|
|
||||||
static void mouse_init_stock_icons (void);
|
|
||||||
static void register_mouse_stock_icons (GtkIconFactory *factory);
|
|
||||||
|
|
||||||
static GtkIconSize mouse_capplet_icon_size = 0;
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/* A quick custom widget to ensure that the left handed toggle works no matter
|
/* A quick custom widget to ensure that the left handed toggle works no matter
|
||||||
* which button is pressed.
|
* which button is pressed.
|
||||||
|
@ -110,11 +99,9 @@ enum
|
||||||
|
|
||||||
#define DOUBLE_CLICK_KEY "/desktop/gnome/peripherals/mouse/double_click"
|
#define DOUBLE_CLICK_KEY "/desktop/gnome/peripherals/mouse/double_click"
|
||||||
#define CURSOR_FONT_KEY "/desktop/gnome/peripherals/mouse/cursor_font"
|
#define CURSOR_FONT_KEY "/desktop/gnome/peripherals/mouse/cursor_font"
|
||||||
/* Write-once data; global for convenience. Set only by load_pixbufs */
|
|
||||||
|
|
||||||
GdkPixbuf *left_handed_pixbuf;
|
|
||||||
GdkPixbuf *right_handed_pixbuf;
|
|
||||||
GConfClient *client;
|
GConfClient *client;
|
||||||
|
|
||||||
/* State in testing the double-click speed. Global for a great deal of
|
/* State in testing the double-click speed. Global for a great deal of
|
||||||
* convenience
|
* convenience
|
||||||
*/
|
*/
|
||||||
|
@ -273,7 +260,7 @@ test_maybe_timeout (struct test_data_t *data)
|
||||||
double_click_state = DOUBLE_CLICK_TEST_OFF;
|
double_click_state = DOUBLE_CLICK_TEST_OFF;
|
||||||
|
|
||||||
gtk_image_set_from_stock (GTK_IMAGE (data->image),
|
gtk_image_set_from_stock (GTK_IMAGE (data->image),
|
||||||
MOUSE_DBLCLCK_OFF, mouse_capplet_icon_size);
|
MOUSE_DBLCLCK_OFF, mouse_capplet_dblclck_icon_get_size());
|
||||||
|
|
||||||
*data->timeout_id = 0;
|
*data->timeout_id = 0;
|
||||||
|
|
||||||
|
@ -335,15 +322,15 @@ event_box_button_press_event (GtkWidget *widget,
|
||||||
switch (double_click_state) {
|
switch (double_click_state) {
|
||||||
case DOUBLE_CLICK_TEST_ON:
|
case DOUBLE_CLICK_TEST_ON:
|
||||||
gtk_image_set_from_stock (GTK_IMAGE (image),
|
gtk_image_set_from_stock (GTK_IMAGE (image),
|
||||||
MOUSE_DBLCLCK_ON, mouse_capplet_icon_size);
|
MOUSE_DBLCLCK_ON, mouse_capplet_dblclck_icon_get_size());
|
||||||
break;
|
break;
|
||||||
case DOUBLE_CLICK_TEST_MAYBE:
|
case DOUBLE_CLICK_TEST_MAYBE:
|
||||||
gtk_image_set_from_stock (GTK_IMAGE (image),
|
gtk_image_set_from_stock (GTK_IMAGE (image),
|
||||||
MOUSE_DBLCLCK_MAYBE, mouse_capplet_icon_size);
|
MOUSE_DBLCLCK_MAYBE, mouse_capplet_dblclck_icon_get_size());
|
||||||
break;
|
break;
|
||||||
case DOUBLE_CLICK_TEST_OFF:
|
case DOUBLE_CLICK_TEST_OFF:
|
||||||
gtk_image_set_from_stock (GTK_IMAGE (image),
|
gtk_image_set_from_stock (GTK_IMAGE (image),
|
||||||
MOUSE_DBLCLCK_OFF, mouse_capplet_icon_size);
|
MOUSE_DBLCLCK_OFF, mouse_capplet_dblclck_icon_get_size());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -357,38 +344,12 @@ event_box_button_press_event (GtkWidget *widget,
|
||||||
static void
|
static void
|
||||||
left_handed_toggle_cb (GConfPropertyEditor *peditor, const gchar *key, const GConfValue *value, GtkWidget *image)
|
left_handed_toggle_cb (GConfPropertyEditor *peditor, const gchar *key, const GConfValue *value, GtkWidget *image)
|
||||||
{
|
{
|
||||||
if (value && gconf_value_get_bool (value))
|
if (value && gconf_value_get_bool (value)) {
|
||||||
g_object_set (G_OBJECT (image),
|
gtk_image_set_from_stock (GTK_IMAGE (image), MOUSE_LEFT_HANDED, mouse_capplet_icon_get_size ());
|
||||||
"pixbuf", left_handed_pixbuf,
|
}
|
||||||
NULL);
|
else {
|
||||||
else
|
gtk_image_set_from_stock (GTK_IMAGE (image), MOUSE_RIGHT_HANDED, mouse_capplet_icon_get_size ());
|
||||||
g_object_set (G_OBJECT (image),
|
}
|
||||||
"pixbuf", right_handed_pixbuf,
|
|
||||||
NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Load the pixbufs we are going to use */
|
|
||||||
|
|
||||||
static void
|
|
||||||
load_pixbufs (void)
|
|
||||||
{
|
|
||||||
static gboolean called = FALSE;
|
|
||||||
gchar *filename;
|
|
||||||
GnomeProgram *program;
|
|
||||||
|
|
||||||
if (called) return;
|
|
||||||
|
|
||||||
program = gnome_program_get ();
|
|
||||||
|
|
||||||
filename = gnome_program_locate_file (program, GNOME_FILE_DOMAIN_APP_PIXMAP, "mouse-left.png", TRUE, NULL);
|
|
||||||
left_handed_pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
|
|
||||||
g_free (filename);
|
|
||||||
|
|
||||||
filename = gnome_program_locate_file (program, GNOME_FILE_DOMAIN_APP_PIXMAP, "mouse-right.png", TRUE, NULL);
|
|
||||||
right_handed_pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
|
|
||||||
g_free (filename);
|
|
||||||
|
|
||||||
called = TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gchar *
|
static gchar *
|
||||||
|
@ -541,7 +502,7 @@ setup_dialog (GladeXML *dialog, GConfChangeSet *changeset)
|
||||||
gconf_value_free (value);
|
gconf_value_free (value);
|
||||||
|
|
||||||
/* Double-click time */
|
/* Double-click time */
|
||||||
gtk_image_set_from_stock (GTK_IMAGE (WID ("double_click_image")), MOUSE_DBLCLCK_OFF, mouse_capplet_icon_size);
|
gtk_image_set_from_stock (GTK_IMAGE (WID ("double_click_image")), MOUSE_DBLCLCK_OFF, mouse_capplet_dblclck_icon_get_size ());
|
||||||
g_object_set_data (G_OBJECT (WID ("double_click_eventbox")), "image", WID ("double_click_image"));
|
g_object_set_data (G_OBJECT (WID ("double_click_eventbox")), "image", WID ("double_click_image"));
|
||||||
g_signal_connect (WID ("double_click_eventbox"), "button_press_event",
|
g_signal_connect (WID ("double_click_eventbox"), "button_press_event",
|
||||||
G_CALLBACK (event_box_button_press_event), changeset);
|
G_CALLBACK (event_box_button_press_event), changeset);
|
||||||
|
@ -762,7 +723,7 @@ main (int argc, char **argv)
|
||||||
GNOME_PARAM_APP_DATADIR, GNOMECC_DATA_DIR,
|
GNOME_PARAM_APP_DATADIR, GNOMECC_DATA_DIR,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
mouse_init_stock_icons ();
|
capplet_init_stock_icons ();
|
||||||
|
|
||||||
activate_settings_daemon ();
|
activate_settings_daemon ();
|
||||||
|
|
||||||
|
@ -774,7 +735,6 @@ main (int argc, char **argv)
|
||||||
} else {
|
} else {
|
||||||
changeset = NULL;
|
changeset = NULL;
|
||||||
dialog = create_dialog ();
|
dialog = create_dialog ();
|
||||||
load_pixbufs ();
|
|
||||||
setup_dialog (dialog, changeset);
|
setup_dialog (dialog, changeset);
|
||||||
|
|
||||||
dialog_win = WID ("mouse_properties_dialog");
|
dialog_win = WID ("mouse_properties_dialog");
|
||||||
|
@ -789,51 +749,3 @@ main (int argc, char **argv)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
char *stock_id;
|
|
||||||
const guint8 *icon_data;
|
|
||||||
} MouseStockIcon;
|
|
||||||
|
|
||||||
static void
|
|
||||||
register_mouse_stock_icons (GtkIconFactory *factory)
|
|
||||||
{
|
|
||||||
gint i;
|
|
||||||
MouseStockIcon items[] =
|
|
||||||
{
|
|
||||||
{ MOUSE_DBLCLCK_MAYBE, mouse_dblclck_maybe_data },
|
|
||||||
{ MOUSE_DBLCLCK_ON, mouse_dblclck_on_data },
|
|
||||||
{ MOUSE_DBLCLCK_OFF, mouse_dblclck_off_data }
|
|
||||||
};
|
|
||||||
|
|
||||||
for (i = 0; i < G_N_ELEMENTS(items); ++i) {
|
|
||||||
GtkIconSet *icon_set;
|
|
||||||
GdkPixbuf *pixbuf;
|
|
||||||
pixbuf = gdk_pixbuf_new_from_inline (-1, items[i].icon_data,
|
|
||||||
FALSE, NULL);
|
|
||||||
|
|
||||||
icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
|
|
||||||
gtk_icon_factory_add (factory, items[i].stock_id, icon_set);
|
|
||||||
|
|
||||||
gtk_icon_set_unref (icon_set);
|
|
||||||
g_object_unref (G_OBJECT (pixbuf));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
mouse_init_stock_icons (void)
|
|
||||||
{
|
|
||||||
GtkIconFactory *factory;
|
|
||||||
|
|
||||||
factory = gtk_icon_factory_new ();
|
|
||||||
gtk_icon_factory_add_default (factory);
|
|
||||||
|
|
||||||
register_mouse_stock_icons (factory);
|
|
||||||
|
|
||||||
mouse_capplet_icon_size = gtk_icon_size_register ("mouse-capplet-icon",
|
|
||||||
MOUSE_CAPPLET_DEFAULT_ICON_SIZE,
|
|
||||||
MOUSE_CAPPLET_DEFAULT_ICON_SIZE);
|
|
||||||
|
|
||||||
g_object_unref (factory);
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue