Move private extensions out of the lib, inside the shell.

This commit is contained in:
Marco Pesenti Gritti 2007-04-07 00:08:54 +02:00
parent 1d25366c4f
commit 2d08ff0163
28 changed files with 2160 additions and 56 deletions

View File

@ -37,7 +37,9 @@ PKG_CHECK_MODULES(PYGTK, pygtk-2.0)
PKG_CHECK_MODULES(PYCAIRO, pycairo) PKG_CHECK_MODULES(PYCAIRO, pycairo)
PKG_CHECK_MODULES(LIB, gtk+-2.0 gstreamer-0.10 gstreamer-plugins-base-0.10) PKG_CHECK_MODULES(LIB, gtk+-2.0)
PKG_CHECK_MODULES(SHELL, gtk+-2.0 gstreamer-0.10 gstreamer-plugins-base-0.10)
PYGTK_DEFSDIR=`$PKG_CONFIG --variable=defsdir pygtk-2.0` PYGTK_DEFSDIR=`$PKG_CONFIG --variable=defsdir pygtk-2.0`
AC_SUBST(PYGTK_DEFSDIR) AC_SUBST(PYGTK_DEFSDIR)
@ -127,6 +129,7 @@ services/presence2/Makefile
services/clipboard/Makefile services/clipboard/Makefile
services/datastore/Makefile services/datastore/Makefile
shell/Makefile shell/Makefile
shell/extensions/Makefile
shell/intro/Makefile shell/intro/Makefile
shell/hardware/Makefile shell/hardware/Makefile
shell/view/Makefile shell/view/Makefile

View File

@ -31,13 +31,6 @@
(gtype-id "SUGAR_TYPE_BROWSER") (gtype-id "SUGAR_TYPE_BROWSER")
) )
(define-object KeyGrabber
(in-module "Sugar")
(parent "GObject")
(c-name "SugarKeyGrabber")
(gtype-id "SUGAR_TYPE_KEY_GRABBER")
)
(define-object DownloadManager (define-object DownloadManager
(in-module "Sugar") (in-module "Sugar")
(parent "GObject") (parent "GObject")
@ -52,14 +45,6 @@
(gtype-id "SUGAR_TYPE_DOWNLOAD") (gtype-id "SUGAR_TYPE_DOWNLOAD")
) )
(define-object AudioManager
(in-module "Sugar")
(parent "GObject")
(c-name "SugarAudioManager")
(gtype-id "SUGAR_TYPE_AUDIO_MANAGER")
)
;; Enumerations and flags ... ;; Enumerations and flags ...
@ -70,8 +55,6 @@
(return-type "GType") (return-type "GType")
) )
;; From sugar-browser.h ;; From sugar-browser.h
(define-function sugar_browser_get_type (define-function sugar_browser_get_type
@ -216,25 +199,6 @@
) )
) )
;; Enumerations and flags ...
;; From sugar-audio-manager.h
(define-function audio_manager_get_type
(c-name "sugar_audio_manager_get_type")
(return-type "GType")
)
(define-method set_volume
(of-object "SugarAudioManager")
(c-name "sugar_audio_manager_set_volume")
(return-type "none")
(parameters
'("int" "level")
)
)
;; From sugar-utils.h ;; From sugar-utils.h
(define-function get_screen_dpi (define-function get_screen_dpi

View File

@ -5,11 +5,9 @@ headers
#include "pygobject.h" #include "pygobject.h"
#include "sugar-browser.h" #include "sugar-browser.h"
#include "sugar-key-grabber.h"
#include "sugar-address-entry.h" #include "sugar-address-entry.h"
#include "sugar-download-manager.h" #include "sugar-download-manager.h"
#include "sugar-download.h" #include "sugar-download.h"
#include "sugar-audio-manager.h"
#include "pycairo.h" #include "pycairo.h"
#include <pygtk/pygtk.h> #include <pygtk/pygtk.h>

View File

@ -22,30 +22,22 @@ noinst_LTLIBRARIES = libsugarprivate.la
libsugarprivate_la_LIBADD = \ libsugarprivate_la_LIBADD = \
$(LIB_LIBS) \ $(LIB_LIBS) \
$(GECKO_LIBS) \ $(GECKO_LIBS)
-lgstinterfaces-0.10 \
-lgstaudio-0.10
libsugarprivate_la_SOURCES = \ libsugarprivate_la_SOURCES = \
$(BUILT_SOURCES) \ $(BUILT_SOURCES) \
eggaccelerators.h \
eggaccelerators.c \
GeckoContentHandler.h \ GeckoContentHandler.h \
GeckoContentHandler.cpp \ GeckoContentHandler.cpp \
GeckoDownload.h \ GeckoDownload.h \
GeckoDownload.cpp \ GeckoDownload.cpp \
sugar-address-entry.h \
sugar-address-entry.c \ sugar-address-entry.c \
sugar-audio-manager.c \ sugar-address-entry.h \
sugar-audio-manager.h \
sugar-browser.h \ sugar-browser.h \
sugar-browser.cpp \ sugar-browser.cpp \
sugar-download.h \ sugar-download.h \
sugar-download.c \ sugar-download.c \
sugar-download-manager.h \ sugar-download-manager.h \
sugar-download-manager.c \ sugar-download-manager.c \
sugar-key-grabber.h \
sugar-key-grabber.c \
sugar-utils.c \ sugar-utils.c \
sugar-utils.h sugar-utils.h

View File

@ -2,4 +2,3 @@ VOID:OBJECT,STRING,LONG,LONG
VOID:OBJECT,LONG VOID:OBJECT,LONG
VOID:OBJECT VOID:OBJECT
BOOLEAN:BOXED BOOLEAN:BOXED
BOOLEAN:UINT,UINT

View File

@ -1,4 +1,4 @@
SUBDIRS = hardware model view intro SUBDIRS = extensions hardware model view intro
bin_SCRIPTS = sugar-shell bin_SCRIPTS = sugar-shell

View File

@ -0,0 +1,73 @@
sugardir = $(pkgdatadir)/shell
sugar_PYTHON = \
__init__.py
pkgpyexecdir = $(pkgdatadir)/shell
pkgpyexec_LTLIBRARIES = extensions.la
extensions_la_LDFLAGS = -module -avoid-version
extensions_la_CFLAGS = \
$(WARN_CFLAGS) \
$(PYTHON_INCLUDES) \
$(PYGTK_CFLAGS) \
$(SHELL_CFLAGS) \
$(top_srcdir)/shell/extensions
extensions_la_LIBADD = \
$(SHELL_LIBS) \
$(PYCAIRO_LIBS) \
-lgstinterfaces-0.10 \
-lgstaudio-0.10
extensions_la_SOURCES = \
$(BUILT_SOURCES) \
eggaccelerators.h \
eggaccelerators.c \
sugar-audio-manager.c \
sugar-audio-manager.h \
sugar-key-grabber.h \
sugar-key-grabber.c \
extensionsmodule.c
BUILT_SOURCES = \
extensions.c \
sugar-shell-marshal.c \
sugar-shell-marshal.h
stamp_files = \
stamp-sugar-shell-marshal.c \
stamp-sugar-shell-marshal.h
sugar-shell-marshal.c: stamp-sugar-shell-marshal.c
@true
stamp-sugar-shell-marshal.c: sugar-shell-marshal.list
$(GLIB_GENMARSHAL) --prefix=sugar_shell_marshal \
$(srcdir)/sugar-shell-marshal.list --header --body > \
sugar-shell-marshal.c && echo timestamp > $(@F)
sugar-shell-marshal.h: stamp-sugar-shell-marshal.h
@true
stamp-sugar-shell-marshal.h: sugar-shell-marshal.list
$(GLIB_GENMARSHAL) --prefix=sugar_shell_marshal \
$(srcdir)/sugar-shell-marshal.list --header > \
sugar-shell-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 extensions.override extensions.defs
extensions.c: extensions.defs extensions.override
.defs.c:
(cd $(srcdir)\
&& $(PYGTK_CODEGEN) \
--register $(PYGTK_DEFSDIR)/gdk-types.defs \
--register $(PYGTK_DEFSDIR)/gtk-types.defs \
--override $*.override \
--prefix py$* $*.defs) > gen-$*.c \
&& cp gen-$*.c $*.c \
&& rm -f gen-$*.c

View File

@ -0,0 +1,17 @@
# Copyright (C) 2007, Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
from extensions import extensions

View File

@ -0,0 +1,702 @@
/* 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;
}

View File

@ -0,0 +1,89 @@
/* 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__ */

View File

@ -0,0 +1,260 @@
/* -- THIS FILE IS GENERATED - DO NOT EDIT *//* -*- Mode: C; c-basic-offset: 4 -*- */
#include <Python.h>
#line 4 "extensions.override"
#include <Python.h>
#include "pygobject.h"
#include "sugar-key-grabber.h"
#include "sugar-address-entry.h"
#include "sugar-audio-manager.h"
#line 16 "extensions.c"
/* ---------- types from other modules ---------- */
static PyTypeObject *_PyGObject_Type;
#define PyGObject_Type (*_PyGObject_Type)
static PyTypeObject *_PyGtkEntry_Type;
#define PyGtkEntry_Type (*_PyGtkEntry_Type)
/* ---------- forward type declarations ---------- */
PyTypeObject G_GNUC_INTERNAL PySugarKeyGrabber_Type;
PyTypeObject G_GNUC_INTERNAL PySugarAudioManager_Type;
#line 30 "extensions.c"
/* ----------- SugarKeyGrabber ----------- */
static PyObject *
_wrap_sugar_key_grabber_grab(PyGObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "key", NULL };
char *key;
if (!PyArg_ParseTupleAndKeywords(args, kwargs,"s:SugarKeyGrabber.grab", kwlist, &key))
return NULL;
sugar_key_grabber_grab(SUGAR_KEY_GRABBER(self->obj), key);
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
_wrap_sugar_key_grabber_get_key(PyGObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "keycode", "state", NULL };
PyObject *py_keycode = NULL, *py_state = NULL;
gchar *ret;
guint keycode = 0, state = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs,"OO:SugarKeyGrabber.get_key", kwlist, &py_keycode, &py_state))
return NULL;
if (py_keycode) {
if (PyLong_Check(py_keycode))
keycode = PyLong_AsUnsignedLong(py_keycode);
else if (PyInt_Check(py_keycode))
keycode = PyInt_AsLong(py_keycode);
else
PyErr_SetString(PyExc_TypeError, "Parameter 'keycode' must be an int or a long");
if (PyErr_Occurred())
return NULL;
}
if (py_state) {
if (PyLong_Check(py_state))
state = PyLong_AsUnsignedLong(py_state);
else if (PyInt_Check(py_state))
state = PyInt_AsLong(py_state);
else
PyErr_SetString(PyExc_TypeError, "Parameter 'state' must be an int or a long");
if (PyErr_Occurred())
return NULL;
}
ret = sugar_key_grabber_get_key(SUGAR_KEY_GRABBER(self->obj), keycode, state);
if (ret) {
PyObject *py_ret = PyString_FromString(ret);
g_free(ret);
return py_ret;
}
Py_INCREF(Py_None);
return Py_None;
}
static const PyMethodDef _PySugarKeyGrabber_methods[] = {
{ "grab", (PyCFunction)_wrap_sugar_key_grabber_grab, METH_VARARGS|METH_KEYWORDS,
NULL },
{ "get_key", (PyCFunction)_wrap_sugar_key_grabber_get_key, METH_VARARGS|METH_KEYWORDS,
NULL },
{ NULL, NULL, 0, NULL }
};
PyTypeObject G_GNUC_INTERNAL PySugarKeyGrabber_Type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
"extensions.KeyGrabber", /* tp_name */
sizeof(PyGObject), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
(destructor)0, /* tp_dealloc */
(printfunc)0, /* tp_print */
(getattrfunc)0, /* tp_getattr */
(setattrfunc)0, /* tp_setattr */
(cmpfunc)0, /* tp_compare */
(reprfunc)0, /* tp_repr */
(PyNumberMethods*)0, /* tp_as_number */
(PySequenceMethods*)0, /* tp_as_sequence */
(PyMappingMethods*)0, /* tp_as_mapping */
(hashfunc)0, /* tp_hash */
(ternaryfunc)0, /* tp_call */
(reprfunc)0, /* tp_str */
(getattrofunc)0, /* tp_getattro */
(setattrofunc)0, /* tp_setattro */
(PyBufferProcs*)0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
NULL, /* Documentation string */
(traverseproc)0, /* tp_traverse */
(inquiry)0, /* tp_clear */
(richcmpfunc)0, /* tp_richcompare */
offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
(getiterfunc)0, /* tp_iter */
(iternextfunc)0, /* tp_iternext */
(struct PyMethodDef*)_PySugarKeyGrabber_methods, /* tp_methods */
(struct PyMemberDef*)0, /* tp_members */
(struct PyGetSetDef*)0, /* tp_getset */
NULL, /* tp_base */
NULL, /* tp_dict */
(descrgetfunc)0, /* tp_descr_get */
(descrsetfunc)0, /* tp_descr_set */
offsetof(PyGObject, inst_dict), /* tp_dictoffset */
(initproc)0, /* tp_init */
(allocfunc)0, /* tp_alloc */
(newfunc)0, /* tp_new */
(freefunc)0, /* tp_free */
(inquiry)0 /* tp_is_gc */
};
/* ----------- SugarAudioManager ----------- */
static PyObject *
_wrap_sugar_audio_manager_set_volume(PyGObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "level", NULL };
int level;
if (!PyArg_ParseTupleAndKeywords(args, kwargs,"i:SugarAudioManager.set_volume", kwlist, &level))
return NULL;
sugar_audio_manager_set_volume(SUGAR_AUDIO_MANAGER(self->obj), level);
Py_INCREF(Py_None);
return Py_None;
}
static const PyMethodDef _PySugarAudioManager_methods[] = {
{ "set_volume", (PyCFunction)_wrap_sugar_audio_manager_set_volume, METH_VARARGS|METH_KEYWORDS,
NULL },
{ NULL, NULL, 0, NULL }
};
PyTypeObject G_GNUC_INTERNAL PySugarAudioManager_Type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
"extensions.AudioManager", /* tp_name */
sizeof(PyGObject), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
(destructor)0, /* tp_dealloc */
(printfunc)0, /* tp_print */
(getattrfunc)0, /* tp_getattr */
(setattrfunc)0, /* tp_setattr */
(cmpfunc)0, /* tp_compare */
(reprfunc)0, /* tp_repr */
(PyNumberMethods*)0, /* tp_as_number */
(PySequenceMethods*)0, /* tp_as_sequence */
(PyMappingMethods*)0, /* tp_as_mapping */
(hashfunc)0, /* tp_hash */
(ternaryfunc)0, /* tp_call */
(reprfunc)0, /* tp_str */
(getattrofunc)0, /* tp_getattro */
(setattrofunc)0, /* tp_setattro */
(PyBufferProcs*)0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
NULL, /* Documentation string */
(traverseproc)0, /* tp_traverse */
(inquiry)0, /* tp_clear */
(richcmpfunc)0, /* tp_richcompare */
offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
(getiterfunc)0, /* tp_iter */
(iternextfunc)0, /* tp_iternext */
(struct PyMethodDef*)_PySugarAudioManager_methods, /* tp_methods */
(struct PyMemberDef*)0, /* tp_members */
(struct PyGetSetDef*)0, /* tp_getset */
NULL, /* tp_base */
NULL, /* tp_dict */
(descrgetfunc)0, /* tp_descr_get */
(descrsetfunc)0, /* tp_descr_set */
offsetof(PyGObject, inst_dict), /* tp_dictoffset */
(initproc)0, /* tp_init */
(allocfunc)0, /* tp_alloc */
(newfunc)0, /* tp_new */
(freefunc)0, /* tp_free */
(inquiry)0 /* tp_is_gc */
};
/* ----------- functions ----------- */
const PyMethodDef pyextensions_functions[] = {
{ NULL, NULL, 0, NULL }
};
/* initialise stuff extension classes */
void
pyextensions_register_classes(PyObject *d)
{
PyObject *module;
if ((module = PyImport_ImportModule("gobject")) != NULL) {
_PyGObject_Type = (PyTypeObject *)PyObject_GetAttrString(module, "GObject");
if (_PyGObject_Type == NULL) {
PyErr_SetString(PyExc_ImportError,
"cannot import name GObject from gobject");
return ;
}
} else {
PyErr_SetString(PyExc_ImportError,
"could not import gobject");
return ;
}
if ((module = PyImport_ImportModule("gtk")) != NULL) {
_PyGtkEntry_Type = (PyTypeObject *)PyObject_GetAttrString(module, "Entry");
if (_PyGtkEntry_Type == NULL) {
PyErr_SetString(PyExc_ImportError,
"cannot import name Entry from gtk");
return ;
}
} else {
PyErr_SetString(PyExc_ImportError,
"could not import gtk");
return ;
}
#line 256 "extensions.c"
pygobject_register_class(d, "SugarKeyGrabber", SUGAR_TYPE_KEY_GRABBER, &PySugarKeyGrabber_Type, Py_BuildValue("(O)", &PyGObject_Type));
pyg_set_object_has_new_constructor(SUGAR_TYPE_KEY_GRABBER);
pygobject_register_class(d, "SugarAudioManager", SUGAR_TYPE_AUDIO_MANAGER, &PySugarAudioManager_Type, Py_BuildValue("(O)", &PyGObject_Type));
pyg_set_object_has_new_constructor(SUGAR_TYPE_AUDIO_MANAGER);
}

View File

@ -0,0 +1,60 @@
;; -*- scheme -*-
; object definitions ...
(define-object KeyGrabber
(in-module "Sugar")
(parent "GObject")
(c-name "SugarKeyGrabber")
(gtype-id "SUGAR_TYPE_KEY_GRABBER")
)
(define-object AudioManager
(in-module "Sugar")
(parent "GObject")
(c-name "SugarAudioManager")
(gtype-id "SUGAR_TYPE_AUDIO_MANAGER")
)
;; Enumerations and flags ...
;; From sugar-key-grabber.h
(define-function sugar_key_grabber_get_type
(c-name "sugar_key_grabber_get_type")
(return-type "GType")
)
(define-method grab
(of-object "SugarKeyGrabber")
(c-name "sugar_key_grabber_grab")
(return-type "none")
(parameters
'("const-char*" "key")
)
)
(define-method get_key
(of-object "SugarKeyGrabber")
(c-name "sugar_key_grabber_get_key")
(return-type "char*")
(parameters
'("guint" "keycode")
'("guint" "state")
)
)
;; From sugar-audio-manager.h
(define-function audio_manager_get_type
(c-name "sugar_audio_manager_get_type")
(return-type "GType")
)
(define-method set_volume
(of-object "SugarAudioManager")
(c-name "sugar_audio_manager_set_volume")
(return-type "none")
(parameters
'("int" "level")
)
)

View File

@ -0,0 +1,19 @@
/* -*- Mode: C; c-basic-offset: 4 -*- */
%%
headers
#include <Python.h>
#include "pygobject.h"
#include "sugar-key-grabber.h"
#include "sugar-address-entry.h"
#include "sugar-audio-manager.h"
%%
modulename extensions
%%
import gobject.GObject as PyGObject_Type
import gtk.Entry as PyGtkEntry_Type
%%
ignore-glob
*_get_type
_*

View File

@ -0,0 +1,27 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
/* include this first, before NO_IMPORT_PYGOBJECT is defined */
#include <pygobject.h>
void pyextensions_register_classes (PyObject *d);
extern PyMethodDef pyextensions_functions[];
DL_EXPORT(void)
initextensions(void)
{
PyObject *m, *d;
init_pygobject ();
m = Py_InitModule ("extensions", pyextensions_functions);
d = PyModule_GetDict (m);
pyextensions_register_classes (d);
if (PyErr_Occurred ()) {
Py_FatalError ("can't initialise module _sugar");
}
}

View File

@ -0,0 +1 @@
timestamp

View File

@ -0,0 +1 @@
timestamp

View File

@ -0,0 +1,661 @@
/*
* Copyright (C) 2006, 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, 0.0, 0.0, 0.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
update_entry_text(SugarAddressEntry *address_entry,
gboolean has_focus)
{
if (has_focus) {
gtk_entry_set_text(GTK_ENTRY(address_entry),
address_entry->address);
} else {
gtk_entry_set_text(GTK_ENTRY(address_entry),
address_entry->title);
}
}
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
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, "button-press-event",
G_CALLBACK(button_press_event_cb), NULL);
}

View File

@ -0,0 +1,55 @@
/*
* Copyright (C) 2006, 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 <glib-object.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__ */

View File

@ -23,7 +23,7 @@
#include "sugar-key-grabber.h" #include "sugar-key-grabber.h"
#include "eggaccelerators.h" #include "eggaccelerators.h"
#include "sugar-marshal.h" #include "sugar-shell-marshal.h"
/* we exclude shift, GDK_CONTROL_MASK and GDK_MOD1_MASK since we know what /* we exclude shift, GDK_CONTROL_MASK and GDK_MOD1_MASK since we know what
these modifiers mean these modifiers mean
@ -82,7 +82,7 @@ sugar_key_grabber_class_init(SugarKeyGrabberClass *grabber_class)
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (SugarKeyGrabberClass, key_pressed), G_STRUCT_OFFSET (SugarKeyGrabberClass, key_pressed),
NULL, NULL, NULL, NULL,
sugar_marshal_BOOLEAN__UINT_UINT, sugar_shell_marshal_BOOLEAN__UINT_UINT,
G_TYPE_BOOLEAN, 2, G_TYPE_BOOLEAN, 2,
G_TYPE_UINT, G_TYPE_UINT,
G_TYPE_UINT); G_TYPE_UINT);
@ -91,7 +91,7 @@ sugar_key_grabber_class_init(SugarKeyGrabberClass *grabber_class)
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (SugarKeyGrabberClass, key_released), G_STRUCT_OFFSET (SugarKeyGrabberClass, key_released),
NULL, NULL, NULL, NULL,
sugar_marshal_BOOLEAN__UINT_UINT, sugar_shell_marshal_BOOLEAN__UINT_UINT,
G_TYPE_BOOLEAN, 2, G_TYPE_BOOLEAN, 2,
G_TYPE_UINT, G_TYPE_UINT,
G_TYPE_UINT); G_TYPE_UINT);

View File

@ -20,6 +20,7 @@
#define __SUGAR_KEY_GRABBER_H__ #define __SUGAR_KEY_GRABBER_H__
#include <glib-object.h> #include <glib-object.h>
#include <gdk/gdkwindow.h>
G_BEGIN_DECLS G_BEGIN_DECLS

View File

@ -0,0 +1,104 @@
#ifndef __sugar_shell_marshal_MARSHAL_H__
#define __sugar_shell_marshal_MARSHAL_H__
#include <glib-object.h>
G_BEGIN_DECLS
#ifdef G_ENABLE_DEBUG
#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
#define g_marshal_value_peek_char(v) g_value_get_char (v)
#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v)
#define g_marshal_value_peek_int(v) g_value_get_int (v)
#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
#define g_marshal_value_peek_long(v) g_value_get_long (v)
#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v)
#define g_marshal_value_peek_int64(v) g_value_get_int64 (v)
#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v)
#define g_marshal_value_peek_enum(v) g_value_get_enum (v)
#define g_marshal_value_peek_flags(v) g_value_get_flags (v)
#define g_marshal_value_peek_float(v) g_value_get_float (v)
#define g_marshal_value_peek_double(v) g_value_get_double (v)
#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
#define g_marshal_value_peek_param(v) g_value_get_param (v)
#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
#define g_marshal_value_peek_object(v) g_value_get_object (v)
#else /* !G_ENABLE_DEBUG */
/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
* Do not access GValues directly in your code. Instead, use the
* g_value_get_*() functions
*/
#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int
#define g_marshal_value_peek_char(v) (v)->data[0].v_int
#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint
#define g_marshal_value_peek_int(v) (v)->data[0].v_int
#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint
#define g_marshal_value_peek_long(v) (v)->data[0].v_long
#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong
#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64
#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64
#define g_marshal_value_peek_enum(v) (v)->data[0].v_long
#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong
#define g_marshal_value_peek_float(v) (v)->data[0].v_float
#define g_marshal_value_peek_double(v) (v)->data[0].v_double
#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer
#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer
#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
#endif /* !G_ENABLE_DEBUG */
/* BOOLEAN:UINT,UINT (./sugar-shell-marshal.list:1) */
extern void sugar_shell_marshal_BOOLEAN__UINT_UINT (GClosure *closure,
GValue *return_value,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data);
void
sugar_shell_marshal_BOOLEAN__UINT_UINT (GClosure *closure,
GValue *return_value,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data)
{
typedef gboolean (*GMarshalFunc_BOOLEAN__UINT_UINT) (gpointer data1,
guint arg_1,
guint arg_2,
gpointer data2);
register GMarshalFunc_BOOLEAN__UINT_UINT callback;
register GCClosure *cc = (GCClosure*) closure;
register gpointer data1, data2;
gboolean v_return;
g_return_if_fail (return_value != NULL);
g_return_if_fail (n_param_values == 3);
if (G_CCLOSURE_SWAP_DATA (closure))
{
data1 = closure->data;
data2 = g_value_peek_pointer (param_values + 0);
}
else
{
data1 = g_value_peek_pointer (param_values + 0);
data2 = closure->data;
}
callback = (GMarshalFunc_BOOLEAN__UINT_UINT) (marshal_data ? marshal_data : cc->callback);
v_return = callback (data1,
g_marshal_value_peek_uint (param_values + 1),
g_marshal_value_peek_uint (param_values + 2),
data2);
g_value_set_boolean (return_value, v_return);
}
G_END_DECLS
#endif /* __sugar_shell_marshal_MARSHAL_H__ */

View File

@ -0,0 +1,20 @@
#ifndef __sugar_shell_marshal_MARSHAL_H__
#define __sugar_shell_marshal_MARSHAL_H__
#include <glib-object.h>
G_BEGIN_DECLS
/* BOOLEAN:UINT,UINT (./sugar-shell-marshal.list:1) */
extern void sugar_shell_marshal_BOOLEAN__UINT_UINT (GClosure *closure,
GValue *return_value,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data);
G_END_DECLS
#endif /* __sugar_shell_marshal_MARSHAL_H__ */

View File

@ -0,0 +1 @@
BOOLEAN:UINT,UINT

View File

@ -0,0 +1,57 @@
#ifndef __sugar_shell_marshal_MARSHAL_H__
#define __sugar_shell_marshal_MARSHAL_H__
#include <glib-object.h>
G_BEGIN_DECLS
#ifdef G_ENABLE_DEBUG
#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
#define g_marshal_value_peek_char(v) g_value_get_char (v)
#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v)
#define g_marshal_value_peek_int(v) g_value_get_int (v)
#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
#define g_marshal_value_peek_long(v) g_value_get_long (v)
#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v)
#define g_marshal_value_peek_int64(v) g_value_get_int64 (v)
#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v)
#define g_marshal_value_peek_enum(v) g_value_get_enum (v)
#define g_marshal_value_peek_flags(v) g_value_get_flags (v)
#define g_marshal_value_peek_float(v) g_value_get_float (v)
#define g_marshal_value_peek_double(v) g_value_get_double (v)
#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
#define g_marshal_value_peek_param(v) g_value_get_param (v)
#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
#define g_marshal_value_peek_object(v) g_value_get_object (v)
#else /* !G_ENABLE_DEBUG */
/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
* Do not access GValues directly in your code. Instead, use the
* g_value_get_*() functions
*/
#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int
#define g_marshal_value_peek_char(v) (v)->data[0].v_int
#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint
#define g_marshal_value_peek_int(v) (v)->data[0].v_int
#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint
#define g_marshal_value_peek_long(v) (v)->data[0].v_long
#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong
#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64
#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64
#define g_marshal_value_peek_enum(v) (v)->data[0].v_long
#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong
#define g_marshal_value_peek_float(v) (v)->data[0].v_float
#define g_marshal_value_peek_double(v) (v)->data[0].v_double
#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer
#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer
#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
#endif /* !G_ENABLE_DEBUG */
G_END_DECLS
#endif /* __sugar_shell_marshal_MARSHAL_H__ */

View File

@ -19,7 +19,7 @@ import logging
import dbus import dbus
from hardware.nmclient import NMClient from hardware.nmclient import NMClient
from _sugar import AudioManager from extensions import AudioManager
_HARDWARE_MANAGER_INTERFACE = 'org.laptop.HardwareManager' _HARDWARE_MANAGER_INTERFACE = 'org.laptop.HardwareManager'
_HARDWARE_MANAGER_SERVICE = 'org.laptop.HardwareManager' _HARDWARE_MANAGER_SERVICE = 'org.laptop.HardwareManager'

View File

@ -9,7 +9,7 @@ import gtk
from sugar import env from sugar import env
from hardware import hardwaremanager from hardware import hardwaremanager
from model.ShellModel import ShellModel from model.ShellModel import ShellModel
from _sugar import KeyGrabber from extensions import KeyGrabber
import sugar import sugar
_actions_table = { _actions_table = {