[maemo-commits] [maemo-commits] r11507 - in projects/haf/trunk/hildon-desktop: . libhildondesktop src
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Mon May 7 19:39:08 EEST 2007
- Previous message: [maemo-commits] r11506 - projects/haf/hafbuildbot
- Next message: [maemo-commits] r11508 - in projects/haf/trunk/hildon-desktop: . libhildonwm src
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: moimart
Date: 2007-05-07 19:39:05 +0300 (Mon, 07 May 2007)
New Revision: 11507
Modified:
projects/haf/trunk/hildon-desktop/ChangeLog
projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-menu.c
projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-window.c
projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-window.h
projects/haf/trunk/hildon-desktop/src/hd-switcher-menu-item.c
projects/haf/trunk/hildon-desktop/src/hd-switcher-menu-item.h
projects/haf/trunk/hildon-desktop/src/hd-switcher-menu.c
Log:
* src/hd-switcher-menu-item.[ch]:
- Renamed some methods
- Added leave notify event handler to unselect itself
* src/hd-switcher-menu.c:
- Implemented blinking notifications.
- Fixed theme of icon.
- Fixed first selected item. Misses stack_changed to track selected
items.
* libhildondesktop/hildon-desktop-popup-window.[ch]:
- Added "popdown-window" signal
* ChangeLog updated
Modified: projects/haf/trunk/hildon-desktop/ChangeLog
===================================================================
--- projects/haf/trunk/hildon-desktop/ChangeLog 2007-05-07 16:15:36 UTC (rev 11506)
+++ projects/haf/trunk/hildon-desktop/ChangeLog 2007-05-07 16:39:05 UTC (rev 11507)
@@ -1,3 +1,16 @@
+2007-05-07 Moises Martinez <moises.martinez at nokia.com>
+
+ * src/hd-switcher-menu-item.[ch]:
+ - Renamed some methods
+ - Added leave notify event handler to unselect itself
+ * src/hd-switcher-menu.c:
+ - Implemented blinking notifications.
+ - Fixed theme of icon.
+ - Fixed first selected item. Misses stack_changed to track selected
+ items.
+ * libhildondesktop/hildon-desktop-popup-window.[ch]:
+ - Added "popdown-window" signal
+
2007-05-07 Johan Bilien <johan.bilien at nokia.com>
* libhildondesktop/hildon-desktop-toggle-button.[ch]:
Modified: projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-menu.c
===================================================================
--- projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-menu.c 2007-05-07 16:15:36 UTC (rev 11506)
+++ projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-menu.c 2007-05-07 16:39:05 UTC (rev 11507)
@@ -262,6 +262,14 @@
GList *menu_items = NULL, *l;
gint w,h,x,y;
+ gtk_widget_get_pointer (GTK_WIDGET (widget), &x, &y);
+
+ w = widget->allocation.width;
+ h = widget->allocation.height;
+
+ if (!((x >= 0) && (x <= w) && (y >= 0) && (y <= h)))
+ return TRUE;
+
menu_items =
gtk_container_get_children (GTK_CONTAINER (menu->priv->box_items));
Modified: projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-window.c
===================================================================
--- projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-window.c 2007-05-07 16:15:36 UTC (rev 11506)
+++ projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-window.c 2007-05-07 16:39:05 UTC (rev 11507)
@@ -44,6 +44,7 @@
enum
{
SIGNAL_POPUP_SHOW,
+ SIGNAL_POPUP_CLOSE,
POPUP_N_SIGNALS
};
@@ -154,6 +155,15 @@
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+
+ signals[SIGNAL_POPUP_SHOW] =
+ g_signal_new ("popdown-window",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (HildonDesktopPopupWindowClass,popdown_window),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
g_object_class_install_property (object_class,
PROP_POPUP_N_PANES,
@@ -967,6 +977,8 @@
for (i=0; i < popup->priv->n_extra_panes; i++)
gtk_grab_remove (popup->priv->extra_panes[i]);
+
+ g_signal_emit_by_name (popup, "popdown-window");
}
void
Modified: projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-window.h
===================================================================
--- projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-window.h 2007-05-07 16:15:36 UTC (rev 11506)
+++ projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-window.h 2007-05-07 16:39:05 UTC (rev 11507)
@@ -66,6 +66,7 @@
/* */
void (*popup_window) (HildonDesktopPopupWindow *window);
+ void (*popdown_window) (HildonDesktopPopupWindow *window);
};
GType
Modified: projects/haf/trunk/hildon-desktop/src/hd-switcher-menu-item.c
===================================================================
--- projects/haf/trunk/hildon-desktop/src/hd-switcher-menu-item.c 2007-05-07 16:15:36 UTC (rev 11506)
+++ projects/haf/trunk/hildon-desktop/src/hd-switcher-menu-item.c 2007-05-07 16:39:05 UTC (rev 11507)
@@ -264,7 +264,7 @@
else
{
pixbuf_anim = gtk_image_get_animation (GTK_IMAGE (icon));
-
+ g_debug ("Turning animation off");
/* grab static image from menu item and reset */
pixbuf = gdk_pixbuf_animation_get_static_image (pixbuf_anim);
@@ -423,7 +423,7 @@
gtk_image_set_from_pixbuf
(GTK_IMAGE (priv->icon), priv->notification_icon);
- g_debug ("Id: %d Summary of notification: %s", priv->notification_id, priv->notification_summary);
+ g_debug ("pixbuf: %p Id: %d Summary of notification: %s", priv->notification_icon, priv->notification_id, priv->notification_summary);
gtk_label_set_text (GTK_LABEL (priv->label),
priv->notification_summary); /* TODO: Insert timestamp */
@@ -569,7 +569,7 @@
menuitem->priv->notification_id,
&error);
- if (!error)
+ if (error)
{
g_warning ("We cannot close the notification!?!?!");
g_error_free (error);
@@ -621,6 +621,14 @@
return FALSE;
}
+static gboolean
+hd_switcher_menu_item_leave_notify (GtkWidget *widget,
+ GdkEventCrossing *event)
+{
+ gtk_item_deselect (GTK_ITEM (widget));
+
+ return TRUE;
+}
static void
hd_switcher_menu_item_class_init (HDSwitcherMenuItemClass *klass)
@@ -638,6 +646,8 @@
widget_class->size_request = hd_switcher_menu_item_size_request;
widget_class->button_press_event = hd_switcher_menu_item_button_press_event;
widget_class->button_release_event = hd_switcher_menu_item_button_release_event;
+
+ widget_class->leave_notify_event = hd_switcher_menu_item_leave_notify;
menuitem_class->activate = hd_switcher_menu_item_activate;
@@ -694,7 +704,7 @@
(G_PARAM_CONSTRUCT | G_PARAM_READWRITE)));
g_object_class_install_property (gobject_class,
- MENU_PROP_NOT_BODY,
+ MENU_PROP_NOT_ICON,
g_param_spec_object ("notification-icon",
"Icon notification",
"The icon of the notification",
@@ -830,16 +840,18 @@
}
void
-hd_switcher_menu_item_set_is_blinking (HDSwitcherMenuItem *menuitem,
+hd_switcher_menu_item_set_blinking (HDSwitcherMenuItem *menuitem,
gboolean is_blinking)
{
g_return_if_fail (HD_IS_SWITCHER_MENU_ITEM (menuitem));
hd_switcher_menu_item_icon_animation (menuitem->priv->icon, is_blinking);
+
+ menuitem->priv->is_blinking = is_blinking;
}
gboolean
-hd_switcher_menu_item_get_is_blinking (HDSwitcherMenuItem *menuitem)
+hd_switcher_menu_item_is_blinking (HDSwitcherMenuItem *menuitem)
{
g_return_val_if_fail (HD_IS_SWITCHER_MENU_ITEM (menuitem), FALSE);
Modified: projects/haf/trunk/hildon-desktop/src/hd-switcher-menu-item.h
===================================================================
--- projects/haf/trunk/hildon-desktop/src/hd-switcher-menu-item.h 2007-05-07 16:15:36 UTC (rev 11506)
+++ projects/haf/trunk/hildon-desktop/src/hd-switcher-menu-item.h 2007-05-07 16:39:05 UTC (rev 11507)
@@ -77,9 +77,9 @@
void hd_switcher_menu_item_set_entry_info (HDSwitcherMenuItem *menuitem,
HDEntryInfo *info);
HDEntryInfo *hd_switcher_menu_item_get_entry_info (HDSwitcherMenuItem *menuitem);
-void hd_switcher_menu_item_set_is_blinking (HDSwitcherMenuItem *menuitem,
+void hd_switcher_menu_item_set_blinking (HDSwitcherMenuItem *menuitem,
gboolean is_blinking);
-gboolean hd_switcher_menu_item_get_is_blinking (HDSwitcherMenuItem *menuitem);
+gboolean hd_switcher_menu_item_is_blinking (HDSwitcherMenuItem *menuitem);
gint hd_switcher_menu_item_get_notification_id (HDSwitcherMenuItem *menuitem);
Modified: projects/haf/trunk/hildon-desktop/src/hd-switcher-menu.c
===================================================================
--- projects/haf/trunk/hildon-desktop/src/hd-switcher-menu.c 2007-05-07 16:15:36 UTC (rev 11506)
+++ projects/haf/trunk/hildon-desktop/src/hd-switcher-menu.c 2007-05-07 16:39:05 UTC (rev 11507)
@@ -67,6 +67,8 @@
#define AS_INTERNAL_PADDING 10
#define AS_SEPARATOR_HEIGHT 10
+#define SWITCHER_TOGGLE_BUTTON GTK_BIN(switcher)->child
+
enum
{
PROP_MENU_NITEMS=1,
@@ -88,6 +90,13 @@
GtkImage *image_button;
GtkWidget *active_menu_item;
+
+ gboolean is_open;
+
+ GtkIconTheme *icon_theme;
+ GtkWidget *icon;
+
+ GtkTreeIter *last_iter_added;
};
static GObject *hd_switcher_menu_constructor (GType gtype,
@@ -96,6 +105,8 @@
static void hd_switcher_menu_finalize (GObject *object);
+static void hd_switcher_menu_style_set (GtkWidget *widget, GtkStyle *style, gpointer data);
+
static void hd_switcher_menu_toggled_cb (GtkWidget *button, HDSwitcherMenu *switcher);
static void hd_switcher_menu_scroll_to (HildonDesktopPopupWindow *window,
@@ -134,6 +145,10 @@
switcher->priv->active_menu_item = NULL;
+ switcher->priv->is_open = FALSE;
+
+ switcher->priv->last_iter_added = NULL;
+
switcher->hdwm = hd_wm_get_singleton ();
switcher->nm =
@@ -146,8 +161,8 @@
static void
hd_switcher_menu_class_init (HDSwitcherMenuClass *switcher)
{
- GObjectClass *object_class = G_OBJECT_CLASS (switcher);
-
+ GObjectClass *object_class = G_OBJECT_CLASS (switcher);
+
object_class->constructor = hd_switcher_menu_constructor;
object_class->finalize = hd_switcher_menu_finalize;
@@ -160,6 +175,64 @@
hildon_desktop_popup_recalculate_position (switcher->priv->popup_window);
}
+static GdkPixbuf *
+hd_switcher_menu_get_icon_from_theme (HDSwitcherMenu *switcher,
+ const gchar *icon_name,
+ gint size)
+{
+ GError *error;
+ GdkPixbuf *retval;
+
+ if (!icon_name)
+ return NULL;
+
+ if (!switcher->priv->icon_theme)
+ switcher->priv->icon_theme = gtk_icon_theme_get_default ();
+
+ g_return_val_if_fail (switcher->priv->icon_theme, NULL);
+
+ if (!icon_name || icon_name[0] == '\0')
+ return NULL;
+
+ error = NULL;
+ retval = gtk_icon_theme_load_icon (switcher->priv->icon_theme,
+ icon_name,
+ size == -1 ? AS_ICON_SIZE : size,
+ 0,
+ &error);
+ if (error)
+ {
+ g_warning ("Could not load icon '%s': %s\n",
+ icon_name,
+ error->message);
+
+ g_error_free (error);
+
+ return NULL;
+ }
+
+ return retval;
+}
+
+static void
+hd_switcher_menu_update_open (HildonDesktopPopupWindow *window, HDSwitcherMenu *switcher)
+{
+ GList *children = NULL, *l;
+
+ switcher->priv->is_open = FALSE;
+
+ children = hildon_desktop_popup_menu_get_children (switcher->priv->menu_notifications);
+
+ for (l = children; l != NULL; l = g_list_next (l))
+ {
+ if (HD_IS_SWITCHER_MENU_ITEM (l->data))
+ {
+ if (hd_switcher_menu_item_is_blinking (HD_SWITCHER_MENU_ITEM (l->data)))
+ hd_switcher_menu_item_set_blinking (HD_SWITCHER_MENU_ITEM (l->data),FALSE);
+ }
+ }
+}
+
static GObject *
hd_switcher_menu_constructor (GType gtype,
guint n_params,
@@ -169,16 +242,26 @@
HDSwitcherMenu *switcher;
GtkWidget *button;
HDWM *hdwm = hd_wm_get_singleton ();
+ GdkPixbuf *pixbuf;
+
object = G_OBJECT_CLASS (hd_switcher_menu_parent_class)->constructor (gtype,
n_params,
params);
-
switcher = HD_SWITCHER_MENU (object);
gtk_widget_push_composite_child ();
button = gtk_toggle_button_new ();
+
+ gtk_widget_set_name (button, AS_MENU_BUTTON_NAME);
+ gtk_widget_set_size_request (button, -1, AS_MENU_BUTTON_HEIGHT);
+
+ pixbuf = hd_switcher_menu_get_icon_from_theme (switcher, AS_MENU_BUTTON_ICON, -1);
+ switcher->priv->icon = gtk_image_new_from_pixbuf (pixbuf);
+ gtk_container_add (GTK_CONTAINER (button), switcher->priv->icon);
+ gtk_widget_show (switcher->priv->icon);
+ g_object_unref (pixbuf);
gtk_container_add (GTK_CONTAINER (object), button);
gtk_widget_show (button);
@@ -214,6 +297,16 @@
gtk_widget_show (GTK_WIDGET (switcher->priv->menu_applications));
gtk_widget_show (GTK_WIDGET (switcher->priv->menu_notifications));
+ g_signal_connect (switcher,
+ "style-set",
+ G_CALLBACK (hd_switcher_menu_style_set),
+ NULL);
+
+ g_signal_connect (switcher->priv->popup_window,
+ "popdown-window",
+ G_CALLBACK (hd_switcher_menu_update_open),
+ (gpointer)switcher);
+
g_signal_connect (switcher->priv->menu_applications,
"popup-menu-resize",
G_CALLBACK (hd_switcher_menu_resize_menu),
@@ -304,6 +397,44 @@
}
static void
+hd_switcher_menu_replace_blinking_icon (HDSwitcherMenu *switcher, GdkPixbuf *icon)
+{
+ if (!switcher->priv->is_open && icon)
+ {
+ GdkPixbufAnimation *icon_blinking;
+ GtkWidget *image_blinking;
+
+ icon_blinking =
+ hn_app_pixbuf_anim_blinker_new (icon,1000/ANIM_FPS,-1,10);
+
+ image_blinking = gtk_image_new ();
+ gtk_image_set_from_animation (GTK_IMAGE (image_blinking), icon_blinking);
+
+ if (image_blinking)
+ {
+ if (GTK_BIN (SWITCHER_TOGGLE_BUTTON)->child == switcher->priv->icon)
+ {
+ g_object_ref (G_OBJECT (switcher->priv->icon));
+ gtk_container_remove (GTK_CONTAINER (SWITCHER_TOGGLE_BUTTON), GTK_WIDGET (switcher->priv->icon));
+ }
+ else
+ gtk_container_remove (GTK_CONTAINER (SWITCHER_TOGGLE_BUTTON), GTK_BIN (SWITCHER_TOGGLE_BUTTON)->child);
+ }
+
+ gtk_container_add (GTK_CONTAINER (SWITCHER_TOGGLE_BUTTON), image_blinking);
+ gtk_widget_show (image_blinking);
+ }
+}
+
+static void
+hd_switcher_menu_style_set (GtkWidget *widget, GtkStyle *style, gpointer data)
+{
+
+ gtk_widget_set_name (widget, AS_MENU_BUTTON_NAME);
+ gtk_widget_set_name (GTK_BIN (widget)->child, AS_MENU_BUTTON_NAME);
+}
+
+static void
hd_switcher_menu_get_workarea (GtkAllocation *allocation)
{
unsigned long n;
@@ -446,9 +577,23 @@
(gpointer)switcher,
GDK_CURRENT_TIME);
- g_debug ("actual size of window: w: %d h: %d",
- GTK_WIDGET (switcher->priv->popup_window)->allocation.width,
- GTK_WIDGET (switcher->priv->popup_window)->allocation.height);
+ if (!hildon_desktop_popup_menu_get_children (switcher->priv->menu_notifications))
+ gtk_widget_hide (hildon_desktop_popup_window_get_pane (switcher->priv->popup_window, 1));
+ else
+ gtk_widget_show (hildon_desktop_popup_window_get_pane (switcher->priv->popup_window, 1));
+
+ switcher->priv->is_open = TRUE;
+
+ if (GTK_BIN (SWITCHER_TOGGLE_BUTTON)->child != switcher->priv->icon)
+ {
+ gtk_container_remove (GTK_CONTAINER (SWITCHER_TOGGLE_BUTTON),
+ GTK_BIN (SWITCHER_TOGGLE_BUTTON)->child);
+
+ gtk_container_add (GTK_CONTAINER (SWITCHER_TOGGLE_BUTTON),
+ GTK_WIDGET (switcher->priv->icon));
+
+ g_object_unref (G_OBJECT (switcher->priv->icon));
+ }
}
static void
@@ -517,12 +662,13 @@
menu_item = hd_switcher_menu_item_new_from_entry_info (entry, TRUE);
+ hildon_desktop_popup_menu_add_item
+ (switcher->priv->menu_applications, GTK_MENU_ITEM (menu_item));
+
if (hd_entry_info_is_active (entry))
hildon_desktop_popup_menu_select_item
(switcher->priv->menu_applications, GTK_MENU_ITEM (menu_item));
- hildon_desktop_popup_menu_add_item
- (switcher->priv->menu_applications, GTK_MENU_ITEM (menu_item));
}
/* append the separator for this app*/
@@ -538,22 +684,10 @@
HDEntryInfo *info,
HDSwitcherMenu *switcher)
{
-/* GtkWidget *menu_item;*/
-
if (!info)
return;
hd_switcher_menu_create_menu (switcher, hdwm);
-/*
- menu_item = gtk_separator_menu_item_new ();
-
- hildon_desktop_popup_menu_add_item
- (switcher->priv->menu_applications, GTK_MENU_ITEM (menu_item));
-
- menu_item = hd_switcher_menu_item_new_from_entry_info (info, TRUE);
-
- hildon_desktop_popup_menu_add_item
- (switcher->priv->menu_applications, GTK_MENU_ITEM (menu_item));*/
}
static void
@@ -638,8 +772,8 @@
if (menu_item)
{
/* child of one of the app buttons */
- if (!hd_switcher_menu_item_get_is_blinking (HD_SWITCHER_MENU_ITEM (menu_item)))
- hd_switcher_menu_item_set_is_blinking (HD_SWITCHER_MENU_ITEM (menu_item), TRUE);
+ if (!hd_switcher_menu_item_is_blinking (HD_SWITCHER_MENU_ITEM (menu_item)))
+ hd_switcher_menu_item_set_blinking (HD_SWITCHER_MENU_ITEM (menu_item), TRUE);
}
}
}
@@ -674,7 +808,13 @@
gchar *summary = NULL, *body = NULL;
guint id;
GtkWidget *menu_item;
-
+
+ GtkWidget *pane_notifications =
+ hildon_desktop_popup_window_get_pane
+ (switcher->priv->popup_window, 1);
+
+ if (switcher->priv->is_open && !GTK_WIDGET_MAPPED (pane_notifications))
+ gtk_widget_show (pane_notifications);
gtk_tree_model_get (tree_model,
iter,
@@ -683,13 +823,23 @@
HD_NM_COL_SUMMARY, &summary,
HD_NM_COL_BODY, &body,
-1);
- g_debug ("Summary %s %s --------->",summary,body);
+
+ if (switcher->priv->last_iter_added == NULL)
+ hd_switcher_menu_notification_deleted_cb
+ (HILDON_DESKTOP_NOTIFICATION_MANAGER (tree_model), id, switcher);
+
menu_item =
hd_switcher_menu_item_new_from_notification
(id, icon, summary, body, TRUE);
+ hd_switcher_menu_item_set_blinking (HD_SWITCHER_MENU_ITEM (menu_item), TRUE);
+
hildon_desktop_popup_menu_add_item
(switcher->priv->menu_notifications, GTK_MENU_ITEM (menu_item));
+
+ hd_switcher_menu_replace_blinking_icon (switcher, icon);
+
+ switcher->priv->last_iter_added = NULL;
}
static void
@@ -724,6 +874,6 @@
GtkTreeIter *iter,
HDSwitcherMenu *switcher)
{
-
+ switcher->priv->last_iter_added = iter;
}
- Previous message: [maemo-commits] r11506 - projects/haf/hafbuildbot
- Next message: [maemo-commits] r11508 - in projects/haf/trunk/hildon-desktop: . libhildonwm src
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
