[maemo-commits] [maemo-commits] r8823 - in projects/haf/branches/maemo-af-desktop/hildon-desktop: . libhildondesktop libhildonwm
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Tue Dec 19 17:25:58 EET 2006
- Previous message: [maemo-commits] r8822 - in projects/haf/branches/maemo-af-desktop/hildon-desktop: . libhildondesktop src
- Next message: [maemo-commits] r8824 - in projects/haf/branches/maemo-af-desktop/hildon-desktop: . src
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: moimart Date: 2006-12-19 17:25:57 +0200 (Tue, 19 Dec 2006) New Revision: 8823 Modified: projects/haf/branches/maemo-af-desktop/hildon-desktop/ChangeLog projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/hn-app-button.c projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/hn-app-button.h projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/hn-app-switcher.c projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildonwm/hd-keys.c projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildonwm/hd-keys.h Log: * libhildondesktop/hn-app-switcher.c: * libhildondesktop/hn-app-button.[ch]: * libhildonwm/hd-keys.[ch]: - Fixes backported from old code: NB#42971,NB#43855,NB#38950,NB#47370. * ChangeLog updated. Modified: projects/haf/branches/maemo-af-desktop/hildon-desktop/ChangeLog =================================================================== --- projects/haf/branches/maemo-af-desktop/hildon-desktop/ChangeLog 2006-12-19 15:11:19 UTC (rev 8822) +++ projects/haf/branches/maemo-af-desktop/hildon-desktop/ChangeLog 2006-12-19 15:25:57 UTC (rev 8823) @@ -1,3 +1,10 @@ +2006-12-19 Moises Martinez <moises.martinez at nokia.com> + + * libhildondesktop/hn-app-switcher.c: + * libhildondesktop/hn-app-button.[ch]: + * libhildonwm/hd-keys.[ch]: + - Fixes backported from old code: NB#42971,NB#43855,NB#38950,NB#47370. + 2006-12-19 Lucas Rocha <lucas.rocha at nokia.com> * src/hd-plugin-loader-factory.c: fix internal registry to really Modified: projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/hn-app-button.c =================================================================== --- projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/hn-app-button.c 2006-12-19 15:11:19 UTC (rev 8822) +++ projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/hn-app-button.c 2006-12-19 15:25:57 UTC (rev 8823) @@ -162,6 +162,70 @@ } #endif +static GdkPixbuf * +hn_app_button_class_get_bkilled_emblem (HNAppButtonClass *button_class) +{ + GError *error = NULL; + + if (button_class->bkilled_emblem) + return g_object_ref (button_class->bkilled_emblem); + + button_class->bkilled_emblem = + gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), + "qgn_indi_bkilled", + APP_GROUP_ICON_SIZE, + 0, + &error); + + if (error) + { + g_warning ("Could not load icon qgn_indi_bkilled: %s", error->message); + g_error_free (error); + } + + if (button_class->bkilled_emblem) + return g_object_ref (button_class->bkilled_emblem); + + return NULL; +} + +static GdkPixbuf * +hn_app_button_class_get_groupped_emblem (HNAppButtonClass *button_class, + guint n_instances) +{ + if (n_instances > app_group_n_icons) + n_instances = app_group_n_icons; + + if (button_class->groupped_emblems[n_instances - 1]) + return g_object_ref (button_class->groupped_emblems[n_instances - 1]); + else + if (app_group_icons[n_instances - 1]) + { + GError *error = NULL; + GtkIconTheme *icon_theme = gtk_icon_theme_get_default (); + + button_class->groupped_emblems[n_instances - 1] = + gtk_icon_theme_load_icon (icon_theme, + app_group_icons[n_instances - 1], + APP_GROUP_ICON_SIZE, + 0, + &error); + + if (error) + { + g_warning ("Could not load icon %s: %s",app_group_icons[n_instances - 1],error->message); + g_error_free (error); + button_class->groupped_emblems[n_instances] = NULL; + return NULL; + } + + if (button_class->groupped_emblems[n_instances - 1]) + return g_object_ref (button_class->groupped_emblems[n_instances - 1]); + } + + return NULL; +} + static void hn_app_button_icon_animation (GtkWidget *icon, gboolean turn_on); @@ -911,6 +975,9 @@ G_PARAM_READWRITE)); g_type_class_add_private (gobject_class, sizeof (HNAppButtonPrivate)); + + klass->groupped_emblems = g_new0 (GdkPixbuf *, app_group_n_icons); + klass->bkilled_emblem = NULL; } static void @@ -1068,11 +1135,11 @@ } static GdkPixbuf * -compose_app_pixbuf (const GdkPixbuf *src, - HDEntryInfo *info) +hn_app_button_compose_app_pixbuf (HNAppButton *button, + const GdkPixbuf *src, + HDEntryInfo *info) { - GdkPixbuf *retval, *inst_pixbuf; - const gchar *inst_name; + GdkPixbuf *retval, *inst_pixbuf = NULL; GError *error; gint dest_width, dest_height; gint off_x, off_y; @@ -1084,54 +1151,45 @@ /* first of all, see if this app is hibernated */ if (hd_entry_info_is_hibernating (info)) + inst_pixbuf = + hn_app_button_class_get_bkilled_emblem (HN_APP_BUTTON_GET_CLASS (button)); + else + if (hd_entry_info_has_extra_icon (info)) + { + const char *inst_name = hd_entry_info_get_extra_icon (info); + + if (inst_name) { - inst_name = "qgn_indi_bkilled"; + error = NULL; + + inst_pixbuf = + gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), + inst_name, + APP_GROUP_ICON_SIZE, + 0, + &error); + if (error) + { + g_warning ("unable to find icon '%s' " + "in current theme: %s", + inst_name, + error->message); + g_error_free (error); + return NULL; + } } - else if (hd_entry_info_has_extra_icon (info)) - { - inst_name = hd_entry_info_get_extra_icon (info); - } + } else - { - gint n_instances = hd_entry_info_get_n_children (info); - - if (!n_instances) - { - g_warning ("top-level item '%s' has no instances", - hd_entry_info_peek_title (info)); - return NULL; - } + { + guint n_instances = hd_entry_info_get_n_children (info); - if (n_instances == 1) - return NULL; + inst_pixbuf = + hn_app_button_class_get_groupped_emblem (HN_APP_BUTTON_GET_CLASS (button), n_instances); + } - if (G_LIKELY (n_instances <= app_group_n_icons - 1)) - inst_name = app_group_icons[n_instances - 1]; - else - inst_name = APP_GROUP_ICON_MORE; - } - - HN_DBG ("Compositing icon for '%s' with icon name '%s'", - hd_entry_info_peek_title (info), - inst_name); + if (!inst_pixbuf) + return NULL; - error = NULL; - inst_pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), - inst_name, - APP_GROUP_ICON_SIZE, - 0, - &error); - if (error) - { - g_warning ("unable to find icon '%s' in current theme: %s", - inst_name, - error->message); - - g_error_free (error); - - return NULL; - } - /* make a copy of the source pixbuf, and also make * sure that it has an alpha channel */ @@ -1178,7 +1236,7 @@ /* compose the application icon with the number of * instances running */ - pixbuf = compose_app_pixbuf (app_pixbuf, info); + pixbuf = hn_app_button_compose_app_pixbuf (button, app_pixbuf, info); if (pixbuf) { gtk_image_set_from_pixbuf (GTK_IMAGE (button->priv->icon), @@ -1246,7 +1304,7 @@ /* compose the application icon with the number of * instances running */ - pixbuf = compose_app_pixbuf (app_pixbuf, info); + pixbuf = hn_app_button_compose_app_pixbuf (button, app_pixbuf, info); if (pixbuf) { gtk_image_set_from_pixbuf (GTK_IMAGE (button->priv->icon), Modified: projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/hn-app-button.h =================================================================== --- projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/hn-app-button.h 2006-12-19 15:11:19 UTC (rev 8822) +++ projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/hn-app-button.h 2006-12-19 15:25:57 UTC (rev 8823) @@ -65,6 +65,9 @@ struct _HNAppButtonClass { GtkToggleButtonClass parent_class; + + GdkPixbuf **groupped_emblems; + GdkPixbuf *bkilled_emblem; }; GType hn_app_button_get_type (void) G_GNUC_CONST; Modified: projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/hn-app-switcher.c =================================================================== --- projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/hn-app-switcher.c 2006-12-19 15:11:19 UTC (rev 8822) +++ projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/hn-app-switcher.c 2006-12-19 15:25:57 UTC (rev 8823) @@ -23,6 +23,10 @@ * */ +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + /* Hildon includes */ #include "hn-app-switcher.h" #include "hn-app-button.h" @@ -59,6 +63,10 @@ #include <libosso.h> +#ifndef HILDON_LIBS +#include <hildon-widgets/hildon-finger.h> +#endif + #include <hildon-widgets/gtk-infoprint.h> #include "hildon-pixbuf-anim-blinker.h" @@ -196,7 +204,6 @@ * HNAppSwitcher */ - enum { ADD_INFO, @@ -808,8 +815,11 @@ g_debug("Main menu button pressed using button %d", event->button); /* hd_wm_activate (HN_TN_DEACTIVATE_KEY_FOCUS);*/ - +#ifndef HILDON_LIBS if (event->button == APP_BUTTON_THUMBABLE || event->button == 2) +#else + if (hildon_button_event_is_finger (event)) +#endif priv->is_thumbable = TRUE; else if (!priv->menu_button_timeout) Modified: projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildonwm/hd-keys.c =================================================================== --- projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildonwm/hd-keys.c 2006-12-19 15:11:19 UTC (rev 8822) +++ projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildonwm/hd-keys.c 2006-12-19 15:25:57 UTC (rev 8823) @@ -481,7 +481,10 @@ shortcut->mod_mask = mask; shortcut->keysym = ks; - shortcut->keycode = XKeysymToKeycode(GDK_DISPLAY(), ks); + gdk_keymap_get_entries_for_keyval (NULL /* default keymap */, + ks, + &shortcut->keycodes, + &shortcut->n_keycodes); shortcut->index = index; g_debug("'%s' to new shortcut with ks:%li, mask:%i", keystr, ks, mask); @@ -489,67 +492,82 @@ return shortcut; } +static void +hd_keys_shortcut_free (HDKeyShortcut *shortcut) +{ + g_free (shortcut->keycodes); + g_free (shortcut); +} static gboolean -hn_key_shortcut_grab (HDKeysConfig *keys, +hd_key_shortcut_grab (HDKeysConfig *keys, HDKeyShortcut *shortcut, gboolean ungrab) { gint ignored_mask = 0; + gint i_keycode; + if (!shortcut->keycodes) + return FALSE; + /* Needed to grab all ignored combo's too if num of scroll lock are on */ - while (ignored_mask < (int) keys->lock_mask) - { - if (ignored_mask & ~(keys->lock_mask)) - { - ++ignored_mask; - continue; - } + for (i_keycode = 0; i_keycode < shortcut->n_keycodes; i_keycode++) + { + while (ignored_mask < (int) keys->lock_mask) + { + if (ignored_mask & ~(keys->lock_mask)) + { + ++ignored_mask; + continue; + } - if (ungrab) - { - XUngrabKey (GDK_DISPLAY(), - shortcut->keycode, - shortcut->mod_mask | ignored_mask, - GDK_ROOT_WINDOW()); - } - else - { - gint result; + + if (ungrab) + { + XUngrabKey (GDK_DISPLAY(), + shortcut->keycodes[i_keycode].keycode, + shortcut->mod_mask | ignored_mask, + GDK_ROOT_WINDOW()); + } + else + { + gint result; - gdk_error_trap_push(); + gdk_error_trap_push(); - XGrabKey (GDK_DISPLAY(), - shortcut->keycode, - shortcut->mod_mask | ignored_mask, - GDK_ROOT_WINDOW(), - False, - GrabModeAsync, - GrabModeAsync); + XGrabKey (GDK_DISPLAY(), + shortcut->keycodes[i_keycode].keycode, + shortcut->mod_mask | ignored_mask, + GDK_ROOT_WINDOW(), + False, + GrabModeAsync, + GrabModeAsync); - XSync(GDK_DISPLAY(), False); + XSync(GDK_DISPLAY(), False); - result = gdk_error_trap_pop(); + result = gdk_error_trap_pop(); - if (result) - { - /* FIXME: Log below somewhere */ - if (result == BadAccess) - { - g_debug ("Some other program is already using the key %s " - "with modifiers %x as a binding\n", - (XKeysymToString (shortcut->keysym)) ? XKeysymToString (shortcut->keysym) : "unknown", - shortcut->mod_mask | ignored_mask ); - } - else - { - g_debug ("Unable to grab the key %s with modifiers %x as a binding\n", - (XKeysymToString (shortcut->keysym)) ? XKeysymToString (shortcut->keysym) : "unknown", - shortcut->mod_mask | ignored_mask); + if (result) + { + /* FIXME: Log below somewhere */ + if (result == BadAccess) + { + g_debug ("Some other program is already using the key %s " + "with modifiers %x as a binding\n", + (XKeysymToString (shortcut->keysym)) ? XKeysymToString (shortcut->keysym) : "unknown", + shortcut->mod_mask | ignored_mask ); + } + else + { + g_debug ("Unable to grab the key %s with modifiers %x as a binding\n", + (XKeysymToString (shortcut->keysym)) ? XKeysymToString (shortcut->keysym) : "unknown", + shortcut->mod_mask | ignored_mask); + } } - } - } - ++ignored_mask; + } + ++ignored_mask; + } + ignored_mask = 0; } return TRUE; @@ -575,7 +593,7 @@ if ((shortcut = hd_keys_shortcut_new (keys, key_def_str, i)) != NULL) { g_debug ("Grabbing '%s'", key_def_str); - hn_key_shortcut_grab (keys, shortcut, FALSE); + hd_key_shortcut_grab (keys, shortcut, FALSE); keys->shortcuts = g_slist_append (keys->shortcuts, shortcut); } } @@ -630,9 +648,9 @@ if (sc->action == HDKeysActionConfLookup[i].action) { g_debug ("removing exisiting action %i", sc->action); - hn_key_shortcut_grab (keys, sc, TRUE); + hd_key_shortcut_grab (keys, sc, TRUE); keys->shortcuts = g_slist_remove (keys->shortcuts, item->data); - g_free (sc); + hd_keys_shortcut_free (sc); break; } item = g_slist_next(item); @@ -651,7 +669,7 @@ if ((shortcut = hd_keys_shortcut_new (keys, value, i)) != NULL) { g_debug ("now grabbing '%s'", value); - hn_key_shortcut_grab (keys, shortcut, FALSE); + hd_key_shortcut_grab (keys, shortcut, FALSE); keys->shortcuts = g_slist_append (keys->shortcuts, shortcut); } } @@ -680,9 +698,9 @@ while (shortcut != NULL) { gpointer data = shortcut->data; - hn_key_shortcut_grab (keys, shortcut->data, TRUE); + hd_key_shortcut_grab (keys, shortcut->data, TRUE); shortcut = g_slist_remove (shortcut, shortcut->data); - g_free (data); + hd_keys_shortcut_free (data); } keys->shortcuts = NULL; Modified: projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildonwm/hd-keys.h =================================================================== --- projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildonwm/hd-keys.h 2006-12-19 15:11:19 UTC (rev 8822) +++ projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildonwm/hd-keys.h 2006-12-19 15:25:57 UTC (rev 8823) @@ -81,7 +81,8 @@ { HDKeyAction action; KeySym keysym; - KeyCode keycode; + GdkKeymapKey *keycodes; + gint n_keycodes; gint mod_mask; gint index; HDKeysActionFunc action_func;
- Previous message: [maemo-commits] r8822 - in projects/haf/branches/maemo-af-desktop/hildon-desktop: . libhildondesktop src
- Next message: [maemo-commits] r8824 - in projects/haf/branches/maemo-af-desktop/hildon-desktop: . src
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]