[maemo-commits] [maemo-commits] r8812 - in projects/haf/branches/maemo-af-desktop/hildon-desktop: . libhildondesktop test
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Tue Dec 19 11:14:16 EET 2006
- Previous message: [maemo-commits] r8811 - in projects/haf/trunk/osso-gnome-vfs2/debian: . patches
- Next message: [maemo-commits] r8813 - projects/haf/branches/osso-gnome-vfs2/2-16-upstream-merge/debian/patches
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: moimart Date: 2006-12-19 11:14:14 +0200 (Tue, 19 Dec 2006) New Revision: 8812 Added: projects/haf/branches/maemo-af-desktop/hildon-desktop/test/test5.c Modified: projects/haf/branches/maemo-af-desktop/hildon-desktop/ChangeLog projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/desktop-panel.c projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/hildon-desktop-panel-item.c projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/hildon-desktop-panel-item.h 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/test5.c: test added * test/test4.c: test updated. * libhildondesktop/desktop-panel.c: - Added orientation change notification * libhildondesktop/hn-app-switcher.[ch]: - Implemented change of orientation * libhildondesktop/hildon-desktop-panel-item.[ch]: - Added orientation property. * libhildondesktop/hn-app-button.c: Fixed blinking by adding a app_switcher reference to every button. * ChangeLog updated. Modified: projects/haf/branches/maemo-af-desktop/hildon-desktop/ChangeLog =================================================================== --- projects/haf/branches/maemo-af-desktop/hildon-desktop/ChangeLog 2006-12-19 09:05:14 UTC (rev 8811) +++ projects/haf/branches/maemo-af-desktop/hildon-desktop/ChangeLog 2006-12-19 09:14:14 UTC (rev 8812) @@ -1,3 +1,16 @@ +2006-12-19 Moises Martinez <moises.martinez at nokia.com> + + * test/test5.c: test added + * test/test4.c: test updated. + * libhildondesktop/desktop-panel.c: + - Added orientation change notification + * libhildondesktop/hn-app-switcher.[ch]: + - Implemented change of orientation + * libhildondesktop/hildon-desktop-panel-item.[ch]: + - Added orientation property. + * libhildondesktop/hn-app-button.c: Fixed blinking by + adding a app_switcher reference to every button. + 2006-12-18 Lucas Rocha <lucas.rocha at nokia.com> * libhildondesktop/hildon-desktop-plugin.h, Modified: projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/desktop-panel.c =================================================================== --- projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/desktop-panel.c 2006-12-19 09:05:14 UTC (rev 8811) +++ projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/desktop-panel.c 2006-12-19 09:14:14 UTC (rev 8812) @@ -24,10 +24,10 @@ */ #include "desktop-panel.h" -#include "hildon-desktop-item.h" +#include "hildon-desktop-panel-item.h" -#define PANEL_WIDGET_DEFAULT_WIDTH 80 -#define PANEL_WIDGET_DEFAULT_HEIGHT 80 +#define PANEL_WIDGET_DEFAULT_WIDTH 180 +#define PANEL_WIDGET_DEFAULT_HEIGHT 180 #define DESKTOP_PANEL_GET_PRIVATE(object) \ (G_TYPE_INSTANCE_GET_PRIVATE ((object), DESKTOP_TYPE_PANEL, DesktopPanel)) @@ -77,7 +77,7 @@ GtkAllocation *allocation); static void desktop_panel_calc_positions (DesktopPanel *panel, - HildonDesktopItem *item); + HildonDesktopPanelItem *item); static void desktop_panel_cadd (GtkContainer *container, GtkWidget *widget); @@ -159,6 +159,22 @@ } static void +desktop_panel_change_child_orientation (DesktopPanel *panel) +{ + GList *children = NULL, *iter; + + children = gtk_container_get_children (GTK_CONTAINER (panel)); + + for (iter = children; iter ; iter = g_list_next (iter)) + if (HILDON_DESKTOP_IS_PANEL_ITEM (iter->data)) + g_object_set (G_OBJECT (iter->data),"orientation",panel->orient,NULL); + + /*TODO: should we queue_redrawing for childrens? */ + + g_list_free (children); +} + +static void desktop_panel_get_property (GObject *object, guint prop_id, GValue *value, @@ -194,6 +210,7 @@ GParamSpec *pspec) { DesktopPanel *panel; + GtkOrientation old_orientation; g_assert (object && DESKTOP_IS_PANEL (object)); @@ -202,14 +219,23 @@ switch (prop_id) { case PROP_ORI: + old_orientation = panel->orient; panel->orient = g_value_get_int (value); + if (panel->orient != old_orientation) + { + g_object_notify (object,"orientation"); + desktop_panel_change_child_orientation (panel); + } break; + case PROP_ITEM_WIDTH: panel->item_width = g_value_get_int (value); break; + case PROP_ITEM_HEIGHT: panel->item_height = g_value_get_int (value); break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -713,7 +739,7 @@ } static void -desktop_panel_calc_positions (DesktopPanel *panel, HildonDesktopItem *item) +desktop_panel_calc_positions (DesktopPanel *panel, HildonDesktopPanelItem *item) { /* FIXME: Please, implement me smoothly and very optimized */ @@ -749,8 +775,8 @@ PANEL_WIDGET_DEFAULT_HEIGHT); } - if (HILDON_DESKTOP_IS_ITEM (widget)) - desktop_panel_calc_positions (panel,HILDON_DESKTOP_ITEM (widget));/*FIXME: Do this! */ + if (HILDON_DESKTOP_IS_PANEL_ITEM (widget)) + desktop_panel_calc_positions (panel,HILDON_DESKTOP_PANEL_ITEM (widget));/*FIXME: Do this! */ else { gtk_box_pack_start (GTK_BOX (panel), widget, FALSE, FALSE, 0); Modified: projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/hildon-desktop-panel-item.c =================================================================== --- projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/hildon-desktop-panel-item.c 2006-12-19 09:05:14 UTC (rev 8811) +++ projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/hildon-desktop-panel-item.c 2006-12-19 09:14:14 UTC (rev 8812) @@ -35,6 +35,7 @@ { PROP_0, DESKTOP_P_ITEM_POS_PROP, + DESKTOP_P_ITEM_POS_ORIENTATION, D_ITEM_PROPS }; @@ -84,6 +85,16 @@ -1, G_PARAM_CONSTRUCT | G_PARAM_READWRITE)); + g_object_class_install_property (object_class, + DESKTOP_P_ITEM_POS_ORIENTATION, + g_param_spec_uint("orientation", + "orientation", + "Orientation", + GTK_ORIENTATION_HORIZONTAL, + GTK_ORIENTATION_VERTICAL, + GTK_ORIENTATION_VERTICAL, + G_PARAM_CONSTRUCT | G_PARAM_READWRITE)); + } static void @@ -93,6 +104,7 @@ GParamSpec *pspec) { HildonDesktopPanelItem *item; + GtkOrientation old_orientation; g_assert (object && HILDON_DESKTOP_IS_PANEL_ITEM (object)); @@ -103,6 +115,14 @@ case DESKTOP_P_ITEM_POS_PROP: item->position = g_value_get_int (value); break; + + case DESKTOP_P_ITEM_POS_ORIENTATION: + old_orientation = item->orientation; + item->orientation = g_value_get_uint (value); + if (old_orientation == item->orientation) + g_object_notify (object,"orientation"); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -126,6 +146,9 @@ case DESKTOP_P_ITEM_POS_PROP: g_value_set_int (value,item->position); break; + case DESKTOP_P_ITEM_POS_ORIENTATION: + g_value_set_uint (value,item->orientation); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; Modified: projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/hildon-desktop-panel-item.h =================================================================== --- projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/hildon-desktop-panel-item.h 2006-12-19 09:05:14 UTC (rev 8811) +++ projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/hildon-desktop-panel-item.h 2006-12-19 09:14:14 UTC (rev 8812) @@ -45,6 +45,7 @@ gint position; + GtkOrientation orientation; }; struct _HildonDesktopPanelItemClass 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 09:05:14 UTC (rev 8811) +++ projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/hn-app-button.c 2006-12-19 09:14:14 UTC (rev 8812) @@ -125,7 +125,8 @@ { BUTTON_PROP_0, BUTTON_PROP_ENTRY_INFO, - BUTTON_PROP_IS_BLINKING + BUTTON_PROP_IS_BLINKING, + BUTTON_PROP_APPSWITCHER }; #define HN_APP_BUTTON_GET_PRIVATE(obj) \ @@ -143,6 +144,8 @@ guint is_blinking : 1; guint is_thumbable : 1; + + HNAppSwitcher *app_switcher; }; @@ -827,6 +830,9 @@ hn_app_button_set_is_blinking (app_button, g_value_get_boolean (value)); break; + case BUTTON_PROP_APPSWITCHER: + app_button->priv->app_switcher = g_value_get_pointer (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); break; @@ -850,6 +856,9 @@ case BUTTON_PROP_IS_BLINKING: g_value_set_boolean (value, app_button->priv->is_blinking); break; + case BUTTON_PROP_APPSWITCHER: + g_value_set_pointer (value, app_button->priv->app_switcher); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); break; @@ -894,6 +903,13 @@ FALSE, G_PARAM_READWRITE)); + g_object_class_install_property (gobject_class, + BUTTON_PROP_APPSWITCHER, + g_param_spec_pointer ("app-switcher", + "Application Switcher", + "The application switcher", + G_PARAM_READWRITE)); + g_type_class_add_private (gobject_class, sizeof (HNAppButtonPrivate)); } @@ -914,7 +930,8 @@ gtk_widget_pop_composite_child (); - priv->info = NULL; + priv->info = NULL; + priv->app_switcher = NULL; priv->is_blinking = FALSE; priv->is_thumbable = FALSE; @@ -1177,14 +1194,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 + if (button->priv->is_blinking && + button->priv->app_switcher && + !hn_app_switcher_get_system_inactivity (button->priv->app_switcher)) + { + hn_app_button_icon_animation (button->priv->icon, button->priv->is_blinking); + } + gtk_widget_show (button->priv->icon); gtk_widget_set_sensitive (GTK_WIDGET (button), TRUE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), @@ -1245,14 +1262,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 + if (button->priv->is_blinking && + button->priv->app_switcher && + !hn_app_switcher_get_system_inactivity (button->priv->app_switcher)) + { + hn_app_button_icon_animation (button->priv->icon, button->priv->is_blinking); + } + 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-19 09:05:14 UTC (rev 8811) +++ projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/hn-app-switcher.c 2006-12-19 09:14:14 UTC (rev 8812) @@ -124,7 +124,7 @@ enum { - AS_PROP_NITEMS=1 + AS_PROP_NITEMS=1, }; static void @@ -143,6 +143,9 @@ hn_app_switcher_show_menu_cb (HDWM *hdwm, gpointer data); static void +hn_app_switcher_orientation_changed_cb (HNAppSwitcher *app_switcher, GParamSpec *pspec); + +static void hn_app_switcher_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); static void @@ -910,6 +913,44 @@ hn_app_switcher_toggle_menu_button (app_switcher); } +static void +hn_app_switcher_orientation_changed_cb (HNAppSwitcher *app_switcher, + GParamSpec *pspec) +{ + GList *children,*iter; + + children = + gtk_container_get_children (GTK_CONTAINER (app_switcher->box)); + + if (children == NULL) return; + else g_debug ("Changing orientation app_switcher"); + + for (iter = children; iter; iter = g_list_next (iter)) + { + g_object_ref (G_OBJECT (iter->data)); + gtk_container_remove (GTK_CONTAINER (app_switcher->box),GTK_WIDGET (iter->data)); + } + + gtk_container_remove (GTK_CONTAINER (app_switcher),GTK_WIDGET (app_switcher->box)); + + if (HILDON_DESKTOP_PANEL_ITEM (app_switcher)->orientation == GTK_ORIENTATION_HORIZONTAL) + app_switcher->box = GTK_BOX (gtk_hbox_new (FALSE, 0)); + else + app_switcher->box = GTK_BOX (gtk_vbox_new (FALSE, 0)); + + gtk_container_add (GTK_CONTAINER (app_switcher),GTK_WIDGET (app_switcher->box)); + + for (iter = children; iter; iter = g_list_next (iter)) + { + gtk_container_add (GTK_CONTAINER (app_switcher->box),GTK_WIDGET (iter->data)); + g_object_unref (G_OBJECT (iter->data)); + } + + gtk_widget_show_all (GTK_WIDGET (app_switcher->box)); + + g_list_free (children); +} + static GtkWidget * create_app_button (HNAppSwitcher *app_switcher, gint pos) @@ -927,6 +968,8 @@ retval = hn_app_button_new (NULL); + g_object_set (retval, "app-switcher", app_switcher, NULL); + set_app_button_pos (retval, pos, priv->nitems); hn_app_button_set_is_blinking (HN_APP_BUTTON (retval), FALSE); @@ -964,14 +1007,17 @@ /* inner box, used for padding */ g_debug ("Adding inner VBox"); - - app_switcher->vbox = GTK_VBOX (gtk_vbox_new (FALSE, 0)); - gtk_widget_set_composite_name (GTK_WIDGET (app_switcher->vbox), "application-switcher-button-box"); + if (HILDON_DESKTOP_PANEL_ITEM (app_switcher)->orientation == GTK_ORIENTATION_HORIZONTAL) + app_switcher->box = GTK_BOX (gtk_hbox_new (FALSE, 0)); + else + app_switcher->box = GTK_BOX (gtk_vbox_new (FALSE, 0)); + + gtk_widget_set_composite_name (GTK_WIDGET (app_switcher->box), "application-switcher-button-box"); - gtk_container_add (GTK_CONTAINER (app_switcher),GTK_WIDGET (app_switcher->vbox)); + gtk_container_add (GTK_CONTAINER (app_switcher),GTK_WIDGET (app_switcher->box)); - gtk_widget_show (GTK_WIDGET (app_switcher->vbox)); + gtk_widget_show (GTK_WIDGET (app_switcher->box)); /* most recent applications buttons */ g_debug ("Adding buttons"); @@ -979,14 +1025,14 @@ 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_box_pack_start (GTK_BOX (app_switcher->box), button, TRUE, TRUE, 0); gtk_widget_show (button); } /* menu button */ g_debug ("Adding menu button"); button = create_menu_button (app_switcher); - gtk_box_pack_start (GTK_BOX (app_switcher->vbox), button, TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (app_switcher->box), button, TRUE, TRUE, 0); gtk_widget_show (button); g_signal_connect (app_switcher->hdwm, @@ -1013,6 +1059,11 @@ "show_menu", G_CALLBACK (hn_app_switcher_show_menu_cb), (gpointer)app_switcher); + + g_signal_connect (app_switcher, + "notify::orientation", + G_CALLBACK (hn_app_switcher_orientation_changed_cb), + NULL); gtk_widget_pop_composite_child (); } @@ -1954,7 +2005,7 @@ /* set base properties of the app-switcher widget */ - gtk_container_set_border_width (GTK_CONTAINER (app_switcher->vbox), 0); + gtk_container_set_border_width (GTK_CONTAINER (app_switcher), 0); hn_app_switcher_init_sound_samples (app_switcher); } @@ -1965,7 +2016,7 @@ GtkWidget * hn_app_switcher_new (gint nitems) { - return g_object_new (HN_TYPE_APP_SWITCHER, "n_items",nitems,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-19 09:05:14 UTC (rev 8811) +++ projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/hn-app-switcher.h 2006-12-19 09:14:14 UTC (rev 8812) @@ -56,7 +56,7 @@ { TaskNavigatorItem parent_instance; - GtkVBox *vbox; + GtkBox *box; HDWM *hdwm; 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-19 09:05:14 UTC (rev 8811) +++ projects/haf/branches/maemo-af-desktop/hildon-desktop/test/test4.c 2006-12-19 09:14:14 UTC (rev 8812) @@ -24,10 +24,10 @@ gtk_container_add (GTK_CONTAINER (win), GTK_WIDGET (hbox)); - 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), g_object_new (HN_TYPE_APP_SWITCHER,"n_items",3,"orientation",GTK_ORIENTATION_HORIZONTAL,NULL),TRUE,TRUE,0); + gtk_box_pack_start (GTK_BOX (hbox), g_object_new (HN_TYPE_APP_SWITCHER,"n_items",5,"orientation",GTK_ORIENTATION_VERTICAL,NULL),TRUE,TRUE,0); + gtk_box_pack_start (GTK_BOX (hbox), g_object_new (HN_TYPE_APP_SWITCHER,"n_items",7,"orientation",GTK_ORIENTATION_VERTICAL,NULL),TRUE,TRUE,0); + gtk_box_pack_start (GTK_BOX (hbox), g_object_new (HN_TYPE_APP_SWITCHER,"n_items",9,"orientation",GTK_ORIENTATION_VERTICAL,NULL),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); Added: projects/haf/branches/maemo-af-desktop/hildon-desktop/test/test5.c =================================================================== --- projects/haf/branches/maemo-af-desktop/hildon-desktop/test/test5.c 2006-12-19 09:05:14 UTC (rev 8811) +++ projects/haf/branches/maemo-af-desktop/hildon-desktop/test/test5.c 2006-12-19 09:14:14 UTC (rev 8812) @@ -0,0 +1,32 @@ +#include <libhildondesktop/hn-app-switcher.h> +#include <libhildonwm/hd-wm.h> + +int +main (int argc, char **argv) +{ + GtkWidget *panel; + + gtk_init (&argc,&argv); + + HDWM *wm = hd_wm_get_singleton (); + + panel = g_object_new (DESKTOP_TYPE_PANEL_WINDOW, + "width", + 480, + "height", + 100, + "orientation", + DPANEL_ORIENTATION_LEFT, + NULL); + + gtk_container_add (GTK_CONTAINER (HILDON_DESKTOP_WINDOW (panel)->container), + g_object_new (HN_TYPE_APP_SWITCHER,"n_items",3,NULL)); + + + gtk_widget_show_all (panel); + + gtk_main (); + + return 0; +} +
- Previous message: [maemo-commits] r8811 - in projects/haf/trunk/osso-gnome-vfs2/debian: . patches
- Next message: [maemo-commits] r8813 - projects/haf/branches/osso-gnome-vfs2/2-16-upstream-merge/debian/patches
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]