Merge branch 'master' of git+ssh://dev.laptop.org/git/sugar-toolkit
This commit is contained in:
commit
dcd212f168
@ -121,6 +121,16 @@
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
(define-method is_modifier
|
||||||
|
(of-object "SugarKeyGrabber")
|
||||||
|
(c-name "sugar_key_grabber_is_modifier")
|
||||||
|
(return-type "gboolean")
|
||||||
|
(parameters
|
||||||
|
'("guint" "keycode")
|
||||||
|
'("guint" "mask" (default "-1"))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
;; From sexy-icon-entry.h
|
;; From sexy-icon-entry.h
|
||||||
|
|
||||||
(define-function sexy_icon_entry_get_type
|
(define-function sexy_icon_entry_get_type
|
||||||
|
@ -67,6 +67,25 @@ class _TrayViewport(gtk.Viewport):
|
|||||||
elif direction == _NEXT_PAGE:
|
elif direction == _NEXT_PAGE:
|
||||||
self._scroll_next()
|
self._scroll_next()
|
||||||
|
|
||||||
|
def scroll_to_item(self, item):
|
||||||
|
"""This function scrolls the viewport so that item will be visible."""
|
||||||
|
assert item in self.traybar.get_children()
|
||||||
|
|
||||||
|
# Get the allocation, and make sure that it is visible
|
||||||
|
if self.orientation == gtk.ORIENTATION_HORIZONTAL:
|
||||||
|
adj = self.get_hadjustment()
|
||||||
|
start = item.allocation.x
|
||||||
|
stop = item.allocation.x + item.allocation.width
|
||||||
|
else:
|
||||||
|
adj = self.get_vadjustment()
|
||||||
|
start = item.allocation.y
|
||||||
|
stop = item.allocation.y + item.allocation.height
|
||||||
|
|
||||||
|
if start < adj.value:
|
||||||
|
adj.value = start
|
||||||
|
elif stop > adj.value + adj.page_size:
|
||||||
|
adj.value = stop - adj.page_size
|
||||||
|
|
||||||
def _scroll_next(self):
|
def _scroll_next(self):
|
||||||
allocation = self.get_allocation()
|
allocation = self.get_allocation()
|
||||||
if self.orientation == gtk.ORIENTATION_HORIZONTAL:
|
if self.orientation == gtk.ORIENTATION_HORIZONTAL:
|
||||||
@ -218,6 +237,9 @@ class HTray(gtk.HBox):
|
|||||||
def get_item_index(self, item):
|
def get_item_index(self, item):
|
||||||
return self._viewport.traybar.get_item_index(item)
|
return self._viewport.traybar.get_item_index(item)
|
||||||
|
|
||||||
|
def scroll_to_item(self, item):
|
||||||
|
self._viewport.scroll_to_item(item)
|
||||||
|
|
||||||
class VTray(gtk.VBox):
|
class VTray(gtk.VBox):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
gobject.GObject.__init__(self, **kwargs)
|
gobject.GObject.__init__(self, **kwargs)
|
||||||
@ -249,6 +271,9 @@ class VTray(gtk.VBox):
|
|||||||
def get_item_index(self, item):
|
def get_item_index(self, item):
|
||||||
return self._viewport.traybar.get_item_index(item)
|
return self._viewport.traybar.get_item_index(item)
|
||||||
|
|
||||||
|
def scroll_to_item(self, item):
|
||||||
|
self._viewport.scroll_to_item(item)
|
||||||
|
|
||||||
class TrayButton(ToolButton):
|
class TrayButton(ToolButton):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
ToolButton.__init__(self, **kwargs)
|
ToolButton.__init__(self, **kwargs)
|
||||||
|
@ -217,3 +217,42 @@ sugar_key_grabber_grab(SugarKeyGrabber *grabber, const char *key)
|
|||||||
|
|
||||||
grabber->keys = g_list_append(grabber->keys, keyinfo);
|
grabber->keys = g_list_append(grabber->keys, keyinfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
sugar_key_grabber_is_modifier(SugarKeyGrabber *grabber, guint keycode, guint mask)
|
||||||
|
{
|
||||||
|
Display *xdisplay;
|
||||||
|
XModifierKeymap *modmap;
|
||||||
|
gint start, end, i, mod_index;
|
||||||
|
gboolean is_modifier = FALSE;
|
||||||
|
|
||||||
|
xdisplay = gdk_x11_drawable_get_xdisplay(GDK_DRAWABLE (grabber->root));
|
||||||
|
|
||||||
|
modmap = XGetModifierMapping(xdisplay);
|
||||||
|
|
||||||
|
if (mask != -1) {
|
||||||
|
mod_index = 0;
|
||||||
|
mask = mask >> 1;
|
||||||
|
while (mask != 0) {
|
||||||
|
mask = mask >> 1;
|
||||||
|
mod_index += 1;
|
||||||
|
}
|
||||||
|
start = mod_index * modmap->max_keypermod;
|
||||||
|
end = (mod_index + 1) * modmap->max_keypermod;
|
||||||
|
} else {
|
||||||
|
start = 0;
|
||||||
|
end = 8 * modmap->max_keypermod;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = start; i < end; i++) {
|
||||||
|
if (keycode == modmap->modifiermap[i]) {
|
||||||
|
is_modifier = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
XFreeModifiermap (modmap);
|
||||||
|
|
||||||
|
return is_modifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -60,6 +60,9 @@ void sugar_key_grabber_grab (SugarKeyGrabber *grabber,
|
|||||||
char *sugar_key_grabber_get_key (SugarKeyGrabber *grabber,
|
char *sugar_key_grabber_get_key (SugarKeyGrabber *grabber,
|
||||||
guint keycode,
|
guint keycode,
|
||||||
guint state);
|
guint state);
|
||||||
|
gboolean sugar_key_grabber_is_modifier (SugarKeyGrabber *grabber,
|
||||||
|
guint keycode,
|
||||||
|
guint mask);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user