[maemo-commits] [maemo-commits] r15293 - in projects/haf/trunk/hildon-desktop: . libhildondesktop src
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Thu Mar 13 14:49:32 EET 2008
- Previous message: [maemo-commits] r15291 - projects/connectivity/bluez-utils-debian/tags
- Next message: [maemo-commits] r15295 - projects/haf/trunk/hildon-help/src
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: lucasr Date: 2008-03-13 14:49:30 +0200 (Thu, 13 Mar 2008) New Revision: 15293 Modified: projects/haf/trunk/hildon-desktop/ChangeLog projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-item.c projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-item.h projects/haf/trunk/hildon-desktop/src/hd-config.h projects/haf/trunk/hildon-desktop/src/hd-plugin-loader-default.c projects/haf/trunk/hildon-desktop/src/hd-plugin-manager.c Log: 2008-03-13 Lucas Rocha <lucas.rocha at nokia.com> Added support for having several instances of the same type of plugins with different configuration or content. * src/hd-config.h: added entries for new keys X-Temporary and X-Resource. * src/hd-plugin-manager.c (hd_plugin_manager_sync): check if the plugins is marked as temporary. Is so, remove the .desktop accordingly. * src/hd-plugin-loader-default.c (hd_plugin_loader_default_open_module): load resource and temporary keys into respective object properties for future usage. * libhildondesktop/hildon-desktop-item.[ch] (hildon_desktop_item_get_resource): accessor method for plugin's resource. (hildon_desktop_home_class_init, hildon_desktop_item_get_property, hildon_desktop_item_set_property): new GObject properties "resource" and "temporary". The former to be used by plugins to identify what content/configuration should be used/considered for each instance. The latter to mark plugins as temporary (.desktop is removed is the plugin is unloaded). Modified: projects/haf/trunk/hildon-desktop/ChangeLog =================================================================== --- projects/haf/trunk/hildon-desktop/ChangeLog 2008-03-12 14:37:11 UTC (rev 15292) +++ projects/haf/trunk/hildon-desktop/ChangeLog 2008-03-13 12:49:30 UTC (rev 15293) @@ -1,3 +1,25 @@ +2008-03-13 Lucas Rocha <lucas.rocha at nokia.com> + + Added support for having several instances of the same type of plugins + with different configuration or content. + + * src/hd-config.h: added entries for new keys X-Temporary and + X-Resource. + * src/hd-plugin-manager.c (hd_plugin_manager_sync): check if the + plugins is marked as temporary. Is so, remove the .desktop + accordingly. + * src/hd-plugin-loader-default.c + (hd_plugin_loader_default_open_module): load resource and temporary + keys into respective object properties for future usage. + * libhildondesktop/hildon-desktop-item.[ch] + (hildon_desktop_item_get_resource): accessor method for plugin's resource. + (hildon_desktop_home_class_init, hildon_desktop_item_get_property, + hildon_desktop_item_set_property): new GObject properties "resource" + and "temporary". The former to be used by plugins to identify what + content/configuration should be used/considered for each instance. The + latter to mark plugins as temporary (.desktop is removed is the plugin + is unloaded). + 2008-02-25 Lucas Rocha <lucas.rocha at nokia.com> * src/hd-desktop.c (hd_desktop_plugin_list_to_conf), Modified: projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-item.c =================================================================== --- projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-item.c 2008-03-12 14:37:11 UTC (rev 15292) +++ projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-item.c 2008-03-13 12:49:30 UTC (rev 15293) @@ -41,8 +41,10 @@ { PROP_0, PROP_ID, + PROP_RESOURCE, PROP_NAME, - PROP_MANDATORY + PROP_MANDATORY, + PROP_TEMPORARY }; static gint desktop_signals[N_SIGNALS]; @@ -95,20 +97,36 @@ G_PARAM_CONSTRUCT | G_PARAM_READWRITE)); g_object_class_install_property (object_class, + PROP_RESOURCE, + g_param_spec_string("resource", + "Plugin's related resource", + "Resource reference for the plugin", + NULL, + G_PARAM_READWRITE)); + + g_object_class_install_property (object_class, PROP_NAME, g_param_spec_string("item-name", "Plugin's Name", "Name of the plugin, not widget", "HildonDesktopItem", G_PARAM_CONSTRUCT | G_PARAM_READWRITE)); + g_object_class_install_property (object_class, PROP_MANDATORY, g_param_spec_boolean("mandatory", - "mandatory", - "plugin that cant'be destroyed", + "Mandatory", + "Plugin that cant'be destroyed", FALSE, G_PARAM_CONSTRUCT | G_PARAM_READWRITE)); + g_object_class_install_property (object_class, + PROP_TEMPORARY, + g_param_spec_boolean("temporary", + "Temporary", + "Plugin is temporary", + FALSE, + G_PARAM_CONSTRUCT | G_PARAM_READWRITE)); } static void @@ -117,6 +135,7 @@ g_return_if_fail (item); item->id = NULL; + item->resource = NULL; item->name = NULL; item->geometry.x = item->geometry.y = -1; @@ -182,6 +201,12 @@ item->id = NULL; } + if (item->resource) + { + g_free (item->resource); + item->resource = NULL; + } + if (item->name) { g_free (item->name); @@ -210,6 +235,11 @@ item->id = g_strdup (g_value_get_string (value)); break; + case PROP_RESOURCE: + g_free (item->resource); + item->resource = g_strdup (g_value_get_string (value)); + break; + case PROP_NAME: g_free (item->name); item->name = g_strdup (g_value_get_string (value)); @@ -219,6 +249,10 @@ item->mandatory = g_value_get_boolean (value); break; + case PROP_TEMPORARY: + item->temporary = g_value_get_boolean (value); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -243,6 +277,10 @@ g_value_set_string (value,item->id); break; + case PROP_RESOURCE: + g_value_set_string (value,item->resource); + break; + case PROP_NAME: g_value_set_string (value,item->name); break; @@ -250,7 +288,11 @@ case PROP_MANDATORY: g_value_set_boolean (value,item->mandatory); break; - + + case PROP_TEMPORARY: + g_value_set_boolean (value,item->temporary); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -289,6 +331,22 @@ } /** + * hildon_desktop_item_get_resource: + * @item: a #HildonDesktopItem + * @returns: the item's resource + * + * Returns a #HildonDesktopItem 's resource. The resource is used + * internally to the plugin as content input. + **/ +const gchar * +hildon_desktop_item_get_resource (HildonDesktopItem *item) +{ + g_return_val_if_fail (item && HILDON_DESKTOP_IS_ITEM (item),NULL); + + return item->resource; +} + +/** * hildon_desktop_item_get_name: * @item: a #HildonDesktopItem * @returns: the item's name Modified: projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-item.h =================================================================== --- projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-item.h 2008-03-12 14:37:11 UTC (rev 15292) +++ projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-item.h 2008-03-13 12:49:30 UTC (rev 15293) @@ -47,9 +47,13 @@ gchar *id; + gchar *resource; + gchar *name; gboolean mandatory; + + gboolean temporary; GdkRectangle geometry; }; @@ -63,17 +67,19 @@ gchar *(*get_name) (HildonDesktopItem *item); }; -GType hildon_desktop_item_get_type (void); +GType hildon_desktop_item_get_type (void); -GtkWidget* hildon_desktop_item_get_widget (HildonDesktopItem *item); +GtkWidget* hildon_desktop_item_get_widget (HildonDesktopItem *item); -const gchar* hildon_desktop_item_get_id (HildonDesktopItem *item); +const gchar* hildon_desktop_item_get_id (HildonDesktopItem *item); -const gchar* hildon_desktop_item_get_name (HildonDesktopItem *item); +const gchar* hildon_desktop_item_get_resource (HildonDesktopItem *item); -gint hildon_desktop_item_find_by_id (HildonDesktopItem *item, - const gchar *id); +const gchar* hildon_desktop_item_get_name (HildonDesktopItem *item); +gint hildon_desktop_item_find_by_id (HildonDesktopItem *item, + const gchar *id); + typedef GtkWidget *(*HildonDesktopItemSettingsDialog) (GModule *module); G_END_DECLS Modified: projects/haf/trunk/hildon-desktop/src/hd-config.h =================================================================== --- projects/haf/trunk/hildon-desktop/src/hd-config.h 2008-03-12 14:37:11 UTC (rev 15292) +++ projects/haf/trunk/hildon-desktop/src/hd-config.h 2008-03-13 12:49:30 UTC (rev 15293) @@ -55,10 +55,12 @@ #define HD_PLUGIN_CONFIG_GROUP "Desktop Entry" #define HD_PLUGIN_CONFIG_KEY_NAME "Name" +#define HD_PLUGIN_CONFIG_KEY_RESOURCE "X-Resource" #define HD_PLUGIN_CONFIG_KEY_TYPE "Type" #define HD_PLUGIN_CONFIG_KEY_PATH "X-Path" #define HD_PLUGIN_CONFIG_KEY_TEXT_DOMAIN "X-Text-Domain" #define HD_PLUGIN_CONFIG_KEY_MANDATORY "Mandatory" +#define HD_PLUGIN_CONFIG_KEY_TEMPORARY "X-Temporary" #define HD_PLUGIN_CONFIG_KEY_HOME_APPLET "X-home-applet" #define HD_PLUGIN_CONFIG_KEY_HOME_APPLET_RESIZABLE "X-home-applet-resizable" Modified: projects/haf/trunk/hildon-desktop/src/hd-plugin-loader-default.c =================================================================== --- projects/haf/trunk/hildon-desktop/src/hd-plugin-loader-default.c 2008-03-12 14:37:11 UTC (rev 15292) +++ projects/haf/trunk/hildon-desktop/src/hd-plugin-loader-default.c 2008-03-13 12:49:30 UTC (rev 15293) @@ -53,7 +53,9 @@ GError *keyfile_error = NULL; gchar *module_file = NULL; gchar *module_path = NULL; + gchar *resource = NULL; gboolean mandatory; + gboolean temporary; g_return_val_if_fail (HD_IS_PLUGIN_LOADER_DEFAULT (loader), NULL); @@ -73,6 +75,17 @@ return NULL; } + resource = g_key_file_get_string (keyfile, + HD_PLUGIN_CONFIG_GROUP, + HD_PLUGIN_CONFIG_KEY_RESOURCE, + &keyfile_error); + + if (keyfile_error) + { + g_error_free (keyfile_error); + keyfile_error = NULL; + } + mandatory = g_key_file_get_boolean (keyfile, HD_PLUGIN_CONFIG_GROUP, HD_PLUGIN_CONFIG_KEY_MANDATORY, @@ -85,6 +98,18 @@ keyfile_error = NULL; } + temporary = g_key_file_get_boolean (keyfile, + HD_PLUGIN_CONFIG_GROUP, + HD_PLUGIN_CONFIG_KEY_TEMPORARY, + &keyfile_error); + + if (keyfile_error) + { + temporary = FALSE; + g_error_free (keyfile_error); + keyfile_error = NULL; + } + if (g_path_is_absolute (module_file)) { module_path = module_file; @@ -120,10 +145,15 @@ for (l = objects; l != NULL; l = g_list_next (l)) if (HILDON_DESKTOP_IS_ITEM (l->data)) - g_object_set (G_OBJECT (l->data), "mandatory", mandatory, NULL); + g_object_set (G_OBJECT (l->data), + "resource", resource, + "mandatory", mandatory, + "temporary", temporary, + NULL); g_type_module_unuse (G_TYPE_MODULE (plugin)); + g_free (resource); g_free (module_path); return objects; Modified: projects/haf/trunk/hildon-desktop/src/hd-plugin-manager.c =================================================================== --- projects/haf/trunk/hildon-desktop/src/hd-plugin-manager.c 2008-03-12 14:37:11 UTC (rev 15292) +++ projects/haf/trunk/hildon-desktop/src/hd-plugin-manager.c 2008-03-13 12:49:30 UTC (rev 15293) @@ -28,6 +28,7 @@ #include <gtk/gtk.h> #include <glib.h> +#include <glib/gstdio.h> #include <glib-object.h> #include <libhildondesktop/hildon-desktop-container.h> @@ -319,9 +320,24 @@ /* Destroy plugins that are not used anymore */ for (iter = children; iter; iter = g_list_next (iter)) { + gchar *desktop_file; + gboolean temporary; + + g_object_get (G_OBJECT (iter->data), + "id", &desktop_file, + "temporary", &temporary, + NULL); + gtk_widget_destroy (GTK_WIDGET (iter->data)); if (keep_order) g_object_unref (iter->data); + + if (temporary && g_file_test (desktop_file, G_FILE_TEST_EXISTS)) + { + g_unlink (desktop_file); + } + + g_free (desktop_file); } g_list_foreach (f_plugin_list, (GFunc) g_free, NULL);
- Previous message: [maemo-commits] r15291 - projects/connectivity/bluez-utils-debian/tags
- Next message: [maemo-commits] r15295 - projects/haf/trunk/hildon-help/src
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]