Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/lib/ui
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <mpg@redhat.com>2007-10-15 13:39:07 (GMT)
committer Marco Pesenti Gritti <mpg@redhat.com>2007-10-15 13:39:07 (GMT)
commit68ff71a0cbf9c11a9be8878146bf485be9bd8f87 (patch)
tree3d6b5113836b8e90f28bac392338241e3402604a /lib/ui
parent8c36556ba0e25dda950d8ce347fb49d1ba36bb2f (diff)
Split part of the sugar library to sugar-base
Diffstat (limited to 'lib/ui')
-rw-r--r--lib/ui/Makefile.am50
-rw-r--r--lib/ui/eggaccelerators.c702
-rw-r--r--lib/ui/eggaccelerators.h89
-rw-r--r--lib/ui/sexy-icon-entry.c984
-rw-r--r--lib/ui/sexy-icon-entry.h104
-rw-r--r--lib/ui/sugar-address-entry.c694
-rw-r--r--lib/ui/sugar-address-entry.h54
-rw-r--r--lib/ui/sugar-key-grabber.c219
-rw-r--r--lib/ui/sugar-key-grabber.h66
-rw-r--r--lib/ui/sugar-marshal.list1
-rw-r--r--lib/ui/sugar-menu.c63
-rw-r--r--lib/ui/sugar-menu.h56
-rw-r--r--lib/ui/sugar-x11-util.c88
-rw-r--r--lib/ui/sugar-x11-util.h36
14 files changed, 0 insertions, 3206 deletions
diff --git a/lib/ui/Makefile.am b/lib/ui/Makefile.am
deleted file mode 100644
index 5c432be..0000000
--- a/lib/ui/Makefile.am
+++ /dev/null
@@ -1,50 +0,0 @@
-libsugarui_la_CPPFLAGS = \
- $(LIBUI_CFLAGS)
-
-noinst_LTLIBRARIES = libsugarui.la
-
-libsugarui_la_LIBADD = \
- $(LIBUI_LIBS)
-
-libsugarui_la_SOURCES = \
- $(BUILT_SOURCES) \
- eggaccelerators.c \
- eggaccelerators.h \
- sexy-icon-entry.h \
- sexy-icon-entry.c \
- sugar-address-entry.c \
- sugar-address-entry.h \
- sugar-key-grabber.c \
- sugar-key-grabber.h \
- sugar-menu.h \
- sugar-menu.c \
- sugar-x11-util.c \
- sugar-x11-util.h
-
-BUILT_SOURCES = \
- sugar-marshal.c \
- sugar-marshal.h
-
-stamp_files = \
- stamp-sugar-marshal.c \
- stamp-sugar-marshal.h
-
-sugar-marshal.c: stamp-sugar-marshal.c
- @true
-stamp-sugar-marshal.c: sugar-marshal.list
- $(GLIB_GENMARSHAL) --prefix=sugar_marshal \
- $(srcdir)/sugar-marshal.list --header --body > \
- sugar-marshal.c && echo timestamp > $(@F)
-
-sugar-marshal.h: stamp-sugar-marshal.h
- @true
-stamp-sugar-marshal.h: sugar-marshal.list
- $(GLIB_GENMARSHAL) --prefix=sugar_marshal \
- $(srcdir)/sugar-marshal.list --header > \
- sugar-marshal.h && echo timestamp > $(@F)
-
-CLEANFILES = $(stamp_files) $(BUILT_SOURCES)
-DISTCLEANFILES = $(stamp_files) $(BUILT_SOURCES)
-MAINTAINERCLEANFILES = $(stamp_files) $(BUILT_SOURCES)
-
-EXTRA_DIST = sugar-marshal.list
diff --git a/lib/ui/eggaccelerators.c b/lib/ui/eggaccelerators.c
deleted file mode 100644
index 0a39d51..0000000
--- a/lib/ui/eggaccelerators.c
+++ /dev/null
@@ -1,702 +0,0 @@
-/* eggaccelerators.c
- * Copyright (C) 2002 Red Hat, Inc.; Copyright 1998, 2001 Tim Janik
- * Developed by Havoc Pennington, Tim Janik
- *
- * 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.
- */
-
-#include "eggaccelerators.h"
-
-#include <stdlib.h>
-#include <string.h>
-#include <gdk/gdkx.h>
-#include <gdk/gdkkeysyms.h>
-
-enum
-{
- EGG_MODMAP_ENTRY_SHIFT = 0,
- EGG_MODMAP_ENTRY_LOCK = 1,
- EGG_MODMAP_ENTRY_CONTROL = 2,
- EGG_MODMAP_ENTRY_MOD1 = 3,
- EGG_MODMAP_ENTRY_MOD2 = 4,
- EGG_MODMAP_ENTRY_MOD3 = 5,
- EGG_MODMAP_ENTRY_MOD4 = 6,
- EGG_MODMAP_ENTRY_MOD5 = 7,
- EGG_MODMAP_ENTRY_LAST = 8
-};
-
-#define MODMAP_ENTRY_TO_MODIFIER(x) (1 << (x))
-
-typedef struct
-{
- EggVirtualModifierType mapping[EGG_MODMAP_ENTRY_LAST];
-
-} EggModmap;
-
-const EggModmap* egg_keymap_get_modmap (GdkKeymap *keymap);
-
-static inline gboolean
-is_alt (const gchar *string)
-{
- return ((string[0] == '<') &&
- (string[1] == 'a' || string[1] == 'A') &&
- (string[2] == 'l' || string[2] == 'L') &&
- (string[3] == 't' || string[3] == 'T') &&
- (string[4] == '>'));
-}
-
-static inline gboolean
-is_ctl (const gchar *string)
-{
- return ((string[0] == '<') &&
- (string[1] == 'c' || string[1] == 'C') &&
- (string[2] == 't' || string[2] == 'T') &&
- (string[3] == 'l' || string[3] == 'L') &&
- (string[4] == '>'));
-}
-
-static inline gboolean
-is_modx (const gchar *string)
-{
- return ((string[0] == '<') &&
- (string[1] == 'm' || string[1] == 'M') &&
- (string[2] == 'o' || string[2] == 'O') &&
- (string[3] == 'd' || string[3] == 'D') &&
- (string[4] >= '1' && string[4] <= '5') &&
- (string[5] == '>'));
-}
-
-static inline gboolean
-is_ctrl (const gchar *string)
-{
- return ((string[0] == '<') &&
- (string[1] == 'c' || string[1] == 'C') &&
- (string[2] == 't' || string[2] == 'T') &&
- (string[3] == 'r' || string[3] == 'R') &&
- (string[4] == 'l' || string[4] == 'L') &&
- (string[5] == '>'));
-}
-
-static inline gboolean
-is_shft (const gchar *string)
-{
- return ((string[0] == '<') &&
- (string[1] == 's' || string[1] == 'S') &&
- (string[2] == 'h' || string[2] == 'H') &&
- (string[3] == 'f' || string[3] == 'F') &&
- (string[4] == 't' || string[4] == 'T') &&
- (string[5] == '>'));
-}
-
-static inline gboolean
-is_shift (const gchar *string)
-{
- return ((string[0] == '<') &&
- (string[1] == 's' || string[1] == 'S') &&
- (string[2] == 'h' || string[2] == 'H') &&
- (string[3] == 'i' || string[3] == 'I') &&
- (string[4] == 'f' || string[4] == 'F') &&
- (string[5] == 't' || string[5] == 'T') &&
- (string[6] == '>'));
-}
-
-static inline gboolean
-is_control (const gchar *string)
-{
- return ((string[0] == '<') &&
- (string[1] == 'c' || string[1] == 'C') &&
- (string[2] == 'o' || string[2] == 'O') &&
- (string[3] == 'n' || string[3] == 'N') &&
- (string[4] == 't' || string[4] == 'T') &&
- (string[5] == 'r' || string[5] == 'R') &&
- (string[6] == 'o' || string[6] == 'O') &&
- (string[7] == 'l' || string[7] == 'L') &&
- (string[8] == '>'));
-}
-
-static inline gboolean
-is_release (const gchar *string)
-{
- return ((string[0] == '<') &&
- (string[1] == 'r' || string[1] == 'R') &&
- (string[2] == 'e' || string[2] == 'E') &&
- (string[3] == 'l' || string[3] == 'L') &&
- (string[4] == 'e' || string[4] == 'E') &&
- (string[5] == 'a' || string[5] == 'A') &&
- (string[6] == 's' || string[6] == 'S') &&
- (string[7] == 'e' || string[7] == 'E') &&
- (string[8] == '>'));
-}
-
-static inline gboolean
-is_meta (const gchar *string)
-{
- return ((string[0] == '<') &&
- (string[1] == 'm' || string[1] == 'M') &&
- (string[2] == 'e' || string[2] == 'E') &&
- (string[3] == 't' || string[3] == 'T') &&
- (string[4] == 'a' || string[4] == 'A') &&
- (string[5] == '>'));
-}
-
-static inline gboolean
-is_super (const gchar *string)
-{
- return ((string[0] == '<') &&
- (string[1] == 's' || string[1] == 'S') &&
- (string[2] == 'u' || string[2] == 'U') &&
- (string[3] == 'p' || string[3] == 'P') &&
- (string[4] == 'e' || string[4] == 'E') &&
- (string[5] == 'r' || string[5] == 'R') &&
- (string[6] == '>'));
-}
-
-static inline gboolean
-is_hyper (const gchar *string)
-{
- return ((string[0] == '<') &&
- (string[1] == 'h' || string[1] == 'H') &&
- (string[2] == 'y' || string[2] == 'Y') &&
- (string[3] == 'p' || string[3] == 'P') &&
- (string[4] == 'e' || string[4] == 'E') &&
- (string[5] == 'r' || string[5] == 'R') &&
- (string[6] == '>'));
-}
-
-static inline gboolean
-is_keycode (const gchar *string)
-{
- return ((string[0] == '0') &&
- (string[1] == 'x'));
-}
-
-/**
- * egg_accelerator_parse_virtual:
- * @accelerator: string representing an accelerator
- * @accelerator_key: return location for accelerator keyval
- * @accelerator_mods: return location for accelerator modifier mask
- *
- * Parses a string representing a virtual accelerator. The format
- * looks like "&lt;Control&gt;a" or "&lt;Shift&gt;&lt;Alt&gt;F1" or
- * "&lt;Release&gt;z" (the last one is for key release). The parser
- * is fairly liberal and allows lower or upper case, and also
- * abbreviations such as "&lt;Ctl&gt;" and "&lt;Ctrl&gt;".
- *
- * If the parse fails, @accelerator_key and @accelerator_mods will
- * be set to 0 (zero) and %FALSE will be returned. If the string contains
- * only modifiers, @accelerator_key will be set to 0 but %TRUE will be
- * returned.
- *
- * The virtual vs. concrete accelerator distinction is a relic of
- * how the X Window System works; there are modifiers Mod2-Mod5 that
- * can represent various keyboard keys (numlock, meta, hyper, etc.),
- * the virtual modifier represents the keyboard key, the concrete
- * modifier the actual Mod2-Mod5 bits in the key press event.
- *
- * Returns: %TRUE on success.
- */
-gboolean
-egg_accelerator_parse_virtual (const gchar *accelerator,
- guint *accelerator_key,
- guint *keycode,
- EggVirtualModifierType *accelerator_mods)
-{
- guint keyval;
- GdkModifierType mods;
- gint len;
- gboolean bad_keyval;
-
- if (accelerator_key)
- *accelerator_key = 0;
- if (accelerator_mods)
- *accelerator_mods = 0;
- if (keycode)
- *keycode = 0;
-
- g_return_val_if_fail (accelerator != NULL, FALSE);
-
- bad_keyval = FALSE;
-
- keyval = 0;
- mods = 0;
- len = strlen (accelerator);
- while (len)
- {
- if (*accelerator == '<')
- {
- if (len >= 9 && is_release (accelerator))
- {
- accelerator += 9;
- len -= 9;
- mods |= EGG_VIRTUAL_RELEASE_MASK;
- }
- else if (len >= 9 && is_control (accelerator))
- {
- accelerator += 9;
- len -= 9;
- mods |= EGG_VIRTUAL_CONTROL_MASK;
- }
- else if (len >= 7 && is_shift (accelerator))
- {
- accelerator += 7;
- len -= 7;
- mods |= EGG_VIRTUAL_SHIFT_MASK;
- }
- else if (len >= 6 && is_shft (accelerator))
- {
- accelerator += 6;
- len -= 6;
- mods |= EGG_VIRTUAL_SHIFT_MASK;
- }
- else if (len >= 6 && is_ctrl (accelerator))
- {
- accelerator += 6;
- len -= 6;
- mods |= EGG_VIRTUAL_CONTROL_MASK;
- }
- else if (len >= 6 && is_modx (accelerator))
- {
- static const guint mod_vals[] = {
- EGG_VIRTUAL_ALT_MASK, EGG_VIRTUAL_MOD2_MASK, EGG_VIRTUAL_MOD3_MASK,
- EGG_VIRTUAL_MOD4_MASK, EGG_VIRTUAL_MOD5_MASK
- };
-
- len -= 6;
- accelerator += 4;
- mods |= mod_vals[*accelerator - '1'];
- accelerator += 2;
- }
- else if (len >= 5 && is_ctl (accelerator))
- {
- accelerator += 5;
- len -= 5;
- mods |= EGG_VIRTUAL_CONTROL_MASK;
- }
- else if (len >= 5 && is_alt (accelerator))
- {
- accelerator += 5;
- len -= 5;
- mods |= EGG_VIRTUAL_ALT_MASK;
- }
- else if (len >= 6 && is_meta (accelerator))
- {
- accelerator += 6;
- len -= 6;
- mods |= EGG_VIRTUAL_META_MASK;
- }
- else if (len >= 7 && is_hyper (accelerator))
- {
- accelerator += 7;
- len -= 7;
- mods |= EGG_VIRTUAL_HYPER_MASK;
- }
- else if (len >= 7 && is_super (accelerator))
- {
- accelerator += 7;
- len -= 7;
- mods |= EGG_VIRTUAL_SUPER_MASK;
- }
- else
- {
- gchar last_ch;
-
- last_ch = *accelerator;
- while (last_ch && last_ch != '>')
- {
- last_ch = *accelerator;
- accelerator += 1;
- len -= 1;
- }
- }
- }
- else
- {
- keyval = gdk_keyval_from_name (accelerator);
-
- if (keyval == 0)
- {
- /* If keyval is 0, than maybe it's a keycode. Check for 0x## */
- if (len >= 4 && is_keycode (accelerator))
- {
- char keystring[5];
- gchar *endptr;
- gint tmp_keycode;
-
- memcpy (keystring, accelerator, 4);
- keystring [4] = '\000';
-
- tmp_keycode = strtol (keystring, &endptr, 16);
-
- if (endptr == NULL || *endptr != '\000')
- {
- bad_keyval = TRUE;
- }
- else if (keycode != NULL)
- {
- *keycode = tmp_keycode;
- /* 0x00 is an invalid keycode too. */
- if (*keycode == 0)
- bad_keyval = TRUE;
- }
- }
- } else if (keycode != NULL)
- *keycode = XKeysymToKeycode (GDK_DISPLAY(), keyval);
-
- accelerator += len;
- len -= len;
- }
- }
-
- if (accelerator_key)
- *accelerator_key = gdk_keyval_to_lower (keyval);
- if (accelerator_mods)
- *accelerator_mods = mods;
-
- return !bad_keyval;
-}
-
-
-/**
- * egg_virtual_accelerator_name:
- * @accelerator_key: accelerator keyval
- * @accelerator_mods: accelerator modifier mask
- * @returns: a newly-allocated accelerator name
- *
- * Converts an accelerator keyval and modifier mask
- * into a string parseable by egg_accelerator_parse_virtual().
- * For example, if you pass in #GDK_q and #EGG_VIRTUAL_CONTROL_MASK,
- * this function returns "&lt;Control&gt;q".
- *
- * The caller of this function must free the returned string.
- */
-gchar*
-egg_virtual_accelerator_name (guint accelerator_key,
- guint keycode,
- EggVirtualModifierType accelerator_mods)
-{
- static const gchar text_release[] = "<Release>";
- static const gchar text_shift[] = "<Shift>";
- static const gchar text_control[] = "<Control>";
- static const gchar text_mod1[] = "<Alt>";
- static const gchar text_mod2[] = "<Mod2>";
- static const gchar text_mod3[] = "<Mod3>";
- static const gchar text_mod4[] = "<Mod4>";
- static const gchar text_mod5[] = "<Mod5>";
- static const gchar text_meta[] = "<Meta>";
- static const gchar text_super[] = "<Super>";
- static const gchar text_hyper[] = "<Hyper>";
- guint l;
- gchar *keyval_name;
- gchar *accelerator;
-
- accelerator_mods &= EGG_VIRTUAL_MODIFIER_MASK;
-
- if (!accelerator_key)
- {
- keyval_name = g_strdup_printf ("0x%02x", keycode);
- }
- else
- {
- keyval_name = gdk_keyval_name (gdk_keyval_to_lower (accelerator_key));
- if (!keyval_name)
- keyval_name = "";
- }
-
- l = 0;
- if (accelerator_mods & EGG_VIRTUAL_RELEASE_MASK)
- l += sizeof (text_release) - 1;
- if (accelerator_mods & EGG_VIRTUAL_SHIFT_MASK)
- l += sizeof (text_shift) - 1;
- if (accelerator_mods & EGG_VIRTUAL_CONTROL_MASK)
- l += sizeof (text_control) - 1;
- if (accelerator_mods & EGG_VIRTUAL_ALT_MASK)
- l += sizeof (text_mod1) - 1;
- if (accelerator_mods & EGG_VIRTUAL_MOD2_MASK)
- l += sizeof (text_mod2) - 1;
- if (accelerator_mods & EGG_VIRTUAL_MOD3_MASK)
- l += sizeof (text_mod3) - 1;
- if (accelerator_mods & EGG_VIRTUAL_MOD4_MASK)
- l += sizeof (text_mod4) - 1;
- if (accelerator_mods & EGG_VIRTUAL_MOD5_MASK)
- l += sizeof (text_mod5) - 1;
- if (accelerator_mods & EGG_VIRTUAL_META_MASK)
- l += sizeof (text_meta) - 1;
- if (accelerator_mods & EGG_VIRTUAL_HYPER_MASK)
- l += sizeof (text_hyper) - 1;
- if (accelerator_mods & EGG_VIRTUAL_SUPER_MASK)
- l += sizeof (text_super) - 1;
- l += strlen (keyval_name);
-
- accelerator = g_new (gchar, l + 1);
-
- l = 0;
- accelerator[l] = 0;
- if (accelerator_mods & EGG_VIRTUAL_RELEASE_MASK)
- {
- strcpy (accelerator + l, text_release);
- l += sizeof (text_release) - 1;
- }
- if (accelerator_mods & EGG_VIRTUAL_SHIFT_MASK)
- {
- strcpy (accelerator + l, text_shift);
- l += sizeof (text_shift) - 1;
- }
- if (accelerator_mods & EGG_VIRTUAL_CONTROL_MASK)
- {
- strcpy (accelerator + l, text_control);
- l += sizeof (text_control) - 1;
- }
- if (accelerator_mods & EGG_VIRTUAL_ALT_MASK)
- {
- strcpy (accelerator + l, text_mod1);
- l += sizeof (text_mod1) - 1;
- }
- if (accelerator_mods & EGG_VIRTUAL_MOD2_MASK)
- {
- strcpy (accelerator + l, text_mod2);
- l += sizeof (text_mod2) - 1;
- }
- if (accelerator_mods & EGG_VIRTUAL_MOD3_MASK)
- {
- strcpy (accelerator + l, text_mod3);
- l += sizeof (text_mod3) - 1;
- }
- if (accelerator_mods & EGG_VIRTUAL_MOD4_MASK)
- {
- strcpy (accelerator + l, text_mod4);
- l += sizeof (text_mod4) - 1;
- }
- if (accelerator_mods & EGG_VIRTUAL_MOD5_MASK)
- {
- strcpy (accelerator + l, text_mod5);
- l += sizeof (text_mod5) - 1;
- }
- if (accelerator_mods & EGG_VIRTUAL_META_MASK)
- {
- strcpy (accelerator + l, text_meta);
- l += sizeof (text_meta) - 1;
- }
- if (accelerator_mods & EGG_VIRTUAL_HYPER_MASK)
- {
- strcpy (accelerator + l, text_hyper);
- l += sizeof (text_hyper) - 1;
- }
- if (accelerator_mods & EGG_VIRTUAL_SUPER_MASK)
- {
- strcpy (accelerator + l, text_super);
- l += sizeof (text_super) - 1;
- }
-
- strcpy (accelerator + l, keyval_name);
-
- return accelerator;
-}
-
-void
-egg_keymap_resolve_virtual_modifiers (GdkKeymap *keymap,
- EggVirtualModifierType virtual_mods,
- GdkModifierType *concrete_mods)
-{
- GdkModifierType concrete;
- int i;
- const EggModmap *modmap;
-
- g_return_if_fail (GDK_IS_KEYMAP (keymap));
- g_return_if_fail (concrete_mods != NULL);
-
- modmap = egg_keymap_get_modmap (keymap);
-
- /* Not so sure about this algorithm. */
-
- concrete = 0;
- i = 0;
- while (i < EGG_MODMAP_ENTRY_LAST)
- {
- if (modmap->mapping[i] & virtual_mods)
- concrete |= (1 << i);
-
- ++i;
- }
-
- *concrete_mods = concrete;
-}
-
-void
-egg_keymap_virtualize_modifiers (GdkKeymap *keymap,
- GdkModifierType concrete_mods,
- EggVirtualModifierType *virtual_mods)
-{
- GdkModifierType virtual;
- int i;
- const EggModmap *modmap;
-
- g_return_if_fail (GDK_IS_KEYMAP (keymap));
- g_return_if_fail (virtual_mods != NULL);
-
- modmap = egg_keymap_get_modmap (keymap);
-
- /* Not so sure about this algorithm. */
-
- virtual = 0;
- i = 0;
- while (i < EGG_MODMAP_ENTRY_LAST)
- {
- if ((1 << i) & concrete_mods)
- {
- EggVirtualModifierType cleaned;
-
- cleaned = modmap->mapping[i] & ~(EGG_VIRTUAL_MOD2_MASK |
- EGG_VIRTUAL_MOD3_MASK |
- EGG_VIRTUAL_MOD4_MASK |
- EGG_VIRTUAL_MOD5_MASK);
-
- if (cleaned != 0)
- {
- virtual |= cleaned;
- }
- else
- {
- /* Rather than dropping mod2->mod5 if not bound,
- * go ahead and use the concrete names
- */
- virtual |= modmap->mapping[i];
- }
- }
-
- ++i;
- }
-
- *virtual_mods = virtual;
-}
-
-static void
-reload_modmap (GdkKeymap *keymap,
- EggModmap *modmap)
-{
- XModifierKeymap *xmodmap;
- int map_size;
- int i;
-
- /* FIXME multihead */
- xmodmap = XGetModifierMapping (gdk_x11_get_default_xdisplay ());
-
- memset (modmap->mapping, 0, sizeof (modmap->mapping));
-
- /* there are 8 modifiers, and the first 3 are shift, shift lock,
- * and control
- */
- map_size = 8 * xmodmap->max_keypermod;
- i = 3 * xmodmap->max_keypermod;
- while (i < map_size)
- {
- /* get the key code at this point in the map,
- * see if its keysym is one we're interested in
- */
- int keycode = xmodmap->modifiermap[i];
- GdkKeymapKey *keys;
- guint *keyvals;
- int n_entries;
- int j;
- EggVirtualModifierType mask;
-
- keys = NULL;
- keyvals = NULL;
- n_entries = 0;
-
- gdk_keymap_get_entries_for_keycode (keymap,
- keycode,
- &keys, &keyvals, &n_entries);
-
- mask = 0;
- j = 0;
- while (j < n_entries)
- {
- if (keyvals[j] == GDK_Num_Lock)
- mask |= EGG_VIRTUAL_NUM_LOCK_MASK;
- else if (keyvals[j] == GDK_Scroll_Lock)
- mask |= EGG_VIRTUAL_SCROLL_LOCK_MASK;
- else if (keyvals[j] == GDK_Meta_L ||
- keyvals[j] == GDK_Meta_R)
- mask |= EGG_VIRTUAL_META_MASK;
- else if (keyvals[j] == GDK_Hyper_L ||
- keyvals[j] == GDK_Hyper_R)
- mask |= EGG_VIRTUAL_HYPER_MASK;
- else if (keyvals[j] == GDK_Super_L ||
- keyvals[j] == GDK_Super_R)
- mask |= EGG_VIRTUAL_SUPER_MASK;
- else if (keyvals[j] == GDK_Mode_switch)
- mask |= EGG_VIRTUAL_MODE_SWITCH_MASK;
-
- ++j;
- }
-
- /* Mod1Mask is 1 << 3 for example, i.e. the
- * fourth modifier, i / keyspermod is the modifier
- * index
- */
- modmap->mapping[i/xmodmap->max_keypermod] |= mask;
-
- g_free (keyvals);
- g_free (keys);
-
- ++i;
- }
-
- /* Add in the not-really-virtual fixed entries */
- modmap->mapping[EGG_MODMAP_ENTRY_SHIFT] |= EGG_VIRTUAL_SHIFT_MASK;
- modmap->mapping[EGG_MODMAP_ENTRY_CONTROL] |= EGG_VIRTUAL_CONTROL_MASK;
- modmap->mapping[EGG_MODMAP_ENTRY_LOCK] |= EGG_VIRTUAL_LOCK_MASK;
- modmap->mapping[EGG_MODMAP_ENTRY_MOD1] |= EGG_VIRTUAL_ALT_MASK;
- modmap->mapping[EGG_MODMAP_ENTRY_MOD2] |= EGG_VIRTUAL_MOD2_MASK;
- modmap->mapping[EGG_MODMAP_ENTRY_MOD3] |= EGG_VIRTUAL_MOD3_MASK;
- modmap->mapping[EGG_MODMAP_ENTRY_MOD4] |= EGG_VIRTUAL_MOD4_MASK;
- modmap->mapping[EGG_MODMAP_ENTRY_MOD5] |= EGG_VIRTUAL_MOD5_MASK;
-
- XFreeModifiermap (xmodmap);
-}
-
-const EggModmap*
-egg_keymap_get_modmap (GdkKeymap *keymap)
-{
- EggModmap *modmap;
-
- /* This is all a hack, much simpler when we can just
- * modify GDK directly.
- */
-
- modmap = g_object_get_data (G_OBJECT (keymap),
- "egg-modmap");
-
- if (modmap == NULL)
- {
- modmap = g_new0 (EggModmap, 1);
-
- /* FIXME modify keymap change events with an event filter
- * and force a reload if we get one
- */
-
- reload_modmap (keymap, modmap);
-
- g_object_set_data_full (G_OBJECT (keymap),
- "egg-modmap",
- modmap,
- g_free);
- }
-
- g_assert (modmap != NULL);
-
- return modmap;
-}
diff --git a/lib/ui/eggaccelerators.h b/lib/ui/eggaccelerators.h
deleted file mode 100644
index d2276d2..0000000
--- a/lib/ui/eggaccelerators.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/* eggaccelerators.h
- * Copyright (C) 2002 Red Hat, Inc.
- * Developed by Havoc Pennington
- *
- * 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.
- */
-
-#ifndef __EGG_ACCELERATORS_H__
-#define __EGG_ACCELERATORS_H__
-
-#include <gtk/gtkaccelgroup.h>
-#include <gdk/gdk.h>
-
-G_BEGIN_DECLS
-
-/* Where a value is also in GdkModifierType we coincide,
- * otherwise we don't overlap.
- */
-typedef enum
-{
- EGG_VIRTUAL_SHIFT_MASK = 1 << 0,
- EGG_VIRTUAL_LOCK_MASK = 1 << 1,
- EGG_VIRTUAL_CONTROL_MASK = 1 << 2,
-
- EGG_VIRTUAL_ALT_MASK = 1 << 3, /* fixed as Mod1 */
-
- EGG_VIRTUAL_MOD2_MASK = 1 << 4,
- EGG_VIRTUAL_MOD3_MASK = 1 << 5,
- EGG_VIRTUAL_MOD4_MASK = 1 << 6,
- EGG_VIRTUAL_MOD5_MASK = 1 << 7,
-
-#if 0
- GDK_BUTTON1_MASK = 1 << 8,
- GDK_BUTTON2_MASK = 1 << 9,
- GDK_BUTTON3_MASK = 1 << 10,
- GDK_BUTTON4_MASK = 1 << 11,
- GDK_BUTTON5_MASK = 1 << 12,
- /* 13, 14 are used by Xkb for the keyboard group */
-#endif
-
- EGG_VIRTUAL_META_MASK = 1 << 24,
- EGG_VIRTUAL_SUPER_MASK = 1 << 25,
- EGG_VIRTUAL_HYPER_MASK = 1 << 26,
- EGG_VIRTUAL_MODE_SWITCH_MASK = 1 << 27,
- EGG_VIRTUAL_NUM_LOCK_MASK = 1 << 28,
- EGG_VIRTUAL_SCROLL_LOCK_MASK = 1 << 29,
-
- /* Also in GdkModifierType */
- EGG_VIRTUAL_RELEASE_MASK = 1 << 30,
-
- /* 28-31 24-27 20-23 16-19 12-15 8-11 4-7 0-3
- * 7 f 0 0 0 0 f f
- */
- EGG_VIRTUAL_MODIFIER_MASK = 0x7f0000ff
-
-} EggVirtualModifierType;
-
-gboolean egg_accelerator_parse_virtual (const gchar *accelerator,
- guint *accelerator_key,
- guint *keycode,
- EggVirtualModifierType *accelerator_mods);
-void egg_keymap_resolve_virtual_modifiers (GdkKeymap *keymap,
- EggVirtualModifierType virtual_mods,
- GdkModifierType *concrete_mods);
-void egg_keymap_virtualize_modifiers (GdkKeymap *keymap,
- GdkModifierType concrete_mods,
- EggVirtualModifierType *virtual_mods);
-
-gchar* egg_virtual_accelerator_name (guint accelerator_key,
- guint keycode,
- EggVirtualModifierType accelerator_mods);
-
-G_END_DECLS
-
-
-#endif /* __EGG_ACCELERATORS_H__ */
diff --git a/lib/ui/sexy-icon-entry.c b/lib/ui/sexy-icon-entry.c
deleted file mode 100644
index ca35209..0000000
--- a/lib/ui/sexy-icon-entry.c
+++ /dev/null
@@ -1,984 +0,0 @@
-/*
- * @file libsexy/sexy-icon-entry.c Entry widget
- *
- * @Copyright (C) 2004-2006 Christian Hammond.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser 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.
- */
-#include <sexy-icon-entry.h>
-#include <string.h>
-#include <gtk/gtk.h>
-
-#define ICON_MARGIN 2
-#define MAX_ICONS 2
-
-#define IS_VALID_ICON_ENTRY_POSITION(pos) \
- ((pos) == SEXY_ICON_ENTRY_PRIMARY || \
- (pos) == SEXY_ICON_ENTRY_SECONDARY)
-
-typedef struct
-{
- GtkImage *icon;
- gboolean highlight;
- gboolean hovered;
- GdkWindow *window;
-
-} SexyIconInfo;
-
-struct _SexyIconEntryPriv
-{
- SexyIconInfo icons[MAX_ICONS];
-
- gulong icon_released_id;
-};
-
-enum
-{
- ICON_PRESSED,
- ICON_RELEASED,
- LAST_SIGNAL
-};
-
-static void sexy_icon_entry_class_init(SexyIconEntryClass *klass);
-static void sexy_icon_entry_editable_init(GtkEditableClass *iface);
-static void sexy_icon_entry_init(SexyIconEntry *entry);
-static void sexy_icon_entry_finalize(GObject *obj);
-static void sexy_icon_entry_destroy(GtkObject *obj);
-static void sexy_icon_entry_map(GtkWidget *widget);
-static void sexy_icon_entry_unmap(GtkWidget *widget);
-static void sexy_icon_entry_realize(GtkWidget *widget);
-static void sexy_icon_entry_unrealize(GtkWidget *widget);
-static void sexy_icon_entry_size_request(GtkWidget *widget,
- GtkRequisition *requisition);
-static void sexy_icon_entry_size_allocate(GtkWidget *widget,
- GtkAllocation *allocation);
-static gint sexy_icon_entry_expose(GtkWidget *widget, GdkEventExpose *event);
-static gint sexy_icon_entry_enter_notify(GtkWidget *widget,
- GdkEventCrossing *event);
-static gint sexy_icon_entry_leave_notify(GtkWidget *widget,
- GdkEventCrossing *event);
-static gint sexy_icon_entry_button_press(GtkWidget *widget,
- GdkEventButton *event);
-static gint sexy_icon_entry_button_release(GtkWidget *widget,
- GdkEventButton *event);
-
-static GtkEntryClass *parent_class = NULL;
-static guint signals[LAST_SIGNAL] = {0};
-
-G_DEFINE_TYPE_EXTENDED(SexyIconEntry, sexy_icon_entry, GTK_TYPE_ENTRY,
- 0,
- G_IMPLEMENT_INTERFACE(GTK_TYPE_EDITABLE,
- sexy_icon_entry_editable_init));
-
-static void
-sexy_icon_entry_class_init(SexyIconEntryClass *klass)
-{
- GObjectClass *gobject_class;
- GtkObjectClass *object_class;
- GtkWidgetClass *widget_class;
- GtkEntryClass *entry_class;
-
- parent_class = g_type_class_peek_parent(klass);
-
- gobject_class = G_OBJECT_CLASS(klass);
- object_class = GTK_OBJECT_CLASS(klass);
- widget_class = GTK_WIDGET_CLASS(klass);
- entry_class = GTK_ENTRY_CLASS(klass);
-
- gobject_class->finalize = sexy_icon_entry_finalize;
-
- object_class->destroy = sexy_icon_entry_destroy;
-
- widget_class->map = sexy_icon_entry_map;
- widget_class->unmap = sexy_icon_entry_unmap;
- widget_class->realize = sexy_icon_entry_realize;
- widget_class->unrealize = sexy_icon_entry_unrealize;
- widget_class->size_request = sexy_icon_entry_size_request;
- widget_class->size_allocate = sexy_icon_entry_size_allocate;
- widget_class->expose_event = sexy_icon_entry_expose;
- widget_class->enter_notify_event = sexy_icon_entry_enter_notify;
- widget_class->leave_notify_event = sexy_icon_entry_leave_notify;
- widget_class->button_press_event = sexy_icon_entry_button_press;
- widget_class->button_release_event = sexy_icon_entry_button_release;
-
- /**
- * SexyIconEntry::icon-pressed:
- * @entry: The entry on which the signal is emitted.
- * @icon_pos: The position of the clicked icon.
- * @button: The mouse button clicked.
- *
- * The ::icon-pressed signal is emitted when an icon is clicked.
- */
- signals[ICON_PRESSED] =
- g_signal_new("icon_pressed",
- G_TYPE_FROM_CLASS(gobject_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET(SexyIconEntryClass, icon_pressed),
- NULL, NULL,
- gtk_marshal_VOID__INT_INT,
- G_TYPE_NONE, 2,
- G_TYPE_INT,
- G_TYPE_INT);
-
- /**
- * SexyIconEntry::icon-released:
- * @entry: The entry on which the signal is emitted.
- * @icon_pos: The position of the clicked icon.
- * @button: The mouse button clicked.
- *
- * The ::icon-released signal is emitted on the button release from a
- * mouse click.
- */
- signals[ICON_RELEASED] =
- g_signal_new("icon_released",
- G_TYPE_FROM_CLASS(gobject_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET(SexyIconEntryClass, icon_released),
- NULL, NULL,
- gtk_marshal_VOID__INT_INT,
- G_TYPE_NONE, 2,
- G_TYPE_INT,
- G_TYPE_INT);
-}
-
-static void
-sexy_icon_entry_editable_init(GtkEditableClass *iface)
-{
-};
-
-static void
-sexy_icon_entry_init(SexyIconEntry *entry)
-{
- entry->priv = g_new0(SexyIconEntryPriv, 1);
-}
-
-static void
-sexy_icon_entry_finalize(GObject *obj)
-{
- SexyIconEntry *entry;
-
- g_return_if_fail(obj != NULL);
- g_return_if_fail(SEXY_IS_ICON_ENTRY(obj));
-
- entry = SEXY_ICON_ENTRY(obj);
-
- g_free(entry->priv);
-
- if (G_OBJECT_CLASS(parent_class)->finalize)
- G_OBJECT_CLASS(parent_class)->finalize(obj);
-}
-
-static void
-sexy_icon_entry_destroy(GtkObject *obj)
-{
- SexyIconEntry *entry;
-
- entry = SEXY_ICON_ENTRY(obj);
-
- sexy_icon_entry_set_icon(entry, SEXY_ICON_ENTRY_PRIMARY, NULL);
- sexy_icon_entry_set_icon(entry, SEXY_ICON_ENTRY_SECONDARY, NULL);
-
- if (GTK_OBJECT_CLASS(parent_class)->destroy)
- GTK_OBJECT_CLASS(parent_class)->destroy(obj);
-}
-
-static void
-sexy_icon_entry_map(GtkWidget *widget)
-{
- if (GTK_WIDGET_REALIZED(widget) && !GTK_WIDGET_MAPPED(widget))
- {
- SexyIconEntry *entry = SEXY_ICON_ENTRY(widget);
- int i;
-
- GTK_WIDGET_CLASS(parent_class)->map(widget);
-
- for (i = 0; i < MAX_ICONS; i++)
- {
- if (entry->priv->icons[i].icon != NULL)
- gdk_window_show(entry->priv->icons[i].window);
- }
- }
-}
-
-static void
-sexy_icon_entry_unmap(GtkWidget *widget)
-{
- if (GTK_WIDGET_MAPPED(widget))
- {
- SexyIconEntry *entry = SEXY_ICON_ENTRY(widget);
- int i;
-
- for (i = 0; i < MAX_ICONS; i++)
- {
- if (entry->priv->icons[i].icon != NULL)
- gdk_window_hide(entry->priv->icons[i].window);
- }
-
- GTK_WIDGET_CLASS(parent_class)->unmap(widget);
- }
-}
-
-static gint
-get_icon_width(SexyIconEntry *entry, SexyIconEntryPosition icon_pos)
-{
- GtkRequisition requisition;
- gint menu_icon_width;
- gint width;
- SexyIconInfo *icon_info = &entry->priv->icons[icon_pos];
-
- if (icon_info->icon == NULL)
- return 0;
-
- gtk_widget_size_request(GTK_WIDGET(icon_info->icon), &requisition);
- gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &menu_icon_width, NULL);
-
- width = MAX(requisition.width, menu_icon_width);
-
- return width;
-}
-
-static void
-get_borders(SexyIconEntry *entry, gint *xborder, gint *yborder)
-{
- GtkWidget *widget = GTK_WIDGET(entry);
- gint focus_width;
- gboolean interior_focus;
-
- gtk_widget_style_get(widget,
- "interior-focus", &interior_focus,
- "focus-line-width", &focus_width,
- NULL);
-
- if (gtk_entry_get_has_frame(GTK_ENTRY(entry)))
- {
- *xborder = widget->style->xthickness;
- *yborder = widget->style->ythickness;
- }
- else
- {
- *xborder = 0;
- *yborder = 0;
- }
-
- if (!interior_focus)
- {
- *xborder += focus_width;
- *yborder += focus_width;
- }
-}
-
-static void
-get_text_area_size(SexyIconEntry *entry, GtkAllocation *alloc)
-{
- GtkWidget *widget = GTK_WIDGET(entry);
- GtkRequisition requisition;
- gint xborder, yborder;
-
- gtk_widget_get_child_requisition(widget, &requisition);
- get_borders(entry, &xborder, &yborder);
-
- alloc->x = xborder;
- alloc->y = yborder;
- alloc->width = widget->allocation.width - xborder * 2;
- alloc->height = requisition.height - yborder * 2;
-}
-
-static void
-get_icon_allocation(SexyIconEntry *icon_entry,
- gboolean left,
- GtkAllocation *widget_alloc,
- GtkAllocation *text_area_alloc,
- GtkAllocation *allocation,
- SexyIconEntryPosition *icon_pos)
-{
- gboolean rtl;
-
- rtl = (gtk_widget_get_direction(GTK_WIDGET(icon_entry)) ==
- GTK_TEXT_DIR_RTL);
-
- if (left)
- *icon_pos = (rtl ? SEXY_ICON_ENTRY_SECONDARY : SEXY_ICON_ENTRY_PRIMARY);
- else
- *icon_pos = (rtl ? SEXY_ICON_ENTRY_PRIMARY : SEXY_ICON_ENTRY_SECONDARY);
-
- allocation->y = text_area_alloc->y;
- allocation->width = get_icon_width(icon_entry, *icon_pos);
- allocation->height = text_area_alloc->height;
-
- if (left)
- allocation->x = text_area_alloc->x + ICON_MARGIN;
- else
- {
- allocation->x = text_area_alloc->x + text_area_alloc->width -
- allocation->width - ICON_MARGIN;
- }
-}
-
-static void
-sexy_icon_entry_realize(GtkWidget *widget)
-{
- SexyIconEntry *entry = SEXY_ICON_ENTRY(widget);
- GdkWindowAttr attributes;
- gint attributes_mask;
- int i;
-
- GTK_WIDGET_CLASS(parent_class)->realize(widget);
-
- attributes.x = 0;
- attributes.y = 0;
- attributes.width = 1;
- attributes.height = 1;
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.visual = gtk_widget_get_visual(widget);
- attributes.colormap = gtk_widget_get_colormap(widget);
- attributes.event_mask = gtk_widget_get_events(widget);
- attributes.event_mask |=
- (GDK_EXPOSURE_MASK
- | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
- | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK);
-
- attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
-
- for (i = 0; i < MAX_ICONS; i++)
- {
- SexyIconInfo *icon_info;
-
- icon_info = &entry->priv->icons[i];
- icon_info->window = gdk_window_new(widget->window, &attributes,
- attributes_mask);
- gdk_window_set_user_data(icon_info->window, widget);
-
- gdk_window_set_background(icon_info->window,
- &widget->style->base[GTK_WIDGET_STATE(widget)]);
- }
-
- gtk_widget_queue_resize(widget);
-}
-
-static void
-sexy_icon_entry_unrealize(GtkWidget *widget)
-{
- SexyIconEntry *entry = SEXY_ICON_ENTRY(widget);
- int i;
-
- GTK_WIDGET_CLASS(parent_class)->unrealize(widget);
-
- for (i = 0; i < MAX_ICONS; i++)
- {
- SexyIconInfo *icon_info = &entry->priv->icons[i];
-
- gdk_window_destroy(icon_info->window);
- icon_info->window = NULL;
- }
-}
-
-static void
-sexy_icon_entry_size_request(GtkWidget *widget, GtkRequisition *requisition)
-{
- GtkEntry *gtkentry;
- SexyIconEntry *entry;
- gint icon_widths = 0;
- int i;
-
- gtkentry = GTK_ENTRY(widget);
- entry = SEXY_ICON_ENTRY(widget);
-
- for (i = 0; i < MAX_ICONS; i++)
- {
- int icon_width = get_icon_width(entry, i);
-
- if (icon_width > 0)
- icon_widths += icon_width + ICON_MARGIN;
- }
-
- GTK_WIDGET_CLASS(parent_class)->size_request(widget, requisition);
-
- if (icon_widths > requisition->width)
- requisition->width += icon_widths;
-}
-
-static void
-place_windows(SexyIconEntry *icon_entry, GtkAllocation *widget_alloc)
-{
- SexyIconEntryPosition left_icon_pos;
- SexyIconEntryPosition right_icon_pos;
- GtkAllocation left_icon_alloc;
- GtkAllocation right_icon_alloc;
- GtkAllocation text_area_alloc;
-
- get_text_area_size(icon_entry, &text_area_alloc);
- get_icon_allocation(icon_entry, TRUE, widget_alloc, &text_area_alloc,
- &left_icon_alloc, &left_icon_pos);
- get_icon_allocation(icon_entry, FALSE, widget_alloc, &text_area_alloc,
- &right_icon_alloc, &right_icon_pos);
-
- if (left_icon_alloc.width > 0)
- {
- text_area_alloc.x = left_icon_alloc.x + left_icon_alloc.width +
- ICON_MARGIN;
- }
-
- if (right_icon_alloc.width > 0)
- text_area_alloc.width -= right_icon_alloc.width + ICON_MARGIN;
-
- text_area_alloc.width -= text_area_alloc.x;
-
- gdk_window_move_resize(icon_entry->priv->icons[left_icon_pos].window,
- left_icon_alloc.x, left_icon_alloc.y,
- left_icon_alloc.width, left_icon_alloc.height);
-
- gdk_window_move_resize(icon_entry->priv->icons[right_icon_pos].window,
- right_icon_alloc.x, right_icon_alloc.y,
- right_icon_alloc.width, right_icon_alloc.height);
-
- gdk_window_move_resize(GTK_ENTRY(icon_entry)->text_area,
- text_area_alloc.x, text_area_alloc.y,
- text_area_alloc.width, text_area_alloc.height);
-}
-
-static void
-sexy_icon_entry_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
-{
- g_return_if_fail(SEXY_IS_ICON_ENTRY(widget));
- g_return_if_fail(allocation != NULL);
-
- widget->allocation = *allocation;
-
- GTK_WIDGET_CLASS(parent_class)->size_allocate(widget, allocation);
-
- if (GTK_WIDGET_REALIZED(widget))
- place_windows(SEXY_ICON_ENTRY(widget), allocation);
-}
-
-static GdkPixbuf *
-get_pixbuf_from_icon(SexyIconEntry *entry, SexyIconEntryPosition icon_pos)
-{
- GdkPixbuf *pixbuf = NULL;
- gchar *stock_id;
- SexyIconInfo *icon_info = &entry->priv->icons[icon_pos];
- GtkIconSize size;
-
- switch (gtk_image_get_storage_type(GTK_IMAGE(icon_info->icon)))
- {
- case GTK_IMAGE_PIXBUF:
- pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(icon_info->icon));
- g_object_ref(pixbuf);
- break;
-
- case GTK_IMAGE_STOCK:
- gtk_image_get_stock(GTK_IMAGE(icon_info->icon), &stock_id, &size);
- pixbuf = gtk_widget_render_icon(GTK_WIDGET(entry),
- stock_id, size, NULL);
- break;
-
- default:
- return NULL;
- }
-
- return pixbuf;
-}
-
-/* Kudos to the gnome-panel guys. */
-static void
-colorshift_pixbuf(GdkPixbuf *dest, GdkPixbuf *src, int shift)
-{
- gint i, j;
- gint width, height, has_alpha, src_rowstride, dest_rowstride;
- guchar *target_pixels;
- guchar *original_pixels;
- guchar *pix_src;
- guchar *pix_dest;
- int val;
- guchar r, g, b;
-
- has_alpha = gdk_pixbuf_get_has_alpha(src);
- width = gdk_pixbuf_get_width(src);
- height = gdk_pixbuf_get_height(src);
- src_rowstride = gdk_pixbuf_get_rowstride(src);
- dest_rowstride = gdk_pixbuf_get_rowstride(dest);
- original_pixels = gdk_pixbuf_get_pixels(src);
- target_pixels = gdk_pixbuf_get_pixels(dest);
-
- for (i = 0; i < height; i++)
- {
- pix_dest = target_pixels + i * dest_rowstride;
- pix_src = original_pixels + i * src_rowstride;
-
- for (j = 0; j < width; j++)
- {
- r = *(pix_src++);
- g = *(pix_src++);
- b = *(pix_src++);
-
- val = r + shift;
- *(pix_dest++) = CLAMP(val, 0, 255);
-
- val = g + shift;
- *(pix_dest++) = CLAMP(val, 0, 255);
-
- val = b + shift;
- *(pix_dest++) = CLAMP(val, 0, 255);
-
- if (has_alpha)
- *(pix_dest++) = *(pix_src++);
- }
- }
-}
-
-static void
-draw_icon(GtkWidget *widget, SexyIconEntryPosition icon_pos)
-{
- SexyIconEntry *entry = SEXY_ICON_ENTRY(widget);
- SexyIconInfo *icon_info = &entry->priv->icons[icon_pos];
- GdkPixbuf *pixbuf;
- gint x, y, width, height;
-
- if (icon_info->icon == NULL || !GTK_WIDGET_REALIZED(widget))
- return;
-
- if ((pixbuf = get_pixbuf_from_icon(entry, icon_pos)) == NULL)
- return;
-
- gdk_drawable_get_size(icon_info->window, &width, &height);
-
- if (width == 1 || height == 1)
- {
- /*
- * size_allocate hasn't been called yet. These are the default values.
- */
- return;
- }
-
- if (gdk_pixbuf_get_height(pixbuf) > height)
- {
- GdkPixbuf *temp_pixbuf;
- int scale;
-
- scale = height - (2 * ICON_MARGIN);
-
- temp_pixbuf = gdk_pixbuf_scale_simple(pixbuf, scale, scale,
- GDK_INTERP_BILINEAR);
-
- g_object_unref(pixbuf);
-
- pixbuf = temp_pixbuf;
- }
-
- x = (width - gdk_pixbuf_get_width(pixbuf)) / 2;
- y = (height - gdk_pixbuf_get_height(pixbuf)) / 2;
-
- if (icon_info->hovered)
- {
- GdkPixbuf *temp_pixbuf;
-
- temp_pixbuf = gdk_pixbuf_copy(pixbuf);
-
- colorshift_pixbuf(temp_pixbuf, pixbuf, 30);
-
- g_object_unref(pixbuf);
-
- pixbuf = temp_pixbuf;
- }
-
- gdk_draw_pixbuf(icon_info->window, widget->style->black_gc, pixbuf,
- 0, 0, x, y, -1, -1,
- GDK_RGB_DITHER_NORMAL, 0, 0);
-
- g_object_unref(pixbuf);
-}
-
-static gint
-sexy_icon_entry_expose(GtkWidget *widget, GdkEventExpose *event)
-{
- SexyIconEntry *entry;
-
- g_return_val_if_fail(SEXY_IS_ICON_ENTRY(widget), FALSE);
- g_return_val_if_fail(event != NULL, FALSE);
-
- entry = SEXY_ICON_ENTRY(widget);
-
- if (GTK_WIDGET_DRAWABLE(widget))
- {
- gboolean found = FALSE;
- int i;
-
- for (i = 0; i < MAX_ICONS && !found; i++)
- {
- SexyIconInfo *icon_info = &entry->priv->icons[i];
-
- if (event->window == icon_info->window)
- {
- gint width;
- GtkAllocation text_area_alloc;
-
- get_text_area_size(entry, &text_area_alloc);
- gdk_drawable_get_size(icon_info->window, &width, NULL);
-
- gtk_paint_flat_box(widget->style, icon_info->window,
- GTK_WIDGET_STATE(widget), GTK_SHADOW_NONE,
- NULL, widget, "entry_bg",
- 0, 0, width, text_area_alloc.height);
-
- draw_icon(widget, i);
-
- found = TRUE;
- }
- }
-
- if (!found)
- GTK_WIDGET_CLASS(parent_class)->expose_event(widget, event);
- }
-
- return FALSE;
-}
-
-static void
-update_icon(GObject *obj, GParamSpec *param, SexyIconEntry *entry)
-{
- if (param != NULL)
- {
- const char *name = g_param_spec_get_name(param);
-
- if (strcmp(name, "pixbuf") && strcmp(name, "stock") &&
- strcmp(name, "image") && strcmp(name, "pixmap") &&
- strcmp(name, "icon_set") && strcmp(name, "pixbuf_animation"))
- {
- return;
- }
- }
-
- gtk_widget_queue_resize(GTK_WIDGET(entry));
-}
-
-static gint
-sexy_icon_entry_enter_notify(GtkWidget *widget, GdkEventCrossing *event)
-{
- SexyIconEntry *entry = SEXY_ICON_ENTRY(widget);
- int i;
-
- for (i = 0; i < MAX_ICONS; i++)
- {
- if (event->window == entry->priv->icons[i].window)
- {
- if (sexy_icon_entry_get_icon_highlight(entry, i))
- {
- entry->priv->icons[i].hovered = TRUE;
-
- update_icon(NULL, NULL, entry);
-
- break;
- }
- }
- }
-
- return FALSE;
-}
-
-static gint
-sexy_icon_entry_leave_notify(GtkWidget *widget, GdkEventCrossing *event)
-{
- SexyIconEntry *entry = SEXY_ICON_ENTRY(widget);
- int i;
-
- for (i = 0; i < MAX_ICONS; i++)
- {
- if (event->window == entry->priv->icons[i].window)
- {
- if (sexy_icon_entry_get_icon_highlight(entry, i))
- {
- entry->priv->icons[i].hovered = FALSE;
-
- update_icon(NULL, NULL, entry);
-
- break;
- }
- }
- }
-
- return FALSE;
-}
-
-static gint
-sexy_icon_entry_button_press(GtkWidget *widget, GdkEventButton *event)
-{
- SexyIconEntry *entry = SEXY_ICON_ENTRY(widget);
- int i;
-
- for (i = 0; i < MAX_ICONS; i++)
- {
- if (event->window == entry->priv->icons[i].window)
- {
- if (event->button == 1 &&
- sexy_icon_entry_get_icon_highlight(entry, i))
- {
- entry->priv->icons[i].hovered = FALSE;
-
- update_icon(NULL, NULL, entry);
- }
-
- g_signal_emit(entry, signals[ICON_PRESSED], 0, i, event->button);
-
- return TRUE;
- }
- }
-
- if (GTK_WIDGET_CLASS(parent_class)->button_press_event)
- return GTK_WIDGET_CLASS(parent_class)->button_press_event(widget,
- event);
-
- return FALSE;
-}
-
-static gint
-sexy_icon_entry_button_release(GtkWidget *widget, GdkEventButton *event)
-{
- SexyIconEntry *entry = SEXY_ICON_ENTRY(widget);
- int i;
-
- for (i = 0; i < MAX_ICONS; i++)
- {
- GdkWindow *icon_window = entry->priv->icons[i].window;
-
- if (event->window == icon_window)
- {
- int width, height;
- gdk_drawable_get_size(icon_window, &width, &height);
-
- if (event->button == 1 &&
- sexy_icon_entry_get_icon_highlight(entry, i) &&
- event->x >= 0 && event->y >= 0 &&
- event->x <= width && event->y <= height)
- {
- entry->priv->icons[i].hovered = TRUE;
-
- update_icon(NULL, NULL, entry);
- }
-
- g_signal_emit(entry, signals[ICON_RELEASED], 0, i, event->button);
-
- return TRUE;
- }
- }
-
- if (GTK_WIDGET_CLASS(parent_class)->button_release_event)
- return GTK_WIDGET_CLASS(parent_class)->button_release_event(widget,
- event);
-
- return FALSE;
-}
-
-/**
- * sexy_icon_entry_new
- *
- * Creates a new SexyIconEntry widget.
- *
- * Returns a new #SexyIconEntry.
- */
-GtkWidget *
-sexy_icon_entry_new(void)
-{
- return GTK_WIDGET(g_object_new(SEXY_TYPE_ICON_ENTRY, NULL));
-}
-
-/**
- * sexy_icon_entry_set_icon
- * @entry: A #SexyIconEntry.
- * @position: Icon position.
- * @icon: A #GtkImage to set as the icon.
- *
- * Sets the icon shown in the entry
- */
-void
-sexy_icon_entry_set_icon(SexyIconEntry *entry, SexyIconEntryPosition icon_pos,
- GtkImage *icon)
-{
- SexyIconInfo *icon_info;
-
- g_return_if_fail(entry != NULL);
- g_return_if_fail(SEXY_IS_ICON_ENTRY(entry));
- g_return_if_fail(IS_VALID_ICON_ENTRY_POSITION(icon_pos));
- g_return_if_fail(icon == NULL || GTK_IS_IMAGE(icon));
-
- icon_info = &entry->priv->icons[icon_pos];
-
- if (icon == icon_info->icon)
- return;
-
- if (icon_pos == SEXY_ICON_ENTRY_SECONDARY &&
- entry->priv->icon_released_id != 0)
- {
- g_signal_handler_disconnect(entry, entry->priv->icon_released_id);
- entry->priv->icon_released_id = 0;
- }
-
- if (icon == NULL)
- {
- if (icon_info->icon != NULL)
- {
- gtk_widget_destroy(GTK_WIDGET(icon_info->icon));
- icon_info->icon = NULL;
-
- /*
- * Explicitly check, as the pointer may become invalidated
- * during destruction.
- */
- if (icon_info->window != NULL && GDK_IS_WINDOW(icon_info->window))
- gdk_window_hide(icon_info->window);
- }
- }
- else
- {
- if (icon_info->window != NULL && icon_info->icon == NULL)
- gdk_window_show(icon_info->window);
-
- g_signal_connect(G_OBJECT(icon), "notify",
- G_CALLBACK(update_icon), entry);
-
- icon_info->icon = icon;
- g_object_ref(icon);
- }
-
- update_icon(NULL, NULL, entry);
-}
-
-/**
- * sexy_icon_entry_set_icon_highlight
- * @entry: A #SexyIconEntry;
- * @position: Icon position.
- * @highlight: TRUE if the icon should highlight on mouse-over
- *
- * Determines whether the icon will highlight on mouse-over.
- */
-void
-sexy_icon_entry_set_icon_highlight(SexyIconEntry *entry,
- SexyIconEntryPosition icon_pos,
- gboolean highlight)
-{
- SexyIconInfo *icon_info;
-
- g_return_if_fail(entry != NULL);
- g_return_if_fail(SEXY_IS_ICON_ENTRY(entry));
- g_return_if_fail(IS_VALID_ICON_ENTRY_POSITION(icon_pos));
-
- icon_info = &entry->priv->icons[icon_pos];
-
- if (icon_info->highlight == highlight)
- return;
-
- icon_info->highlight = highlight;
-}
-
-/**
- * sexy_icon_entry_get_icon
- * @entry: A #SexyIconEntry.
- * @position: Icon position.
- *
- * Retrieves the image used for the icon
- *
- * Returns: A #GtkImage.
- */
-GtkImage *
-sexy_icon_entry_get_icon(const SexyIconEntry *entry,
- SexyIconEntryPosition icon_pos)
-{
- g_return_val_if_fail(entry != NULL, NULL);
- g_return_val_if_fail(SEXY_IS_ICON_ENTRY(entry), NULL);
- g_return_val_if_fail(IS_VALID_ICON_ENTRY_POSITION(icon_pos), NULL);
-
- return entry->priv->icons[icon_pos].icon;
-}
-
-/**
- * sexy_icon_entry_get_icon_highlight
- * @entry: A #SexyIconEntry.
- * @position: Icon position.
- *
- * Retrieves whether entry will highlight the icon on mouseover.
- *
- * Returns: TRUE if icon highlights.
- */
-gboolean
-sexy_icon_entry_get_icon_highlight(const SexyIconEntry *entry,
- SexyIconEntryPosition icon_pos)
-{
- g_return_val_if_fail(entry != NULL, FALSE);
- g_return_val_if_fail(SEXY_IS_ICON_ENTRY(entry), FALSE);
- g_return_val_if_fail(IS_VALID_ICON_ENTRY_POSITION(icon_pos), FALSE);
-
- return entry->priv->icons[icon_pos].highlight;
-}
-
-static void
-clear_button_clicked_cb(SexyIconEntry *icon_entry,
- SexyIconEntryPosition icon_pos,
- int button)
-{
- if (icon_pos != SEXY_ICON_ENTRY_SECONDARY || button != 1)
- return;
-
- gtk_entry_set_text(GTK_ENTRY(icon_entry), "");
-}
-
-/**
- * sexy_icon_entry_add_clear_button
- * @icon_entry: A #SexyIconEntry.
- *
- * A convenience function to add a clear button to the end of the entry.
- * This is useful for search boxes.
- */
-void
-sexy_icon_entry_add_clear_button(SexyIconEntry *icon_entry)
-{
- GtkWidget *icon;
-
- g_return_if_fail(icon_entry != NULL);
- g_return_if_fail(SEXY_IS_ICON_ENTRY(icon_entry));
-
- icon = gtk_image_new_from_stock(GTK_STOCK_CLEAR, GTK_ICON_SIZE_MENU);
- gtk_widget_show(icon);
- sexy_icon_entry_set_icon(SEXY_ICON_ENTRY(icon_entry),
- SEXY_ICON_ENTRY_SECONDARY,
- GTK_IMAGE(icon));
- sexy_icon_entry_set_icon_highlight(SEXY_ICON_ENTRY(icon_entry),
- SEXY_ICON_ENTRY_SECONDARY, TRUE);
-
- if (icon_entry->priv->icon_released_id != 0)
- {
- g_signal_handler_disconnect(icon_entry,
- icon_entry->priv->icon_released_id);
- }
-
- icon_entry->priv->icon_released_id =
- g_signal_connect(G_OBJECT(icon_entry), "icon_released",
- G_CALLBACK(clear_button_clicked_cb), NULL);
-}
-
-GType
-sexy_icon_entry_position_get_type (void)
-{
- static GType etype = 0;
- if (etype == 0) {
- static const GEnumValue values[] = {
- { SEXY_ICON_ENTRY_PRIMARY, "SEXY_ICON_ENTRY_PRIMARY", "primary" },
- { SEXY_ICON_ENTRY_SECONDARY, "SEXY_ICON_ENTRY_SECONDARY", "secondary" },
- { 0, NULL, NULL }
- };
- etype = g_enum_register_static ("SexyIconEntryPosition", values);
- }
- return etype;
-}
-
diff --git a/lib/ui/sexy-icon-entry.h b/lib/ui/sexy-icon-entry.h
deleted file mode 100644
index eb83fed..0000000
--- a/lib/ui/sexy-icon-entry.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * @file libsexy/sexy-icon-entry.h Entry widget
- *
- * @Copyright (C) 2004-2006 Christian Hammond.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser 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.
- */
-#ifndef _SEXY_ICON_ENTRY_H_
-#define _SEXY_ICON_ENTRY_H_
-
-typedef struct _SexyIconEntry SexyIconEntry;
-typedef struct _SexyIconEntryClass SexyIconEntryClass;
-typedef struct _SexyIconEntryPriv SexyIconEntryPriv;
-
-#include <gtk/gtkentry.h>
-#include <gtk/gtkimage.h>
-
-#define SEXY_TYPE_ICON_ENTRY (sexy_icon_entry_get_type())
-#define SEXY_ICON_ENTRY(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj), SEXY_TYPE_ICON_ENTRY, SexyIconEntry))
-#define SEXY_ICON_ENTRY_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass), SEXY_TYPE_ICON_ENTRY, SexyIconEntryClass))
-#define SEXY_IS_ICON_ENTRY(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj), SEXY_TYPE_ICON_ENTRY))
-#define SEXY_IS_ICON_ENTRY_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass), SEXY_TYPE_ICON_ENTRY))
-#define SEXY_ICON_ENTRY_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), SEXY_TYPE_ICON_ENTRY, SexyIconEntryClass))
-
-typedef enum
-{
- SEXY_ICON_ENTRY_PRIMARY,
- SEXY_ICON_ENTRY_SECONDARY
-
-} SexyIconEntryPosition;
-
-GType sexy_icon_entry_position_get_type(void);
-#define SEXY_TYPE_ICON_ENTRY_POSITION (sexy_icon_entry_position_get_type())
-
-struct _SexyIconEntry
-{
- GtkEntry parent_object;
-
- SexyIconEntryPriv *priv;
-
- void (*gtk_reserved1)(void);
- void (*gtk_reserved2)(void);
- void (*gtk_reserved3)(void);
- void (*gtk_reserved4)(void);
-};
-
-struct _SexyIconEntryClass
-{
- GtkEntryClass parent_class;
-
- /* Signals */
- void (*icon_pressed)(SexyIconEntry *entry, SexyIconEntryPosition icon_pos,
- int button);
- void (*icon_released)(SexyIconEntry *entry, SexyIconEntryPosition icon_pos,
- int button);
-
- void (*gtk_reserved1)(void);
- void (*gtk_reserved2)(void);
- void (*gtk_reserved3)(void);
- void (*gtk_reserved4)(void);
-};
-
-G_BEGIN_DECLS
-
-GType sexy_icon_entry_get_type(void);
-
-GtkWidget *sexy_icon_entry_new(void);
-
-void sexy_icon_entry_set_icon(SexyIconEntry *entry,
- SexyIconEntryPosition position,
- GtkImage *icon);
-
-void sexy_icon_entry_set_icon_highlight(SexyIconEntry *entry,
- SexyIconEntryPosition position,
- gboolean highlight);
-
-GtkImage *sexy_icon_entry_get_icon(const SexyIconEntry *entry,
- SexyIconEntryPosition position);
-
-gboolean sexy_icon_entry_get_icon_highlight(const SexyIconEntry *entry,
- SexyIconEntryPosition position);
-void sexy_icon_entry_add_clear_button(SexyIconEntry *icon_entry);
-
-G_END_DECLS
-
-#endif /* _SEXY_ICON_ENTRY_H_ */
diff --git a/lib/ui/sugar-address-entry.c b/lib/ui/sugar-address-entry.c
deleted file mode 100644
index 1f8c983..0000000
--- a/lib/ui/sugar-address-entry.c
+++ /dev/null
@@ -1,694 +0,0 @@
-/*
- * Copyright (C) 2006-2007 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser 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.
- */
-
-#include <math.h>
-#include <gtk/gtkentry.h>
-
-#include "sugar-address-entry.h"
-
-enum {
- PROP_0,
- PROP_PROGRESS,
- PROP_ADDRESS,
- PROP_TITLE
-};
-
-typedef enum {
- CURSOR_STANDARD,
- CURSOR_DND
-} CursorType;
-
-static void _gtk_entry_effective_inner_border (GtkEntry *entry,
- GtkBorder *border);
-static void get_text_area_size (GtkEntry *entry,
- gint *x,
- gint *y,
- gint *width,
- gint *height);
-
-G_DEFINE_TYPE(SugarAddressEntry, sugar_address_entry, GTK_TYPE_ENTRY)
-
-static GQuark quark_inner_border = 0;
-static const GtkBorder default_inner_border = { 2, 2, 2, 2 };
-
-static void
-draw_insertion_cursor (GtkEntry *entry,
- GdkRectangle *cursor_location,
- gboolean is_primary,
- PangoDirection direction,
- gboolean draw_arrow)
-{
- GtkWidget *widget = GTK_WIDGET (entry);
- GtkTextDirection text_dir;
-
- if (direction == PANGO_DIRECTION_LTR)
- text_dir = GTK_TEXT_DIR_LTR;
- else
- text_dir = GTK_TEXT_DIR_RTL;
-
- gtk_draw_insertion_cursor (widget, entry->text_area, NULL,
- cursor_location,
- is_primary, text_dir, draw_arrow);
-}
-
-static void
-gtk_entry_get_pixel_ranges (GtkEntry *entry,
- gint **ranges,
- gint *n_ranges)
-{
- gint start_char, end_char;
-
- if (gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), &start_char, &end_char))
- {
- //PangoLayout *layout = gtk_entry_ensure_layout (entry, TRUE);
- PangoLayout *layout = gtk_entry_get_layout (entry);
- PangoLayoutLine *line = pango_layout_get_lines (layout)->data;
- const char *text = pango_layout_get_text (layout);
- gint start_index = g_utf8_offset_to_pointer (text, start_char) - text;
- gint end_index = g_utf8_offset_to_pointer (text, end_char) - text;
- gint real_n_ranges, i;
-
- pango_layout_line_get_x_ranges (line, start_index, end_index, ranges, &real_n_ranges);
-
- if (ranges)
- {
- gint *r = *ranges;
-
- for (i = 0; i < real_n_ranges; ++i)
- {
- r[2 * i + 1] = (r[2 * i + 1] - r[2 * i]) / PANGO_SCALE;
- r[2 * i] = r[2 * i] / PANGO_SCALE;
- }
- }
-
- if (n_ranges)
- *n_ranges = real_n_ranges;
- }
- else
- {
- if (n_ranges)
- *n_ranges = 0;
- if (ranges)
- *ranges = NULL;
- }
-}
-
-static void
-gtk_entry_get_cursor_locations (GtkEntry *entry,
- CursorType type,
- gint *strong_x,
- gint *weak_x)
-{
- if (!entry->visible && !entry->invisible_char)
- {
- if (strong_x)
- *strong_x = 0;
-
- if (weak_x)
- *weak_x = 0;
- }
- else
- {
- //PangoLayout *layout = gtk_entry_ensure_layout (entry, TRUE);
- PangoLayout *layout = gtk_entry_get_layout (entry);
- const gchar *text = pango_layout_get_text (layout);
- PangoRectangle strong_pos, weak_pos;
- gint index;
-
- if (type == CURSOR_STANDARD)
- {
- index = g_utf8_offset_to_pointer (text, entry->current_pos + entry->preedit_cursor) - text;
- }
- else /* type == CURSOR_DND */
- {
- index = g_utf8_offset_to_pointer (text, entry->dnd_position) - text;
-
- if (entry->dnd_position > entry->current_pos)
- {
- if (entry->visible)
- index += entry->preedit_length;
- else
- {
- gint preedit_len_chars = g_utf8_strlen (text, -1) - entry->text_length;
- index += preedit_len_chars * g_unichar_to_utf8 (entry->invisible_char, NULL);
- }
- }
- }
-
- pango_layout_get_cursor_pos (layout, index, &strong_pos, &weak_pos);
-
- if (strong_x)
- *strong_x = strong_pos.x / PANGO_SCALE;
-
- if (weak_x)
- *weak_x = weak_pos.x / PANGO_SCALE;
- }
-}
-
-static void
-gtk_entry_draw_cursor (GtkEntry *entry,
- CursorType type)
-{
- GdkKeymap *keymap = gdk_keymap_get_for_display (gtk_widget_get_display (GTK_WIDGET (entry)));
- PangoDirection keymap_direction = gdk_keymap_get_direction (keymap);
-
- if (GTK_WIDGET_DRAWABLE (entry))
- {
- GtkWidget *widget = GTK_WIDGET (entry);
- GdkRectangle cursor_location;
- gboolean split_cursor;
-
- GtkBorder inner_border;
- gint xoffset;
- gint strong_x, weak_x;
- gint text_area_height;
- PangoDirection dir1 = PANGO_DIRECTION_NEUTRAL;
- PangoDirection dir2 = PANGO_DIRECTION_NEUTRAL;
- gint x1 = 0;
- gint x2 = 0;
-
- _gtk_entry_effective_inner_border (entry, &inner_border);
-
- xoffset = inner_border.left - entry->scroll_offset;
-
- gdk_drawable_get_size (entry->text_area, NULL, &text_area_height);
-
- gtk_entry_get_cursor_locations (entry, type, &strong_x, &weak_x);
-
- g_object_get (gtk_widget_get_settings (widget),
- "gtk-split-cursor", &split_cursor,
- NULL);
-
- dir1 = entry->resolved_dir;
-
- if (split_cursor)
- {
- x1 = strong_x;
-
- if (weak_x != strong_x)
- {
- dir2 = (entry->resolved_dir == PANGO_DIRECTION_LTR) ? PANGO_DIRECTION_RTL : PANGO_DIRECTION_LTR;
- x2 = weak_x;
- }
- }
- else
- {
- if (keymap_direction == entry->resolved_dir)
- x1 = strong_x;
- else
- x1 = weak_x;
- }
-
- cursor_location.x = xoffset + x1;
- cursor_location.y = inner_border.top;
- cursor_location.width = 0;
- cursor_location.height = text_area_height - inner_border.top - inner_border.bottom;
-
- draw_insertion_cursor (entry,
- &cursor_location, TRUE, dir1,
- dir2 != PANGO_DIRECTION_NEUTRAL);
-
- if (dir2 != PANGO_DIRECTION_NEUTRAL)
- {
- cursor_location.x = xoffset + x2;
- draw_insertion_cursor (entry,
- &cursor_location, FALSE, dir2,
- TRUE);
- }
- }
-}
-
-static void
-get_layout_position (GtkEntry *entry,
- gint *x,
- gint *y)
-{
- PangoLayout *layout;
- PangoRectangle logical_rect;
- gint area_width, area_height;
- GtkBorder inner_border;
- gint y_pos;
- PangoLayoutLine *line;
-
-// layout = gtk_entry_ensure_layout (entry, TRUE);
- layout = gtk_entry_get_layout(entry);
-
- get_text_area_size (entry, NULL, NULL, &area_width, &area_height);
- _gtk_entry_effective_inner_border (entry, &inner_border);
-
- area_height = PANGO_SCALE * (area_height - inner_border.top - inner_border.bottom);
-
- line = pango_layout_get_lines (layout)->data;
- pango_layout_line_get_extents (line, NULL, &logical_rect);
-
- /* Align primarily for locale's ascent/descent */
- y_pos = ((area_height - entry->ascent - entry->descent) / 2 +
- entry->ascent + logical_rect.y);
-
- /* Now see if we need to adjust to fit in actual drawn string */
- if (logical_rect.height > area_height)
- y_pos = (area_height - logical_rect.height) / 2;
- else if (y_pos < 0)
- y_pos = 0;
- else if (y_pos + logical_rect.height > area_height)
- y_pos = area_height - logical_rect.height;
-
- y_pos = inner_border.top + y_pos / PANGO_SCALE;
-
- if (x)
- *x = inner_border.left - entry->scroll_offset;
-
- if (y)
- *y = y_pos;
-}
-
-static void
-_gtk_entry_effective_inner_border (GtkEntry *entry,
- GtkBorder *border)
-{
- GtkBorder *tmp_border;
-
- tmp_border = g_object_get_qdata (G_OBJECT (entry), quark_inner_border);
-
- if (tmp_border)
- {
- *border = *tmp_border;
- return;
- }
-
- gtk_widget_style_get (GTK_WIDGET (entry), "inner-border", &tmp_border, NULL);
-
- if (tmp_border)
- {
- *border = *tmp_border;
- g_free (tmp_border);
- return;
- }
-
- *border = default_inner_border;
-}
-
-static void
-gtk_entry_draw_text (GtkEntry *entry)
-{
- GtkWidget *widget;
-
- if (!entry->visible && entry->invisible_char == 0)
- return;
-
- if (GTK_WIDGET_DRAWABLE (entry))
- {
- //PangoLayout *layout = gtk_entry_ensure_layout (entry, TRUE);
- PangoLayout *layout = gtk_entry_get_layout (entry);
- cairo_t *cr;
- gint x, y;
- gint start_pos, end_pos;
-
- widget = GTK_WIDGET (entry);
-
- get_layout_position (entry, &x, &y);
-
- cr = gdk_cairo_create (entry->text_area);
-
- cairo_move_to (cr, x, y);
- gdk_cairo_set_source_color (cr, &widget->style->text [widget->state]);
- pango_cairo_show_layout (cr, layout);
-
- if (gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), &start_pos, &end_pos))
- {
- gint *ranges;
- gint n_ranges, i;
- PangoRectangle logical_rect;
- GdkColor *selection_color, *text_color;
- GtkBorder inner_border;
-
- pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
- gtk_entry_get_pixel_ranges (entry, &ranges, &n_ranges);
-
- if (GTK_WIDGET_HAS_FOCUS (entry))
- {
- selection_color = &widget->style->base [GTK_STATE_SELECTED];
- text_color = &widget->style->text [GTK_STATE_SELECTED];
- }
- else
- {
- selection_color = &widget->style->base [GTK_STATE_ACTIVE];
- text_color = &widget->style->text [GTK_STATE_ACTIVE];
- }
-
- _gtk_entry_effective_inner_border (entry, &inner_border);
-
- for (i = 0; i < n_ranges; ++i)
- cairo_rectangle (cr,
- inner_border.left - entry->scroll_offset + ranges[2 * i],
- y,
- ranges[2 * i + 1],
- logical_rect.height);
-
- cairo_clip (cr);
-
- gdk_cairo_set_source_color (cr, selection_color);
- cairo_paint (cr);
-
- cairo_move_to (cr, x, y);
- gdk_cairo_set_source_color (cr, text_color);
- pango_cairo_show_layout (cr, layout);
-
- g_free (ranges);
- }
-
- cairo_destroy (cr);
- }
-}
-
-static void
-sugar_address_entry_get_borders (GtkEntry *entry,
- gint *xborder,
- gint *yborder)
-{
- GtkWidget *widget = GTK_WIDGET (entry);
- gint focus_width;
- gboolean interior_focus;
-
- gtk_widget_style_get (widget,
- "interior-focus", &interior_focus,
- "focus-line-width", &focus_width,
- NULL);
-
- if (entry->has_frame)
- {
- *xborder = widget->style->xthickness;
- *yborder = widget->style->ythickness;
- }
- else
- {
- *xborder = 0;
- *yborder = 0;
- }
-
- if (!interior_focus)
- {
- *xborder += focus_width;
- *yborder += focus_width;
- }
-}
-
-static void
-get_text_area_size (GtkEntry *entry,
- gint *x,
- gint *y,
- gint *width,
- gint *height)
-{
- gint xborder, yborder;
- GtkRequisition requisition;
- GtkWidget *widget = GTK_WIDGET (entry);
-
- gtk_widget_get_child_requisition (widget, &requisition);
-
- sugar_address_entry_get_borders (entry, &xborder, &yborder);
-
- if (x)
- *x = xborder;
-
- if (y)
- *y = yborder;
-
- if (width)
- *width = GTK_WIDGET (entry)->allocation.width - xborder * 2;
-
- if (height)
- *height = requisition.height - yborder * 2;
-}
-
-static gint
-sugar_address_entry_expose(GtkWidget *widget,
- GdkEventExpose *event)
-{
- GtkEntry *entry = GTK_ENTRY (widget);
- SugarAddressEntry *address_entry = SUGAR_ADDRESS_ENTRY(widget);
- cairo_t *cr;
-
- if (entry->text_area == event->window) {
- gint area_width, area_height;
-
- get_text_area_size (entry, NULL, NULL, &area_width, &area_height);
-
-/* gtk_paint_flat_box (widget->style, entry->text_area,
- GTK_WIDGET_STATE(widget), GTK_SHADOW_NONE,
- NULL, widget, "entry_bg",
- 0, 0, area_width, area_height);
-*/
-
- if (address_entry->progress != 0.0 && address_entry->progress != 1.0 &&
- !GTK_WIDGET_HAS_FOCUS(entry)) {
- int bar_width = area_width * address_entry->progress;
- float radius = area_height / 2;
-
- cr = gdk_cairo_create(entry->text_area);
- cairo_set_source_rgb(cr, 0xA6 / 255.0, 0xA6 / 255.0, 0xA6 / 255.0);
-
- cairo_move_to (cr, radius, 0);
- cairo_arc (cr, bar_width - radius, radius, radius, M_PI * 1.5, M_PI * 2);
- cairo_arc (cr, bar_width - radius, area_height - radius, radius, 0, M_PI * 0.5);
- cairo_arc (cr, radius, area_height - radius, radius, M_PI * 0.5, M_PI);
- cairo_arc (cr, radius, radius, radius, M_PI, M_PI * 1.5);
-
- cairo_fill(cr);
- cairo_destroy (cr);
- }
-
-
- if ((entry->visible || entry->invisible_char != 0) &&
- GTK_WIDGET_HAS_FOCUS (widget) &&
- entry->selection_bound == entry->current_pos && entry->cursor_visible)
- gtk_entry_draw_cursor (GTK_ENTRY (widget), CURSOR_STANDARD);
-
- if (entry->dnd_position != -1)
- gtk_entry_draw_cursor (GTK_ENTRY (widget), CURSOR_DND);
-
- gtk_entry_draw_text (GTK_ENTRY (widget));
- } else {
- GtkWidgetClass *parent_class;
- parent_class = GTK_WIDGET_CLASS(sugar_address_entry_parent_class);
- parent_class->expose_event(widget, event);
- }
-
- return FALSE;
-}
-
-static void
-entry_changed_cb(SugarAddressEntry *entry)
-{
- if (entry->address) {
- g_free (entry->address);
- }
-
- entry->address = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1);
-}
-
-static void
-update_entry_text(SugarAddressEntry *address_entry,
- gboolean has_focus)
-{
- g_signal_handlers_block_by_func(address_entry, entry_changed_cb, NULL);
-
- if (has_focus || address_entry->title == NULL) {
- gtk_entry_set_text(GTK_ENTRY(address_entry),
- address_entry->address);
- } else {
- gtk_entry_set_text(GTK_ENTRY(address_entry),
- address_entry->title);
- }
-
- g_signal_handlers_unblock_by_func(address_entry, entry_changed_cb, NULL);
-}
-
-static void
-sugar_address_entry_set_address(SugarAddressEntry *address_entry,
- const char *address)
-{
- g_free(address_entry->address);
- address_entry->address = g_strdup(address);
-
- update_entry_text(address_entry,
- gtk_widget_is_focus(GTK_WIDGET(address_entry)));
-}
-
-static void
-sugar_address_entry_set_title(SugarAddressEntry *address_entry,
- const char *title)
-{
- g_free(address_entry->title);
- address_entry->title = g_strdup(title);
-
- update_entry_text(address_entry,
- gtk_widget_is_focus(GTK_WIDGET(address_entry)));
-}
-
-static void
-sugar_address_entry_set_property(GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- SugarAddressEntry *address_entry = SUGAR_ADDRESS_ENTRY(object);
- GtkEntry *entry = GTK_ENTRY(object);
-
- switch (prop_id) {
- case PROP_PROGRESS:
- address_entry->progress = g_value_get_double(value);
- if (GTK_WIDGET_REALIZED(entry))
- gdk_window_invalidate_rect(entry->text_area, NULL, FALSE);
- break;
- case PROP_ADDRESS:
- sugar_address_entry_set_address(address_entry,
- g_value_get_string(value));
- break;
- case PROP_TITLE:
- sugar_address_entry_set_title(address_entry,
- g_value_get_string(value));
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-sugar_address_entry_get_property(GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- SugarAddressEntry *entry = SUGAR_ADDRESS_ENTRY(object);
-
- switch (prop_id) {
- case PROP_PROGRESS:
- g_value_set_double(value, entry->progress);
- break;
- case PROP_TITLE:
- g_value_set_string(value, entry->title);
- break;
- case PROP_ADDRESS:
- g_value_set_string(value, entry->address);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-sugar_address_entry_class_init(SugarAddressEntryClass *klass)
-{
- GtkWidgetClass *widget_class = (GtkWidgetClass*)klass;
- GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
-
- widget_class->expose_event = sugar_address_entry_expose;
-
- gobject_class->set_property = sugar_address_entry_set_property;
- gobject_class->get_property = sugar_address_entry_get_property;
-
- quark_inner_border = g_quark_from_static_string ("gtk-entry-inner-border");
-
- g_object_class_install_property (gobject_class, PROP_PROGRESS,
- g_param_spec_double("progress",
- "Progress",
- "Progress",
- 0.0, 1.0, 0.0,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (gobject_class, PROP_TITLE,
- g_param_spec_string("title",
- "Title",
- "Title",
- "",
- G_PARAM_READWRITE));
-
- g_object_class_install_property (gobject_class, PROP_ADDRESS,
- g_param_spec_string("address",
- "Address",
- "Address",
- "",
- G_PARAM_READWRITE));
-}
-
-static gboolean
-button_press_event_cb (GtkWidget *widget, GdkEventButton *event)
-{
- if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) {
- gtk_editable_select_region(GTK_EDITABLE(widget), 0, -1);
- gtk_widget_grab_focus(widget);
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-static gboolean
-focus_in_event_cb(GtkWidget *widget, GdkEventFocus *event)
-{
- update_entry_text(SUGAR_ADDRESS_ENTRY(widget), TRUE);
- return FALSE;
-}
-
-static gboolean
-focus_out_event_cb(GtkWidget *widget, GdkEventFocus *event)
-{
- update_entry_text(SUGAR_ADDRESS_ENTRY(widget), FALSE);
- return FALSE;
-}
-
-static void
-popup_unmap_cb(GtkWidget *popup, SugarAddressEntry *entry)
-{
- g_signal_handlers_unblock_by_func(entry, focus_out_event_cb, NULL);
-}
-
-static void
-populate_popup_cb(SugarAddressEntry *entry, GtkWidget *menu)
-{
- g_signal_handlers_block_by_func(entry, focus_out_event_cb, NULL);
-
- g_signal_connect(menu, "unmap",
- G_CALLBACK(popup_unmap_cb), entry);
-}
-
-static void
-sugar_address_entry_init(SugarAddressEntry *entry)
-{
- entry->progress = 0.0;
- entry->address = NULL;
- entry->title = g_strdup("");
-
- g_signal_connect(entry, "focus-in-event",
- G_CALLBACK(focus_in_event_cb), NULL);
- g_signal_connect(entry, "focus-out-event",
- G_CALLBACK(focus_out_event_cb), NULL);
- g_signal_connect(entry, "changed",
- G_CALLBACK(entry_changed_cb), NULL);
- g_signal_connect(entry, "button-press-event",
- G_CALLBACK(button_press_event_cb), NULL);
- g_signal_connect(entry, "populate-popup",
- G_CALLBACK(populate_popup_cb), NULL);
-}
diff --git a/lib/ui/sugar-address-entry.h b/lib/ui/sugar-address-entry.h
deleted file mode 100644
index 60c56ab..0000000
--- a/lib/ui/sugar-address-entry.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2006-2007 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser 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.
- */
-
-#ifndef __SUGAR_ADDRESS_ENTRY_H__
-#define __SUGAR_ADDRESS_ENTRY_H__
-
-#include <gtk/gtkentry.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SugarAddressEntry SugarAddressEntry;
-typedef struct _SugarAddressEntryClass SugarAddressEntryClass;
-typedef struct _SugarAddressEntryPrivate SugarAddressEntryPrivate;
-
-#define SUGAR_TYPE_ADDRESS_ENTRY (sugar_address_entry_get_type())
-#define SUGAR_ADDRESS_ENTRY(object) (G_TYPE_CHECK_INSTANCE_CAST((object), SUGAR_TYPE_ADDRESS_ENTRY, SugarAddressEntry))
-#define SUGAR_ADDRESS_ENTRY_CLASS(klass) (G_TYPE_CHACK_CLASS_CAST((klass), SUGAR_TYPE_ADDRESS_ENTRY, SugarAddressEntryClass))
-#define SUGAR_IS_ADDRESS_ENTRY(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), SUGAR_TYPE_ADDRESS_ENTRY))
-#define SUGAR_IS_ADDRESS_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SUGAR_TYPE_ADDRESS_ENTRY))
-#define SUGAR_ADDRESS_ENTRY_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), SUGAR_TYPE_ADDRESS_ENTRY, SugarAddressEntryClass))
-
-struct _SugarAddressEntry {
- GtkEntry base_instance;
-
- float progress;
- char *title;
- char *address;
-};
-
-struct _SugarAddressEntryClass {
- GtkEntryClass base_class;
-};
-
-GType sugar_address_entry_get_type (void);
-
-G_END_DECLS
-
-#endif /* __SUGAR_ADDRESS_ENTRY_H__ */
diff --git a/lib/ui/sugar-key-grabber.c b/lib/ui/sugar-key-grabber.c
deleted file mode 100644
index baddab5..0000000
--- a/lib/ui/sugar-key-grabber.c
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * Copyright (C) 2006-2007, Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser 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.
- */
-
-#include <X11/X.h>
-#include <gdk/gdkscreen.h>
-#include <gdk/gdkx.h>
-#include <gdk/gdk.h>
-
-#include "sugar-key-grabber.h"
-#include "eggaccelerators.h"
-#include "sugar-marshal.h"
-
-/* we exclude shift, GDK_CONTROL_MASK and GDK_MOD1_MASK since we know what
- these modifiers mean
- these are the mods whose combinations are bound by the keygrabbing code */
-#define IGNORED_MODS (0x2000 /*Xkb modifier*/ | GDK_LOCK_MASK | \
- GDK_MOD2_MASK | GDK_MOD3_MASK | GDK_MOD4_MASK | GDK_MOD5_MASK)
-/* these are the ones we actually use for global keys, we always only check
- * for these set */
-#define USED_MODS (GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK)
-
-enum {
- KEY_PRESSED,
- KEY_RELEASED,
- N_SIGNALS
-};
-
-typedef struct {
- char *key;
- guint keysym;
- guint state;
- guint keycode;
-} Key;
-
-G_DEFINE_TYPE(SugarKeyGrabber, sugar_key_grabber, G_TYPE_OBJECT)
-
-static guint signals[N_SIGNALS];
-
-static void
-free_key_info(Key *key_info)
-{
- g_free(key_info->key);
- g_free(key_info);
-}
-
-static void
-sugar_key_grabber_dispose (GObject *object)
-{
- SugarKeyGrabber *grabber = SUGAR_KEY_GRABBER(object);
-
- if (grabber->keys) {
- g_list_foreach(grabber->keys, (GFunc)free_key_info, NULL);
- g_list_free(grabber->keys);
- grabber->keys = NULL;
- }
-}
-
-static void
-sugar_key_grabber_class_init(SugarKeyGrabberClass *grabber_class)
-{
- GObjectClass *g_object_class = G_OBJECT_CLASS (grabber_class);
-
- g_object_class->dispose = sugar_key_grabber_dispose;
-
- signals[KEY_PRESSED] = g_signal_new ("key-pressed",
- G_TYPE_FROM_CLASS (grabber_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (SugarKeyGrabberClass, key_pressed),
- NULL, NULL,
- sugar_marshal_BOOLEAN__UINT_UINT,
- G_TYPE_BOOLEAN, 2,
- G_TYPE_UINT,
- G_TYPE_UINT);
- signals[KEY_RELEASED] = g_signal_new ("key-released",
- G_TYPE_FROM_CLASS (grabber_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (SugarKeyGrabberClass, key_released),
- NULL, NULL,
- sugar_marshal_BOOLEAN__UINT_UINT,
- G_TYPE_BOOLEAN, 2,
- G_TYPE_UINT,
- G_TYPE_UINT);
-}
-
-char *
-sugar_key_grabber_get_key(SugarKeyGrabber *grabber, guint keycode, guint state)
-{
- GList *l;
-
- for (l = grabber->keys; l != NULL; l = l->next) {
- Key *keyinfo = (Key *)l->data;
- if ((keyinfo->keycode == keycode) &&
- ((state & USED_MODS) == keyinfo->state)) {
- return g_strdup(keyinfo->key);
- }
- }
-
- return NULL;
-}
-
-static GdkFilterReturn
-filter_events(GdkXEvent *xevent, GdkEvent *event, gpointer data)
-{
- SugarKeyGrabber *grabber = (SugarKeyGrabber *)data;
- XEvent *xev = (XEvent *)xevent;
-
- if (xev->type == KeyRelease) {
- int return_value;
- g_signal_emit (grabber, signals[KEY_RELEASED], 0, xev->xkey.keycode,
- xev->xkey.state, &return_value);
- if(return_value)
- return GDK_FILTER_REMOVE;
- }
-
- if (xev->type == KeyPress) {
- int return_value;
- g_signal_emit (grabber, signals[KEY_PRESSED], 0, xev->xkey.keycode,
- xev->xkey.state, &return_value);
- if(return_value)
- return GDK_FILTER_REMOVE;
- }
-
- return GDK_FILTER_CONTINUE;
-}
-
-static void
-sugar_key_grabber_init(SugarKeyGrabber *grabber)
-{
- GdkScreen *screen;
-
- screen = gdk_screen_get_default();
- grabber->root = gdk_screen_get_root_window(screen);
- grabber->keys = NULL;
-
- gdk_window_add_filter(grabber->root, filter_events, grabber);
-}
-
-/* grab_key and grab_key_real are from
- * gnome-control-center/gnome-settings-daemon/gnome-settings-multimedia-keys.c
- */
-
-static gboolean
-grab_key_real (Key *key, GdkWindow *root, gboolean grab, int result)
-{
- gdk_error_trap_push ();
- if (grab)
- XGrabKey (GDK_DISPLAY(), key->keycode, (result | key->state),
- GDK_WINDOW_XID (root), True, GrabModeAsync, GrabModeAsync);
- else
- XUngrabKey(GDK_DISPLAY(), key->keycode, (result | key->state),
- GDK_WINDOW_XID (root));
- gdk_flush ();
-
- gdk_error_trap_pop ();
-
- return TRUE;
-}
-
-#define N_BITS 32
-static void
-grab_key (SugarKeyGrabber *grabber, Key *key, gboolean grab)
-{
- int indexes[N_BITS];/*indexes of bits we need to flip*/
- int i, bit, bits_set_cnt;
- int uppervalue;
- guint mask_to_traverse = IGNORED_MODS & ~ key->state;
-
- bit = 0;
- for (i = 0; i < N_BITS; i++) {
- if (mask_to_traverse & (1<<i))
- indexes[bit++]=i;
- }
-
- bits_set_cnt = bit;
-
- uppervalue = 1<<bits_set_cnt;
- for (i = 0; i < uppervalue; i++) {
- int j, result = 0;
-
- for (j = 0; j < bits_set_cnt; j++) {
- if (i & (1<<j))
- result |= (1<<indexes[j]);
- }
-
- if (grab_key_real (key, grabber->root, grab, result) == FALSE)
- return;
- }
-}
-
-void
-sugar_key_grabber_grab(SugarKeyGrabber *grabber, const char *key)
-{
- Key *keyinfo;
-
- keyinfo = g_new0 (Key, 1);
- keyinfo->key = g_strdup(key);
- egg_accelerator_parse_virtual (key, &keyinfo->keysym,
- &keyinfo->keycode, &keyinfo->state);
-
- grab_key(grabber, keyinfo, TRUE);
-
- grabber->keys = g_list_append(grabber->keys, keyinfo);
-}
diff --git a/lib/ui/sugar-key-grabber.h b/lib/ui/sugar-key-grabber.h
deleted file mode 100644
index 5b734e7..0000000
--- a/lib/ui/sugar-key-grabber.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2006-2007, Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser 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.
- */
-
-#ifndef __SUGAR_KEY_GRABBER_H__
-#define __SUGAR_KEY_GRABBER_H__
-
-#include <glib-object.h>
-#include <gdk/gdkwindow.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SugarKeyGrabber SugarKeyGrabber;
-typedef struct _SugarKeyGrabberClass SugarKeyGrabberClass;
-typedef struct _SugarKeyGrabberPrivate SugarKeyGrabberPrivate;
-
-#define SUGAR_TYPE_KEY_GRABBER (sugar_key_grabber_get_type())
-#define SUGAR_KEY_GRABBER(object) (G_TYPE_CHECK_INSTANCE_CAST((object), SUGAR_TYPE_KEY_GRABBER, SugarKeyGrabber))
-#define SUGAR_KEY_GRABBER_CLASS(klass) (G_TYPE_CHACK_CLASS_CAST((klass), SUGAR_TYPE_KEY_GRABBER, SugarKeyGrabberClass))
-#define SUGAR_IS_KEY_GRABBER(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), SUGAR_TYPE_KEY_GRABBER))
-#define SUGAR_IS_KEYGRABBER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SUGAR_TYPE_KEY_GRABBER))
-#define SUGAR_KEY_GRABBER_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), SUGAR_TYPE_KEY_GRABBER, SugarKeyGrabberClass))
-
-struct _SugarKeyGrabber {
- GObject base_instance;
-
- GdkWindow *root;
- GList *keys;
-};
-
-struct _SugarKeyGrabberClass {
- GObjectClass base_class;
-
- gboolean (* key_pressed) (SugarKeyGrabber *grabber,
- guint keycode,
- guint state);
- gboolean (* key_released) (SugarKeyGrabber *grabber,
- guint keycode,
- guint state);
-};
-
-GType sugar_key_grabber_get_type (void);
-void sugar_key_grabber_grab (SugarKeyGrabber *grabber,
- const char *key);
-char *sugar_key_grabber_get_key (SugarKeyGrabber *grabber,
- guint keycode,
- guint state);
-
-G_END_DECLS
-
-#endif /* __SUGAR_KEY_GRABBER_H__ */
diff --git a/lib/ui/sugar-marshal.list b/lib/ui/sugar-marshal.list
deleted file mode 100644
index 41ce620..0000000
--- a/lib/ui/sugar-marshal.list
+++ /dev/null
@@ -1 +0,0 @@
-BOOLEAN:UINT,UINT
diff --git a/lib/ui/sugar-menu.c b/lib/ui/sugar-menu.c
deleted file mode 100644
index f19dc4b..0000000
--- a/lib/ui/sugar-menu.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2006-2007, Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser 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.
- */
-
-#include <gtk/gtkwindow.h>
-
-#include "sugar-menu.h"
-
-static void sugar_menu_class_init (SugarMenuClass *menu_class);
-static void sugar_menu_init (SugarMenu *menu);
-
-
-G_DEFINE_TYPE(SugarMenu, sugar_menu, GTK_TYPE_MENU)
-
-void
-sugar_menu_set_active(SugarMenu *menu, gboolean active)
-{
- GTK_MENU_SHELL(menu)->active = active;
-}
-
-void
-sugar_menu_embed(SugarMenu *menu, GtkContainer *parent)
-{
- menu->orig_toplevel = GTK_MENU(menu)->toplevel;
-
- GTK_MENU(menu)->toplevel = gtk_widget_get_toplevel(GTK_WIDGET(parent));
- gtk_widget_reparent(GTK_WIDGET(menu), GTK_WIDGET(parent));
-}
-
-void
-sugar_menu_unembed(SugarMenu *menu)
-{
- if (menu->orig_toplevel) {
- GTK_MENU(menu)->toplevel = menu->orig_toplevel;
- gtk_widget_reparent(GTK_WIDGET(menu), GTK_WIDGET(menu->orig_toplevel));
- }
-}
-
-static void
-sugar_menu_class_init(SugarMenuClass *menu_class)
-{
-}
-
-static void
-sugar_menu_init(SugarMenu *menu)
-{
- menu->orig_toplevel = NULL;
-}
diff --git a/lib/ui/sugar-menu.h b/lib/ui/sugar-menu.h
deleted file mode 100644
index 8773a31..0000000
--- a/lib/ui/sugar-menu.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2006-2007, Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser 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.
- */
-
-#ifndef __SUGAR_MENU_H__
-#define __SUGAR_MENU_H__
-
-#include <gtk/gtkmenu.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SugarMenu SugarMenu;
-typedef struct _SugarMenuClass SugarMenuClass;
-
-#define SUGAR_TYPE_MENU (sugar_menu_get_type())
-#define SUGAR_MENU(object) (G_TYPE_CHECK_INSTANCE_CAST((object), SUGAR_TYPE_MENU, SugarMenu))
-#define SUGAR_MENU_CLASS(klass) (G_TYPE_CHACK_CLASS_CAST((klass), SUGAR_TYPE_MENU, SugarMenuClass))
-#define SUGAR_IS_MENU(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), SUGAR_TYPE_MENU))
-#define SUGAR_IS_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SUGAR_TYPE_MENU))
-#define SUGAR_MENU_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), SUGAR_TYPE_MENU, SugarMenuClass))
-
-struct _SugarMenu {
- GtkMenu base_instance;
-
- GtkWidget *orig_toplevel;
- int min_width;
-};
-
-struct _SugarMenuClass {
- GtkMenuClass base_class;
-};
-
-GType sugar_menu_get_type (void);
-void sugar_menu_set_active (SugarMenu *menu,
- gboolean active);
-void sugar_menu_embed (SugarMenu *menu,
- GtkContainer *parent);
-
-G_END_DECLS
-
-#endif /* __SUGAR_MENU_H__ */
diff --git a/lib/ui/sugar-x11-util.c b/lib/ui/sugar-x11-util.c
deleted file mode 100644
index b57d051..0000000
--- a/lib/ui/sugar-x11-util.c
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2006-2007 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser 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.
- */
-
-#include <gdk/gdkproperty.h>
-#include <X11/Xatom.h>
-#include <glib/gstrfuncs.h>
-#include <string.h>
-
-#include "sugar-x11-util.h"
-
-void
-sugar_x11_util_set_string_property(GdkWindow *window,
- const char *property,
- const char *value)
-{
- Atom prop_atom;
- Atom string_atom;
- GdkDisplay *display;
- char *prop_text;
-
- display = gdk_drawable_get_display(window);
- prop_atom = gdk_x11_get_xatom_by_name_for_display(display, property);
- string_atom = gdk_x11_get_xatom_by_name_for_display(display, "STRING");
- prop_text = gdk_utf8_to_string_target(value);
-
- XChangeProperty(GDK_DISPLAY_XDISPLAY(display),
- GDK_WINDOW_XID(window),
- prop_atom,
- string_atom, 8,
- PropModeReplace, prop_text,
- strlen(prop_text));
-
- g_free(prop_text);
-}
-
-char *
-sugar_x11_util_get_string_property(GdkWindow *window,
- const char *property)
-{
- Atom type;
- Atom prop_atom;
- Atom string_atom;
- int format;
- int result;
- unsigned long bytes_after, n_items;
- unsigned char *str = NULL;
- char *value = NULL;
- GdkDisplay *display;
-
- display = gdk_drawable_get_display(window);
- prop_atom = gdk_x11_get_xatom_by_name_for_display(display, property);
- string_atom = gdk_x11_get_xatom_by_name_for_display(display, "STRING");
-
- result = XGetWindowProperty(GDK_DISPLAY_XDISPLAY(display),
- GDK_WINDOW_XID(window),
- prop_atom,
- 0, 1024L,
- False, string_atom,
- &type, &format, &n_items,
- &bytes_after, (unsigned char **)&str);
-
- if (result == Success && str != NULL && type == string_atom &&
- format == 8 && n_items > 0) {
- value = g_strdup(str);
- }
-
- if (str) {
- XFree(str);
- }
-
- return value;
-}
diff --git a/lib/ui/sugar-x11-util.h b/lib/ui/sugar-x11-util.h
deleted file mode 100644
index 54655a9..0000000
--- a/lib/ui/sugar-x11-util.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2006-2007 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser 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.
- */
-
-#ifndef __SUGAR_X11_UTIL_H__
-#define __SUGAR_X11_UTIL_H__
-
-#include <gdk/gdkx.h>
-
-G_BEGIN_DECLS
-
-void sugar_x11_util_set_string_property(GdkWindow *window,
- const char *property,
- const char *value);
-
-char *sugar_x11_util_get_string_property(GdkWindow *window,
- const char *property);
-
-G_END_DECLS
-
-#endif /* __SUGAR_ADDRESS_ENTRY_H__ */