[maemo-commits] [maemo-commits] r8793 - in projects/haf/branches/maemo-af-desktop/hildon-desktop: . libhildondesktop test
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Fri Dec 15 19:09:53 EET 2006
- Previous message: [maemo-commits] r8792 - in projects/haf/branches/gtk+/maemo-gtk-2-10: . gdk gdk/x11
- Next message: [maemo-commits] r8794 - in projects/haf/branches/maemo-af-desktop/hildon-desktop: . libhildondesktop
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: moimart Date: 2006-12-15 19:09:52 +0200 (Fri, 15 Dec 2006) New Revision: 8793 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-switcher.c projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/hn-app-switcher.h projects/haf/branches/maemo-af-desktop/hildon-desktop/test/test4.c Log: * test/test4.c: test updated with refactored appswitcher. * libhildondesktop/hn-app-switcher.[ch]: - Refactored appswitcher to allow different sizes. * libhildondesktop/hn-app-button.c: Commented out code not implemented yet. * ChangeLog updated. Modified: projects/haf/branches/maemo-af-desktop/hildon-desktop/ChangeLog =================================================================== --- projects/haf/branches/maemo-af-desktop/hildon-desktop/ChangeLog 2006-12-15 16:27:48 UTC (rev 8792) +++ projects/haf/branches/maemo-af-desktop/hildon-desktop/ChangeLog 2006-12-15 17:09:52 UTC (rev 8793) @@ -1,3 +1,11 @@ +2006-12-15 Moises Martinez <moises.martinzes at nokia.com> + + * test/test4.c: test updated with refactored appswitcher. + * libhildondesktop/hn-app-switcher.[ch]: + - Refactored appswitcher to allow different sizes. + * libhildondesktop/hn-app-button.c: Commented out code not implemented + yet. + 2006-12-15 Lucas Rocha <lucas.rocha at nokia.com> * libhildondesktop/hildon-desktop-plugin.[ch]: new macro which correctly 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-15 16:27:48 UTC (rev 8792) +++ projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/hn-app-button.c 2006-12-15 17:09:52 UTC (rev 8793) @@ -1177,12 +1177,14 @@ else HN_DBG ("Unable to find the icon (even the default one)"); +/*FIXME: FIXME: FIXME: This is broken because app switcher is not singleton anymore */ +#if 0 /* the newly composed image is static */ if(button->priv->is_blinking && !hn_app_switcher_get_system_inactivity(HN_APP_SWITCHER (hn_app_switcher_new ()))) hn_app_button_icon_animation (button->priv->icon, button->priv->is_blinking); - +#endif gtk_widget_show (button->priv->icon); gtk_widget_set_sensitive (GTK_WIDGET (button), TRUE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), @@ -1243,12 +1245,14 @@ else HN_DBG ("Unable to find the icon (even the default one)"); +/*FIXME: FIXME: FIXME: This is broken because app switcher is not singleton anymore */ +#if 0 /* the newly composed image is static */ if(button->priv->is_blinking && !hn_app_switcher_get_system_inactivity(HN_APP_SWITCHER (hn_app_switcher_new()))) hn_app_button_icon_animation (button->priv->icon, button->priv->is_blinking); - +#endif gtk_widget_show (button->priv->icon); gtk_widget_set_sensitive (GTK_WIDGET (button), TRUE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), 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-15 16:27:48 UTC (rev 8792) +++ projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/hn-app-switcher.c 2006-12-15 17:09:52 UTC (rev 8793) @@ -92,24 +92,9 @@ #define ANIM_DURATION 5000 /* 5 Secs for blinking icons */ #define ANIM_FPS 2 -/* Themed widget names */ -static const gchar *as_button_names[] = { - "hildon-navigator-small-button1", - "hildon-navigator-small-button2", - "hildon-navigator-small-button3", - "hildon-navigator-small-button4", - - NULL, -}; +#define AS_BUTTON_NAME "hildon-navigator-small-button%d" +#define AS_BUTTON_NAME_PRESSED "hildon-navigator-small-button%d-pressed" -static const gchar *as_button_pressed_names[] = { - "hildon-navigator-small-button1-pressed", - "hildon-navigator-small-button2-pressed", - "hildon-navigator-small-button3-pressed", - "hildon-navigator-small-button4-pressed", - NULL, -}; - #define AS_MENU_BUTTON_NAME "hildon-navigator-small-button5" #define AS_UPPER_SEPARATOR "hildon-navigator-upper-separator" @@ -137,6 +122,11 @@ #define TOOLTIP_SHOW_TIMEOUT 500 #define TOOLTIP_HIDE_TIMEOUT 1500 +enum +{ + AS_PROP_NITEMS=1 +}; + static void hn_app_switcher_add_info_cb (HDWM *hdwm, HDEntryInfo *entry_info, gpointer data); @@ -152,6 +142,12 @@ static void hn_app_switcher_show_menu_cb (HDWM *hdwm, gpointer data); +static void +hn_app_switcher_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); + +static void +hn_app_switcher_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); + static void hn_app_image_animation (GtkWidget *icon, gboolean is_on) @@ -197,16 +193,7 @@ * HNAppSwitcher */ -enum -{ - AS_APP1_BUTTON, - AS_APP2_BUTTON, - AS_APP3_BUTTON, - AS_APP4_BUTTON, - N_BUTTONS -}; - enum { ADD_INFO, @@ -224,7 +211,9 @@ struct _HNAppSwitcherPrivate { - GtkWidget *buttons[N_BUTTONS]; + gint nitems; + + GtkWidget **buttons; GSList *buttons_group; GtkWidget *main_button; @@ -272,7 +261,7 @@ { gint pos; - g_return_val_if_fail (GTK_IS_TOGGLE_BUTTON (button), AS_APP1_BUTTON); + g_return_val_if_fail (GTK_IS_TOGGLE_BUTTON (button), 0); pos = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "app-button-pos")); @@ -281,10 +270,11 @@ static void set_app_button_pos (GtkWidget *button, - gint pos) + gint pos, + gint maxpos) { g_return_if_fail (GTK_IS_TOGGLE_BUTTON (button)); - g_return_if_fail (pos >= AS_APP1_BUTTON && pos < N_BUTTONS); + g_return_if_fail (pos >= 0 && pos < maxpos); g_object_set_data (G_OBJECT (button), "app-button-pos", @@ -653,7 +643,7 @@ */ for (k = priv->applications, i = 0; k != NULL; k = k->next, ++i) { - if (i < N_BUTTONS) + if (i < priv->nitems) continue; for (l = hd_entry_info_get_children (k->data); l != NULL; l = l->next) @@ -884,17 +874,27 @@ gint pos = get_app_button_pos (widget); gboolean is_active = gtk_toggle_button_get_active (toggle); gboolean is_inconsistent = gtk_toggle_button_get_inconsistent (toggle); + gchar *name,*name_pressed; + name = + g_strdup_printf (AS_BUTTON_NAME,pos+1); + + name_pressed = + g_strdup_printf (AS_BUTTON_NAME_PRESSED,pos+1); + if (is_inconsistent) - gtk_widget_set_name (widget, as_button_names[pos]); + gtk_widget_set_name (widget, name); else { if (is_active) - gtk_widget_set_name (widget, as_button_pressed_names[pos]); + gtk_widget_set_name (widget, name_pressed); else - gtk_widget_set_name (widget, as_button_names[pos]); + gtk_widget_set_name (widget, name); } + g_free (name); + g_free (name_pressed); + g_debug ("setting button (pos=%d) (inconsistent='<%s>', active='<%s>') name: %s", pos, is_inconsistent ? "true" : "false", @@ -916,24 +916,29 @@ { HNAppSwitcherPrivate *priv = app_switcher->priv; GtkWidget *retval; + gchar *name; g_assert (priv->buttons[pos] == NULL); - g_debug ("Creating app button at pos %d (name %s)", - pos, as_button_names[pos]); + name = + g_strdup_printf (AS_BUTTON_NAME,pos+1); + + g_debug ("Creating app button at pos %d (name %s)", pos, name); retval = hn_app_button_new (NULL); - set_app_button_pos (retval, pos); + set_app_button_pos (retval, pos, priv->nitems); hn_app_button_set_is_blinking (HN_APP_BUTTON (retval), FALSE); - gtk_widget_set_name (retval, as_button_names[pos]); + gtk_widget_set_name (retval, name); g_signal_connect (retval, "toggled", G_CALLBACK (app_button_toggled_cb), NULL); priv->buttons[pos] = retval; + + g_free (name); return priv->buttons[pos]; } @@ -942,9 +947,12 @@ hn_app_switcher_build (HNAppSwitcher *app_switcher) { GtkWidget *button; + gint i; g_assert (app_switcher); + app_switcher->priv->buttons = g_new0 (GtkWidget*,app_switcher->priv->nitems); + app_switcher->hdwm = hd_wm_get_singleton (); g_debug ("singleton wm: %p",app_switcher->hdwm); @@ -967,22 +975,14 @@ /* most recent applications buttons */ g_debug ("Adding buttons"); - button = create_app_button (app_switcher, AS_APP1_BUTTON); - gtk_box_pack_start (GTK_BOX (app_switcher->vbox), button, TRUE, TRUE, 0); - gtk_widget_show (button); - - button = create_app_button (app_switcher, AS_APP2_BUTTON); - gtk_box_pack_start (GTK_BOX (app_switcher->vbox), button, TRUE, TRUE, 0); - gtk_widget_show (button); - - button = create_app_button (app_switcher, AS_APP3_BUTTON); - gtk_box_pack_start (GTK_BOX (app_switcher->vbox), button, TRUE, TRUE, 0); - gtk_widget_show (button); - - button = create_app_button (app_switcher, AS_APP4_BUTTON); - gtk_box_pack_start (GTK_BOX (app_switcher->vbox), button, TRUE, TRUE, 0); - gtk_widget_show (button); - + + for (i=0;i < app_switcher->priv->nitems;i++) + { + button = create_app_button (app_switcher, i); + gtk_box_pack_start (GTK_BOX (app_switcher->vbox), button, TRUE, TRUE, 0); + gtk_widget_show (button); + } + /* menu button */ g_debug ("Adding menu button"); button = create_menu_button (app_switcher); @@ -1091,7 +1091,7 @@ gtk_widget_show (priv->main_button); /* show only the buttons linked to an application */ - for (i = AS_APP1_BUTTON; i < N_BUTTONS; i++) + for (i = 0; i < priv->nitems; i++) { GtkWidget *button = priv->buttons[i]; HDEntryInfo *info; @@ -1129,7 +1129,7 @@ HNAppSwitcherPrivate *priv = app_switcher->priv; gint pos; - for (pos = AS_APP1_BUTTON; pos < N_BUTTONS; pos++) + for (pos = 0; pos < priv->nitems; pos++) { GtkWidget *button = priv->buttons[pos]; HDEntryInfo *e; @@ -1223,7 +1223,7 @@ GtkWidget *app_image; /* first we reset all the buttons icons */ - for (pos = AS_APP1_BUTTON; pos < N_BUTTONS; pos++) + for (pos = 0; pos < priv->nitems; pos++) { HNAppButton *button = HN_APP_BUTTON (priv->buttons[pos]); @@ -1234,8 +1234,8 @@ priv->buttons_group = NULL; /* then refresh the icons of the application buttons */ - for (l = priv->applications, pos = AS_APP1_BUTTON; - l != NULL && pos < N_BUTTONS; + for (l = priv->applications, pos = 0; + l != NULL && pos < priv->nitems; l = l->next, pos++) { HDEntryInfo *entry = l->data; @@ -1286,7 +1286,7 @@ const GList *k; HDEntryInfo *child; - if (pos < N_BUTTONS) + if (pos < priv->nitems) continue; /* set the ignore flag on any children that were causing the blinking @@ -1582,8 +1582,8 @@ g_debug ("HDEntryInfo present and of type WATCHED_APP"); - for (l = priv->applications, pos = AS_APP1_BUTTON; - l != NULL && pos < N_BUTTONS; + for (l = priv->applications, pos = 0; + l != NULL && pos < priv->nitems; l = l->next, pos++) { HDEntryInfo *entry = l->data; @@ -1651,8 +1651,8 @@ /* the remaining cases are more complicated and require that we know * the state of the associated button */ - for (l = priv->applications, pos = AS_APP1_BUTTON; - l != NULL && pos < N_BUTTONS; + for (l = priv->applications, pos = 0; + l != NULL && pos < priv->nitems; l = l->next, pos++) { HDEntryInfo *entry = l->data; @@ -1795,8 +1795,8 @@ /* locate the associated button, and toggle it */ active_pos = 0; - for (l = priv->applications, pos = AS_APP1_BUTTON; - l != NULL && pos < N_BUTTONS; + for (l = priv->applications, pos = 0; + l != NULL && pos < priv->nitems; l = l->next, pos++) { HDEntryInfo *entry = l->data; @@ -1816,7 +1816,7 @@ */ if (!active_found) { - for (pos = AS_APP1_BUTTON; pos < N_BUTTONS; pos++) + for (pos = 0; pos < priv->nitems; pos++) { GtkToggleButton *app_button; @@ -1835,28 +1835,6 @@ } static void -hn_app_switcher_real_bgkill (HNAppSwitcher *app_switcher, - gboolean is_on) -{ - hn_app_switcher_changed_info_cb (app_switcher->hdwm, NULL, (gpointer)app_switcher); -} - -static void -hn_app_switcher_real_lowmem (HNAppSwitcher *app_switcher, - gboolean is_on) -{ - HNAppSwitcherPrivate *priv = app_switcher->priv; - priv->is_dimming_on = is_on; - - g_debug ("Received lowmem signal"); - - /* TODO - update the sensitivity of the items depending on the - * lowmem state - */ - hn_app_switcher_changed_info_cb (app_switcher->hdwm, NULL, (gpointer)app_switcher); -} - -static void hn_app_switcher_finalize (GObject *gobject) { HNAppSwitcher *app_switch = HN_APP_SWITCHER (gobject); @@ -1896,6 +1874,48 @@ return object; } +static void +hn_app_switcher_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + HNAppSwitcher *app_switcher; + + app_switcher = HN_APP_SWITCHER (object); + + switch (prop_id) + { + case AS_PROP_NITEMS: + app_switcher->priv->nitems = g_value_get_int (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +hn_app_switcher_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + HNAppSwitcher *app_switcher; + + app_switcher = HN_APP_SWITCHER (object); + + switch (prop_id) + { + case AS_PROP_NITEMS: + g_value_set_int (value,app_switcher->priv->nitems); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + static void hn_app_switcher_class_init (HNAppSwitcherClass *klass) { @@ -1905,12 +1925,22 @@ gobject_class->finalize = hn_app_switcher_finalize; gobject_class->constructor = hn_app_switcher_constructor; + gobject_class->set_property = hn_app_switcher_set_property; + gobject_class->get_property = hn_app_switcher_get_property; + widget_class->show_all = hn_app_switcher_show_all; - klass->bgkill = hn_app_switcher_real_bgkill; - klass->lowmem = hn_app_switcher_real_lowmem; - g_type_class_add_private (klass, sizeof (HNAppSwitcherPrivate)); + + g_object_class_install_property (gobject_class, + AS_PROP_NITEMS, + g_param_spec_int("n_items", + "number_of_items", + "Number of items", + 1, + 20, + 4, + G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)); } static void @@ -1933,9 +1963,9 @@ /* Public API */ GtkWidget * -hn_app_switcher_new (void) +hn_app_switcher_new (gint nitems) { - return g_object_new (HN_TYPE_APP_SWITCHER, NULL); + return g_object_new (HN_TYPE_APP_SWITCHER, "n_items",nitems,NULL); } GList * Modified: projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/hn-app-switcher.h =================================================================== --- projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/hn-app-switcher.h 2006-12-15 16:27:48 UTC (rev 8792) +++ projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/hn-app-switcher.h 2006-12-15 17:09:52 UTC (rev 8793) @@ -77,7 +77,7 @@ GType hn_app_switcher_get_type (void) G_GNUC_CONST; -GtkWidget *hn_app_switcher_new (void); +GtkWidget *hn_app_switcher_new (gint nitems); GList * hn_app_switcher_get_entries (HNAppSwitcher *app_switcher); void hn_app_switcher_foreach_entry (HNAppSwitcher *app_switcher, Modified: projects/haf/branches/maemo-af-desktop/hildon-desktop/test/test4.c =================================================================== --- projects/haf/branches/maemo-af-desktop/hildon-desktop/test/test4.c 2006-12-15 16:27:48 UTC (rev 8792) +++ projects/haf/branches/maemo-af-desktop/hildon-desktop/test/test4.c 2006-12-15 17:09:52 UTC (rev 8793) @@ -24,10 +24,10 @@ gtk_container_add (GTK_CONTAINER (win), GTK_WIDGET (hbox)); - gtk_box_pack_start (GTK_BOX (hbox), hn_app_switcher_new (),TRUE,TRUE,0); - gtk_box_pack_start (GTK_BOX (hbox), hn_app_switcher_new (),TRUE,TRUE,0); - gtk_box_pack_start (GTK_BOX (hbox), hn_app_switcher_new (),TRUE,TRUE,0); - gtk_box_pack_start (GTK_BOX (hbox), hn_app_switcher_new (),TRUE,TRUE,0); + gtk_box_pack_start (GTK_BOX (hbox), hn_app_switcher_new (3),TRUE,TRUE,0); + gtk_box_pack_start (GTK_BOX (hbox), hn_app_switcher_new (4),TRUE,TRUE,0); + gtk_box_pack_start (GTK_BOX (hbox), hn_app_switcher_new (5),TRUE,TRUE,0); + gtk_box_pack_start (GTK_BOX (hbox), hn_app_switcher_new (6),TRUE,TRUE,0); gtk_box_pack_start (GTK_BOX (hbox), button, TRUE,TRUE,0); g_signal_connect (button,"clicked",G_CALLBACK(show_a_menu),NULL);
- Previous message: [maemo-commits] r8792 - in projects/haf/branches/gtk+/maemo-gtk-2-10: . gdk gdk/x11
- Next message: [maemo-commits] r8794 - in projects/haf/branches/maemo-af-desktop/hildon-desktop: . libhildondesktop
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]