[maemo-commits] [maemo-commits] r11003 - in projects/haf/trunk/hildon-desktop: . libhildonwm src
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Thu Apr 12 16:05:03 EEST 2007
- Previous message: [maemo-commits] r11002 - in projects/haf/trunk/libosso: debian src
- Next message: [maemo-commits] r11004 - projects/haf/trunk/hildon-desktop/libhildonwm
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: moimart Date: 2007-04-12 16:05:01 +0300 (Thu, 12 Apr 2007) New Revision: 11003 Modified: projects/haf/trunk/hildon-desktop/ChangeLog projects/haf/trunk/hildon-desktop/libhildonwm/hd-wm-watchable-app.c projects/haf/trunk/hildon-desktop/libhildonwm/hd-wm.c projects/haf/trunk/hildon-desktop/src/hd-desktop.c Log: * src/hd-desktop.c: - Implemented banner when launching applications. Fixes: NB#53974 * libhildonwm/hd-wm.c: - Removed all dbus method for launching banners. - Send application starting signal when launched by DBus. * libhildonwm/hd-wm-watchable-app.c: - Never return maemo-af-desktop when trying to get localized name of watchable application. * ChangeLog updated. Modified: projects/haf/trunk/hildon-desktop/ChangeLog =================================================================== --- projects/haf/trunk/hildon-desktop/ChangeLog 2007-04-12 12:26:22 UTC (rev 11002) +++ projects/haf/trunk/hildon-desktop/ChangeLog 2007-04-12 13:05:01 UTC (rev 11003) @@ -1,3 +1,14 @@ +2007-04-12 Moises Martinez <moises.martinez at nokia.com> + + * src/hd-desktop.c: + - Implemented banner when launching applications. Fixes: NB#53974 + * libhildonwm/hd-wm.c: + - Removed all dbus method for launching banners. + - Send application starting signal when launched by DBus. + * libhildonwm/hd-wm-watchable-app.c: + - Never return maemo-af-desktop when trying to get localized name of + watchable application. + 2007-04-11 Moises Martinez <moises.martinez at nokia.com> * src/hn-others-button.c: Set active others menu's toggle button when Modified: projects/haf/trunk/hildon-desktop/libhildonwm/hd-wm-watchable-app.c =================================================================== --- projects/haf/trunk/hildon-desktop/libhildonwm/hd-wm-watchable-app.c 2007-04-12 12:26:22 UTC (rev 11002) +++ projects/haf/trunk/hildon-desktop/libhildonwm/hd-wm-watchable-app.c 2007-04-12 13:05:01 UTC (rev 11003) @@ -452,8 +452,8 @@ const gchar* hd_wm_watchable_app_get_localized_name (HDWMWatchableApp *app) { - return (app->text_domain?dgettext(app->text_domain,app->app_name): - dgettext("maemo-af-desktop", app->app_name)); + return (app->text_domain ? dgettext(app->text_domain,app->app_name): + app->app_name); } const gchar* Modified: projects/haf/trunk/hildon-desktop/libhildonwm/hd-wm.c =================================================================== --- projects/haf/trunk/hildon-desktop/libhildonwm/hd-wm.c 2007-04-12 12:26:22 UTC (rev 11002) +++ projects/haf/trunk/hildon-desktop/libhildonwm/hd-wm.c 2007-04-12 13:05:01 UTC (rev 11003) @@ -557,53 +557,11 @@ static DBusHandlerResult hd_wm_dbus_method_call_handler (DBusConnection *connection, DBusMessage *message, - void *data ) + void *data) { const gchar *path; HDWM *hdwm = HD_WM (data); - /* Catch APP_LAUNCH_BANNER_METHOD */ - if (dbus_message_is_method_call (message, - APP_LAUNCH_BANNER_METHOD_INTERFACE, - APP_LAUNCH_BANNER_METHOD ) ) - { - DBusError error; - gchar *service_name = NULL; - HDWMWatchableApp *app; - - dbus_error_init (&error); - - dbus_message_get_args (message, - &error, - DBUS_TYPE_STRING, - &service_name, - DBUS_TYPE_INVALID ); - - if (dbus_error_is_set (&error)) - { - g_warning ("Error getting message args: %s\n", error.message); - dbus_error_free (&error); - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; - } - - g_return_val_if_fail (service_name, DBUS_HANDLER_RESULT_NOT_YET_HANDLED); - - g_debug ("Checking if service: '%s' is watchable", service_name); - - /* Is this 'service' watchable ? */ - if ((app = hd_wm_lookup_watchable_app_via_service (service_name)) != NULL) - { - if (hd_wm_watchable_app_has_startup_notify (app) && - hdwm->priv->lowmem_banner_timeout > 0 && - !hd_wm_watchable_app_has_windows (app)) - { - g_signal_emit_by_name (hdwm, - "application-starting", - hd_wm_watchable_app_get_localized_name (app)); - } - } - } - path = dbus_message_get_path(message); if (path != NULL && g_str_equal(path, TASKNAV_GENERAL_PATH)) { @@ -841,7 +799,7 @@ } else { - match_rule = g_strdup_printf("interface='%s'", APP_LAUNCH_BANNER_METHOD_INTERFACE ); + match_rule = g_strdup_printf("interface='%s'", TASKNAV_INSENSITIVE_INTERFACE); dbus_bus_add_match( connection, match_rule, NULL ); g_free (match_rule); @@ -852,7 +810,7 @@ dbus_connection_add_filter (connection, hd_wm_dbus_signal_handler, hdwm, NULL); g_free(match_rule); - match_rule = g_strdup_printf("interface='%s'", TASKNAV_INSENSITIVE_INTERFACE ); + match_rule = g_strdup_printf("interface='%s'", APP_LAUNCH_BANNER_METHOD_INTERFACE ); dbus_bus_add_match (connection, match_rule, NULL ); @@ -990,15 +948,15 @@ G_TYPE_NONE, 0); hdwm_signals[HDWM_APPLICATION_STARTING_SIGNAL] = - g_signal_new("application_starting", + g_signal_new("application-starting", G_OBJECT_CLASS_TYPE(object_class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (HDWMClass,application_starting), NULL, NULL, - g_cclosure_marshal_VOID__STRING, + g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, - G_TYPE_STRING); + G_TYPE_POINTER); hdwm_signals[HDWM_FULLSCREEN] = g_signal_new("fullscreen", @@ -1248,53 +1206,71 @@ void hd_wm_activate_service (const gchar *app, const gchar *parameters) { - char service[SERVICE_NAME_LEN], - path[PATH_NAME_LEN], - interface[INTERFACE_NAME_LEN], - tmp[TMP_NAME_LEN]; - DBusMessage *msg = NULL; - DBusError error; - DBusConnection *conn; + gchar service[SERVICE_NAME_LEN], + path[PATH_NAME_LEN], + interface[INTERFACE_NAME_LEN], + tmp[TMP_NAME_LEN]; + DBusMessage *msg = NULL; + DBusError error; + DBusConnection *conn; + gboolean sent; + HDWM *hdwm = hd_wm_get_singleton (); + HDWMWatchableApp *wapp; - /* If we have full service name we will use it*/ - if (g_strrstr(app,".")) - { - g_snprintf(service,SERVICE_NAME_LEN,"%s",app); - g_snprintf(interface,INTERFACE_NAME_LEN,"%s",service); - g_snprintf(tmp,TMP_NAME_LEN,"%s",app); - g_snprintf(path,PATH_NAME_LEN,"/%s",g_strdelimit(tmp,".",'/')); - } - else /* we will use com.nokia prefix*/ - { - g_snprintf(service,SERVICE_NAME_LEN,"%s.%s",OSSO_BUS_ROOT,app); - g_snprintf(path,PATH_NAME_LEN,"%s/%s",OSSO_BUS_ROOT_PATH,app); - g_snprintf(interface,INTERFACE_NAME_LEN,"%s",service); - } + /* If we have full service name we will use it*/ + if (g_strrstr(app,".")) + { + g_snprintf(service,SERVICE_NAME_LEN,"%s",app); + g_snprintf(interface,INTERFACE_NAME_LEN,"%s",service); + g_snprintf(tmp,TMP_NAME_LEN,"%s",app); + g_snprintf(path,PATH_NAME_LEN,"/%s",g_strdelimit(tmp,".",'/')); + } + else /* we will use com.nokia prefix*/ + { + g_snprintf(service,SERVICE_NAME_LEN,"%s.%s",OSSO_BUS_ROOT,app); + g_snprintf(path,PATH_NAME_LEN,"%s/%s",OSSO_BUS_ROOT_PATH,app); + g_snprintf(interface,INTERFACE_NAME_LEN,"%s",service); + } - dbus_error_init (&error); - conn = dbus_bus_get (DBUS_BUS_SESSION, &error); + dbus_error_init (&error); + conn = dbus_bus_get (DBUS_BUS_SESSION, &error); - if (dbus_error_is_set (&error)) - { - g_warning ("could not start: %s: %s", - service, - error.message); - dbus_error_free (&error); - return; - } + if (dbus_error_is_set (&error)) + { + g_warning ("could not start: %s: %s", + service, + error.message); + dbus_error_free (&error); + return; + } - msg = dbus_message_new_method_call (service, - path, - interface, - OSSO_BUS_TOP); - if (parameters) - dbus_message_append_args (msg, - DBUS_TYPE_STRING, - parameters, - DBUS_TYPE_INVALID); + msg = dbus_message_new_method_call (service, + path, + interface, + OSSO_BUS_TOP); + if (parameters) + dbus_message_append_args (msg, + DBUS_TYPE_STRING, + parameters, + DBUS_TYPE_INVALID); - dbus_message_set_auto_start (msg, TRUE); - dbus_connection_send (conn, msg, NULL); + dbus_message_set_auto_start (msg, TRUE); + sent = dbus_connection_send (conn, msg, NULL); + + if (sent) + { + if ((wapp = hd_wm_lookup_watchable_app_via_service (service)) != NULL) + { + if (hd_wm_watchable_app_has_startup_notify (wapp) && + hdwm->priv->lowmem_banner_timeout >= 0 && + !hd_wm_watchable_app_has_windows (wapp)) + { + g_signal_emit_by_name (hdwm, + "application-starting", + wapp); + } + } + } } Modified: projects/haf/trunk/hildon-desktop/src/hd-desktop.c =================================================================== --- projects/haf/trunk/hildon-desktop/src/hd-desktop.c 2007-04-12 12:26:22 UTC (rev 11002) +++ projects/haf/trunk/hildon-desktop/src/hd-desktop.c 2007-04-12 13:05:01 UTC (rev 11003) @@ -32,14 +32,18 @@ #include <glib-object.h> #include <gtk/gtk.h> #include <libgnomevfs/gnome-vfs.h> +#include <glib/gi18n.h> #ifdef HAVE_LIBOSSO #include <libosso.h> #endif +#include <libhildonwm/hd-wm.h> #include <libhildondesktop/hildon-desktop-window.h> #include <libhildondesktop/hildon-desktop-notification-manager.h> +#include <hildon/hildon-banner.h> + #include "hd-desktop.h" #include "hd-select-plugins-dialog.h" #include "hd-config.h" @@ -56,6 +60,16 @@ #define HD_DESKTOP_CONFIG_FILE "desktop.conf" #define HD_DESKTOP_CONFIG_USER_PATH ".osso/hildon-desktop/" +typedef struct +{ + GtkWidget *parent; + GtkWidget *banner; + struct timeval launch_time; + gchar *msg; + HDWMWatchableApp *app; + HDWM *hdwm; +} HDDesktopBannerInfo; + typedef struct { gchar *config_file; @@ -80,6 +94,89 @@ static void hd_desktop_load_containers (HDDesktop *desktop); +static gboolean +hd_desktop_launch_banner_timeout (gpointer data); + +void +hd_desktop_launch_banner_close (GtkWidget *parent, HDDesktopBannerInfo *info); + +static void +hd_desktop_launch_banner_show (HDWM *hdwm, HDWMWatchableApp *app, gpointer data) +{ + HDDesktopBannerInfo *info; + guint interval; + const gchar *lapp_name; + + g_return_if_fail (app); + + interval = APP_LAUNCH_BANNER_CHECK_INTERVAL * 1000; + + info = g_new0 (HDDesktopBannerInfo, 1); + + info->hdwm = hdwm; + info->app = app; + + gettimeofday (&info->launch_time, NULL ); + + lapp_name = hd_wm_watchable_app_get_localized_name (app); + + info->msg = + g_strdup_printf (_(hd_wm_watchable_app_is_hibernating(app) ? + APP_LAUNCH_BANNER_MSG_RESUMING : + APP_LAUNCH_BANNER_MSG_LOADING), + lapp_name ? _(lapp_name) : "" ); + + g_debug ("Launching banner %s...",info->msg); + + info->banner = GTK_WIDGET (hildon_banner_show_animation (NULL, NULL, info->msg)); + + g_timeout_add (interval, hd_desktop_launch_banner_timeout, info); +} + +static gboolean +hd_desktop_launch_banner_timeout (gpointer data) +{ + HDDesktopBannerInfo *info = data; + struct timeval current_time; + long unsigned int t1, t2; + guint time_left; + gulong current_banner_timeout = 0; + + if (hd_wm_is_lowmem_situation()) + current_banner_timeout = + hd_wm_get_lowmem_banner_timeout() * hd_wm_get_lowmem_timeout_multiplier(); + + gettimeofday (¤t_time, NULL); + + t1 = (long unsigned int) info->launch_time.tv_sec; + t2 = (long unsigned int) current_time.tv_sec; + time_left = (guint) (t2 - t1); + + if (time_left >= current_banner_timeout || + hd_wm_watchable_app_has_windows (info->app)) + { + hd_desktop_launch_banner_close (NULL, info); + return FALSE; + } + + return TRUE; +} + +void +hd_desktop_launch_banner_close (GtkWidget *parent, + HDDesktopBannerInfo *info) +{ + if (!(info && info->msg)) + return; + + if (info->banner) + gtk_widget_destroy (info->banner); + + g_free (info->msg); + g_free (info); +} + + static gint hd_desktop_find_by_id (gconstpointer a, gconstpointer b) { @@ -936,6 +1033,7 @@ HDDesktopPrivate *priv; gchar *user_conf_dir; const gchar *env_config_file; + HDWM *hdwm; desktop->priv = HD_DESKTOP_GET_PRIVATE (desktop); @@ -983,6 +1081,13 @@ desktop->priv->nm = hildon_desktop_notification_manager_get_singleton (); + hdwm = hd_wm_get_singleton (); + + g_signal_connect (hdwm, + "application-starting", + G_CALLBACK (hd_desktop_launch_banner_show), + NULL); + desktop->priv->system_conf_monitor = NULL; desktop->priv->user_conf_monitor = NULL; }
- Previous message: [maemo-commits] r11002 - in projects/haf/trunk/libosso: debian src
- Next message: [maemo-commits] r11004 - projects/haf/trunk/hildon-desktop/libhildonwm
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]