[maemo-commits] [maemo-commits] r8405 - in projects/haf/branches/hildon-control-panel/refactoring: . src
From: www-data at stage.maemo.org www-data at stage.maemo.orgDate: Tue Nov 28 13:31:07 EET 2006
- Previous message: [maemo-commits] r8404 - in projects/haf/trunk/libsdl1.2: debian src/events src/video src/video/dga src/video/directfb src/video/fbcon src/video/x11
- Next message: [maemo-commits] r8406 - projects/haf/branches/hildon-control-panel/refactoring
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: lucasr Date: 2006-11-28 13:31:05 +0200 (Tue, 28 Nov 2006) New Revision: 8405 Modified: projects/haf/branches/hildon-control-panel/refactoring/ChangeLog projects/haf/branches/hildon-control-panel/refactoring/src/hcp-app-list.c projects/haf/branches/hildon-control-panel/refactoring/src/hcp-app-view.c projects/haf/branches/hildon-control-panel/refactoring/src/hcp-app.c projects/haf/branches/hildon-control-panel/refactoring/src/hcp-grid.c projects/haf/branches/hildon-control-panel/refactoring/src/hcp-main.c projects/haf/branches/hildon-control-panel/refactoring/src/hcp-program.c projects/haf/branches/hildon-control-panel/refactoring/src/hcp-rfs.c projects/haf/branches/hildon-control-panel/refactoring/src/hcp-window.c Log: 2006-11-28 Lucas Rocha <lucas.rocha at nokia.com> * src/*.[ch]: general code cleanups, improve code reliability, fix some GObject leaks. Modified: projects/haf/branches/hildon-control-panel/refactoring/ChangeLog =================================================================== --- projects/haf/branches/hildon-control-panel/refactoring/ChangeLog 2006-11-28 10:26:54 UTC (rev 8404) +++ projects/haf/branches/hildon-control-panel/refactoring/ChangeLog 2006-11-28 11:31:05 UTC (rev 8405) @@ -1,3 +1,8 @@ +2006-11-28 Lucas Rocha <lucas.rocha at nokia.com> + + * src/*.[ch]: general code cleanups, improve code reliability, fix + some GObject leaks. + 2006-11-23 Lucas Rocha <lucas.rocha at nokia.com> * src/hcp-grid.c: fix warnings when icon default icon is used. Modified: projects/haf/branches/hildon-control-panel/refactoring/src/hcp-app-list.c =================================================================== --- projects/haf/branches/hildon-control-panel/refactoring/src/hcp-app-list.c 2006-11-28 10:26:54 UTC (rev 8404) +++ projects/haf/branches/hildon-control-panel/refactoring/src/hcp-app-list.c 2006-11-28 11:31:05 UTC (rev 8405) @@ -24,7 +24,6 @@ #include <string.h> -#include <osso-log.h> #include <libosso.h> #include <hildon-base-lib/hildon-base-dnotify.h> @@ -43,16 +42,17 @@ typedef enum { - HCP_APP_LIST_SIGNAL_UPDATED, - HCP_APP_LIST_SIGNALS + SIGNAL_UPDATED, + N_SIGNALS } HCPAppListSignals; -static gint hcp_app_list_signals[HCP_APP_LIST_SIGNALS]; +static gint signals[N_SIGNALS]; enum { - HCP_APP_LIST_PROP_APPS = 1, - HCP_APP_LIST_PROP_CATEGORIES, + PROP_0, + PROP_APPS, + PROP_CATEGORIES, }; struct _HCPAppListPrivate @@ -80,7 +80,7 @@ hcp_app_list_update (al); g_signal_emit (G_OBJECT (al), - hcp_app_list_signals[HCP_APP_LIST_SIGNAL_UPDATED], + signals[SIGNAL_UPDATED], 0, NULL); return FALSE; @@ -102,6 +102,10 @@ { hildon_return_t ret; + g_return_val_if_fail (al, HILDON_ERR); + g_return_val_if_fail (HCP_IS_APP_LIST (al), HILDON_ERR); + g_return_val_if_fail (path, HILDON_ERR); + ret = hildon_dnotify_handler_init (); if (ret != HILDON_OK) @@ -124,6 +128,7 @@ static void hcp_app_list_get_configured_categories (HCPAppList *al) { + HCPAppListPrivate *priv; GConfClient *client = NULL; GSList *group_names = NULL; GSList *group_names_i = NULL; @@ -131,18 +136,26 @@ GSList *group_ids_i = NULL; GError *error = NULL; + g_return_if_fail (al); + g_return_if_fail (HCP_IS_APP_LIST (al)); + + priv = HCP_APP_LIST_GET_PRIVATE (al); + client = gconf_client_get_default (); if (client) { /* Get the group names */ group_names = gconf_client_get_list (client, - HCP_GCONF_GROUPS_KEY, - GCONF_VALUE_STRING, &error); + HCP_GCONF_GROUPS_KEY, + GCONF_VALUE_STRING, + &error); if (error) { - ULOG_ERR (error->message); + g_warning ("Error reading categories names from GConf: %s", + error->message); + g_error_free (error); g_object_unref (client); @@ -151,12 +164,14 @@ /* Get the group ids */ group_ids = gconf_client_get_list (client, - HCP_GCONF_GROUP_IDS_KEY, - GCONF_VALUE_STRING, &error); + HCP_GCONF_GROUP_IDS_KEY, + GCONF_VALUE_STRING, &error); if (error) { - ULOG_ERR (error->message); + g_warning ("Error reading categories ids from GConf: %s", + error->message); + g_error_free (error); g_object_unref (client); @@ -177,7 +192,7 @@ category->name = (gchar *) group_names_i->data; category->apps = NULL; - al->priv->categories = g_slist_append (al->priv->categories, category); + priv->categories = g_slist_append (priv->categories, category); group_ids_i = g_slist_next (group_ids_i); group_names_i = g_slist_next (group_names_i); @@ -251,14 +266,12 @@ static void hcp_app_list_finalize (GObject *object) { - HCPAppList *al; HCPAppListPrivate *priv; - g_return_if_fail (object != NULL); + g_return_if_fail (object); g_return_if_fail (HCP_IS_APP_LIST (object)); - al = HCP_APP_LIST (object); - priv = al->priv; + priv = HCP_APP_LIST_GET_PRIVATE (object); if (priv->apps != NULL) { @@ -271,6 +284,8 @@ g_slist_foreach (priv->categories, (GFunc) hcp_app_list_free_category, NULL); g_slist_free (priv->categories); } + + G_OBJECT_CLASS (hcp_app_list_parent_class)->finalize (object); } static void @@ -279,17 +294,18 @@ GValue *value, GParamSpec *pspec) { + HCPAppListPrivate *priv; - HCPAppList *al = HCP_APP_LIST (gobject); + priv = HCP_APP_LIST_GET_PRIVATE (gobject); switch (prop_id) { - case HCP_APP_LIST_PROP_APPS: - g_value_set_pointer (value, al->priv->apps); + case PROP_APPS: + g_value_set_pointer (value, priv->apps); break; - case HCP_APP_LIST_PROP_CATEGORIES: - g_value_set_pointer (value, al->priv->categories); + case PROP_CATEGORIES: + g_value_set_pointer (value, priv->categories); break; default: @@ -307,7 +323,7 @@ g_object_class->get_property = hcp_app_list_get_property; - hcp_app_list_signals[HCP_APP_LIST_SIGNAL_UPDATED] = + signals[SIGNAL_UPDATED] = g_signal_new ("updated", G_OBJECT_CLASS_TYPE (g_object_class), G_SIGNAL_RUN_FIRST, @@ -317,17 +333,17 @@ G_TYPE_NONE, 0); g_object_class_install_property (g_object_class, - HCP_APP_LIST_PROP_APPS, + PROP_APPS, g_param_spec_pointer ("apps", "Apps", - "Set app list", + "App List", G_PARAM_READABLE)); g_object_class_install_property (g_object_class, - HCP_APP_LIST_PROP_CATEGORIES, + PROP_CATEGORIES, g_param_spec_pointer ("categories", "Categories", - "Set categories list", + "Categories List", G_PARAM_READABLE)); g_type_class_add_private (g_object_class, sizeof (HCPAppListPrivate)); @@ -336,20 +352,23 @@ static void hcp_app_list_read_desktop_entries (HCPAppList *al, const gchar *dir_path) { + HCPAppListPrivate *priv; GDir *dir; GError *error = NULL; const char *filename; GKeyFile *keyfile; - ULOG_DEBUG("hcp-app-list:read_desktop_entries"); + g_return_if_fail (al); + g_return_if_fail (HCP_IS_APP_LIST (al)); + g_return_if_fail (dir_path); - g_return_if_fail (dir_path && al->priv->apps); + priv = HCP_APP_LIST_GET_PRIVATE (al); dir = g_dir_open(dir_path, 0, &error); if (!dir) { - ULOG_ERR (error->message); + g_warning ("Error reading desktop files directory: %s", error->message); g_error_free (error); return; } @@ -377,56 +396,56 @@ if (error) { - ULOG_ERR (error->message); + g_warning ("Error reading applet desktop file: %s", error->message); g_error_free (error); continue; } name = g_key_file_get_locale_string (keyfile, - HCP_DESKTOP_GROUP, - HCP_DESKTOP_KEY_NAME, - NULL /* current locale */, - &error); + HCP_DESKTOP_GROUP, + HCP_DESKTOP_KEY_NAME, + NULL /* current locale */, + &error); if (error) { - ULOG_ERR (error->message); + g_warning ("Error reading applet desktop file: %s", error->message); g_error_free (error); continue; } plugin = g_key_file_get_string (keyfile, - HCP_DESKTOP_GROUP, - HCP_DESKTOP_KEY_PLUGIN, - &error); + HCP_DESKTOP_GROUP, + HCP_DESKTOP_KEY_PLUGIN, + &error); if (error) { - ULOG_ERR (error->message); + g_warning ("Error reading applet desktop file: %s", error->message); g_error_free (error); continue; } icon = g_key_file_get_string (keyfile, - HCP_DESKTOP_GROUP, - HCP_DESKTOP_KEY_ICON, - &error); + HCP_DESKTOP_GROUP, + HCP_DESKTOP_KEY_ICON, + &error); if (error) { - ULOG_WARN (error->message); + g_warning ("Error reading applet desktop file: %s", error->message); g_error_free (error); error = NULL; } category = g_key_file_get_string (keyfile, - HCP_DESKTOP_GROUP, - HCP_DESKTOP_KEY_CATEGORY, - &error); + HCP_DESKTOP_GROUP, + HCP_DESKTOP_KEY_CATEGORY, + &error); if (error) { - ULOG_WARN (error->message); + g_warning ("Error reading applet desktop file: %s", error->message); g_error_free (error); error = NULL; } @@ -440,7 +459,7 @@ "category", category, NULL); - g_hash_table_insert (al->priv->apps, g_strdup (plugin), app); + g_hash_table_insert (priv->apps, g_strdup (plugin), app); g_free (name); g_free (plugin); @@ -453,10 +472,10 @@ } static gint -hcp_app_list_find_category (gpointer _category, gpointer _app) +hcp_app_list_find_category (gpointer a, gpointer b) { - HCPCategory *category = (HCPCategory *) _category; - HCPApp *app = (HCPApp *) _app; + HCPCategory *category = (HCPCategory *) a; + HCPApp *app = (HCPApp *) b; gchar *category_id = NULL; g_object_get (G_OBJECT (app), @@ -464,7 +483,7 @@ NULL); if (category_id && category->id && - !strcmp (category_id, category->id)) + !g_ascii_strcasecmp (category_id, category->id)) { g_free (category_id); return 0; @@ -476,15 +495,23 @@ } static void -hcp_app_list_sort_by_category (gpointer key, gpointer value, gpointer _al) +hcp_app_list_sort_by_category (gpointer key, gpointer value, gpointer user_data) { - HCPAppList *al = (HCPAppList *) _al; - GSList *category_item = NULL; + HCPAppListPrivate *priv; + HCPAppList *al = (HCPAppList *) user_data; HCPApp *app = (HCPApp *) value; HCPCategory *category; + GSList *category_item = NULL; + g_return_if_fail (al); + g_return_if_fail (HCP_IS_APP_LIST (al)); + g_return_if_fail (app); + g_return_if_fail (HCP_IS_APP (app)); + + priv = HCP_APP_LIST_GET_PRIVATE (al); + /* Find a category for this applet */ - category_item = g_slist_find_custom (al->priv->categories, + category_item = g_slist_find_custom (priv->categories, app, (GCompareFunc) hcp_app_list_find_category); @@ -496,36 +523,43 @@ { /* If category doesn't exist or wasn't matched, * add to the default one (Extra) */ - category = g_slist_last (al->priv->categories)->data; + category = g_slist_last (priv->categories)->data; } - + category->apps = g_slist_insert_sorted ( category->apps, app, (GCompareFunc) hcp_app_sort_func); } +GObject * +hcp_app_list_new () +{ + GObject *al = g_object_new (HCP_TYPE_APP_LIST, NULL); + + return al; +} + void hcp_app_list_update (HCPAppList *al) { + HCPAppListPrivate *priv; + + g_return_if_fail (al); + g_return_if_fail (HCP_IS_APP_LIST (al)); + + priv = HCP_APP_LIST_GET_PRIVATE (al); + /* Clean the previous list */ - g_hash_table_foreach_remove (al->priv->apps, (GHRFunc) hcp_app_list_free_app, NULL); + g_hash_table_foreach_remove (priv->apps, (GHRFunc) hcp_app_list_free_app, NULL); /* Read all the entries */ hcp_app_list_read_desktop_entries (al, CONTROLPANEL_ENTRY_DIR); /* Place them is the relevant category */ - g_slist_foreach (al->priv->categories, (GFunc) hcp_app_list_empty_category, NULL); + g_slist_foreach (priv->categories, (GFunc) hcp_app_list_empty_category, NULL); - g_hash_table_foreach (al->priv->apps, + g_hash_table_foreach (priv->apps, (GHFunc) hcp_app_list_sort_by_category, al); } - -GObject * -hcp_app_list_new () -{ - GObject *al = g_object_new (HCP_TYPE_APP_LIST, NULL); - - return al; -} Modified: projects/haf/branches/hildon-control-panel/refactoring/src/hcp-app-view.c =================================================================== --- projects/haf/branches/hildon-control-panel/refactoring/src/hcp-app-view.c 2006-11-28 10:26:54 UTC (rev 8404) +++ projects/haf/branches/hildon-control-panel/refactoring/src/hcp-app-view.c 2006-11-28 11:31:05 UTC (rev 8405) @@ -22,8 +22,6 @@ * */ -#include <osso-log.h> - #include <glib/gi18n.h> #include "hcp-app-view.h" @@ -39,11 +37,11 @@ typedef enum { - HCP_APP_VIEW_SIGNAL_FOCUS_CHANGED, - HCP_APP_VIEW_SIGNALS + SIGNAL_FOCUS_CHANGED, + N_SIGNALS } HCPAppViewSignals; -static gint hcp_app_view_signals[HCP_APP_VIEW_SIGNALS]; +static gint signals[N_SIGNALS]; enum { @@ -106,7 +104,8 @@ GtkTreeIter iter; gint item_pos; - g_return_val_if_fail (widget != NULL, NULL); + g_return_val_if_fail (widget, NULL); + g_return_val_if_fail (GTK_IS_ICON_VIEW (widget), NULL); model = gtk_icon_view_get_model (GTK_ICON_VIEW (widget)); @@ -176,7 +175,7 @@ } g_signal_emit (G_OBJECT (widget->parent), - hcp_app_view_signals[HCP_APP_VIEW_SIGNAL_FOCUS_CHANGED], + signals[SIGNAL_FOCUS_CHANGED], 0, app); } @@ -278,13 +277,14 @@ GValue *value, GParamSpec *pspec) { + HCPAppViewPrivate *priv; - HCPAppView *view = HCP_APP_VIEW (gobject); + priv = HCP_APP_VIEW_GET_PRIVATE (gobject); switch (prop_id) { case PROP_ICON_SIZE: - g_value_set_int (value, view->priv->icon_size); + g_value_set_int (value, priv->icon_size); break; default: @@ -299,12 +299,14 @@ const GValue *value, GParamSpec *pspec) { - HCPAppView *view = HCP_APP_VIEW (gobject); + HCPAppViewPrivate *priv; + + priv = HCP_APP_VIEW_GET_PRIVATE (gobject); switch (prop_id) { case PROP_ICON_SIZE: - view->priv->icon_size = g_value_get_int (value); + priv->icon_size = g_value_get_int (value); break; default: @@ -321,6 +323,16 @@ g_object_class->get_property = hcp_app_view_get_property; g_object_class->set_property = hcp_app_view_set_property; + signals[SIGNAL_FOCUS_CHANGED] = + g_signal_new ("focus-changed", + G_OBJECT_CLASS_TYPE (g_object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (HCPAppViewClass, focus_changed), + NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, + HCP_TYPE_APP); + g_object_class_install_property (g_object_class, PROP_ICON_SIZE, g_param_spec_int ("icon-size", @@ -333,16 +345,6 @@ G_PARAM_WRITABLE | G_PARAM_CONSTRUCT))); - hcp_app_view_signals[HCP_APP_VIEW_SIGNAL_FOCUS_CHANGED] = - g_signal_new ("focus-changed", - G_OBJECT_CLASS_TYPE (g_object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (HCPAppViewClass, focus_changed), - NULL, NULL, - g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, 1, - HCP_TYPE_APP); - g_type_class_add_private (g_object_class, sizeof (HCPAppViewPrivate)); } @@ -359,8 +361,16 @@ void hcp_app_view_populate (HCPAppView *view, HCPAppList *al) { + HCPAppViewPrivate *priv; GSList *categories = NULL; + g_return_if_fail (view); + g_return_if_fail (HCP_IS_APP_VIEW (view)); + g_return_if_fail (al); + g_return_if_fail (HCP_IS_APP_LIST (al)); + + priv = HCP_APP_VIEW_GET_PRIVATE (view); + g_object_get (G_OBJECT (al), "categories", &categories, NULL); @@ -369,7 +379,7 @@ (GtkCallback) gtk_widget_destroy, NULL); - view->priv->first_grid = NULL; + priv->first_grid = NULL; gtk_container_set_focus_chain (GTK_CONTAINER (view), NULL); @@ -377,13 +387,13 @@ (GFunc) hcp_app_view_add_category, view); - hcp_app_view_set_icon_size (GTK_WIDGET (view), view->priv->icon_size); + hcp_app_view_set_icon_size (GTK_WIDGET (view), priv->icon_size); /* Put focus on the first item of the first grid */ if (view->priv->first_grid) { - gtk_widget_grab_focus (view->priv->first_grid); - gtk_icon_view_select_path (GTK_ICON_VIEW (view->priv->first_grid), + gtk_widget_grab_focus (priv->first_grid); + gtk_icon_view_select_path (GTK_ICON_VIEW (priv->first_grid), gtk_tree_path_new_first ()); } } @@ -395,6 +405,9 @@ GList *iter = NULL; GList *list = NULL; + g_return_if_fail (view); + g_return_if_fail (HCP_IS_APP_VIEW (view)); + list = iter = gtk_container_get_children (GTK_CONTAINER (view)); /* Iterate through all of them and set their mode */ Modified: projects/haf/branches/hildon-control-panel/refactoring/src/hcp-app.c =================================================================== --- projects/haf/branches/hildon-control-panel/refactoring/src/hcp-app.c 2006-11-28 10:26:54 UTC (rev 8404) +++ projects/haf/branches/hildon-control-panel/refactoring/src/hcp-app.c 2006-11-28 11:31:05 UTC (rev 8405) @@ -25,8 +25,6 @@ #include <dlfcn.h> #include <string.h> -#include <osso-log.h> - #include <glib.h> #include <glib/gi18n.h> #include <gtk/gtk.h> @@ -73,7 +71,7 @@ { HCPApp *app; HCPPlugin *plugin; - gboolean user_activated; + gboolean user_activated; } PluginLaunchData; #define HCP_PLUGIN_EXEC_SYMBOL "execute" @@ -98,17 +96,23 @@ hcp_app_load (HCPApp *app, HCPPlugin *plugin) { gchar *plugin_path = NULL; + HCPAppPrivate *priv; - g_return_if_fail (app && app->priv->plugin); + g_return_if_fail (app); + g_return_if_fail (HCP_IS_APP (app)); - if (*app->priv->plugin == G_DIR_SEPARATOR) + priv = HCP_APP_GET_PRIVATE (app); + + g_return_if_fail (priv->plugin); + + if (*priv->plugin == G_DIR_SEPARATOR) { /* .desktop provided fullpath, use that */ - plugin_path = g_strdup (app->priv->plugin); + plugin_path = g_strdup (priv->plugin); } else { - plugin_path = g_build_filename (HCP_PLUGIN_DIR, app->priv->plugin, NULL); + plugin_path = g_build_filename (HCP_PLUGIN_DIR, priv->plugin, NULL); } plugin->handle = dlopen (plugin_path, RTLD_LAZY); @@ -117,9 +121,9 @@ if (!plugin->handle) { - ULOG_ERR ("Could not load hildon-control-panel applet %s: %s", - app->priv->plugin, - dlerror()); + g_warning ("Could not load hildon-control-panel applet %s: %s", + priv->plugin, + dlerror()); return; } @@ -127,53 +131,67 @@ if (!plugin->exec) { - ULOG_ERR ("Could not find "HCP_PLUGIN_SYMBOL" symbol in " - "hildon-control-panel applet %s: %s", - app->priv->plugin, - dlerror ()); + g_warning ("Could not find "HCP_PLUGIN_EXEC_SYMBOL" symbol in " + "hildon-control-panel applet %s: %s", + priv->plugin, + dlerror ()); dlclose (plugin->handle); plugin->handle = NULL; } - app->priv->save_state = dlsym (plugin->handle, HCP_PLUGIN_SAVE_STATE_SYMBOL); + priv->save_state = dlsym (plugin->handle, HCP_PLUGIN_SAVE_STATE_SYMBOL); } static void -hcp_app_unload (HCPApp *item, HCPPlugin *plugin) +hcp_app_unload (HCPApp *app, HCPPlugin *plugin) { - g_return_if_fail (plugin->handle); + HCPAppPrivate *priv; - if (dlclose (plugin->handle)) - { - ULOG_ERR ("An error occurred when unloading hildon-control-panel " - "applet %s: %s", - app->priv->plugin, - dlerror ()); - } + g_return_if_fail (app); + g_return_if_fail (HCP_IS_APP (app)); + g_return_if_fail (plugin->handle); + + priv = HCP_APP_GET_PRIVATE (app); + + if (dlclose (plugin->handle)) + { + g_warning ("An error occurred when unloading hildon-control-panel " + "applet %s: %s", + priv->plugin, + dlerror ()); + } } static gboolean hcp_app_idle_launch (PluginLaunchData *d) { HCPPlugin *p; + HCPAppPrivate *priv; HCPProgram *program = hcp_program_get_instance (); + + g_return_val_if_fail (d, FALSE); + g_return_val_if_fail (d->app, FALSE); + g_return_val_if_fail (HCP_IS_APP (d->app), FALSE); + + priv = HCP_APP_GET_PRIVATE (d->app); p = g_new0 (HCPPlugin, 1); hcp_app_load (d->app, p); - + if (!p->handle) goto cleanup; - - d->app->priv->is_running = TRUE; + priv->is_running = TRUE; + /* Always use hcp->window as parent. If CP is launched without * UI (run_applet RPC) the applet's dialog will be system modal */ p->exec (program->osso, program->window, d->user_activated); - d->app->priv->is_running = FALSE; + priv->is_running = FALSE; + program->execute = 0; hcp_app_unload (d->app, p); @@ -197,11 +215,11 @@ HCPApp *app; HCPAppPrivate *priv; - g_return_if_fail (object != NULL); + g_return_if_fail (object); g_return_if_fail (HCP_IS_APP (object)); app = HCP_APP (object); - priv = app->priv; + priv = HCP_APP_GET_PRIVATE (app); if (priv->name != NULL) { @@ -242,37 +260,38 @@ GValue *value, GParamSpec *pspec) { + HCPAppPrivate *priv; - HCPApp *app = HCP_APP (gobject); + priv = HCP_APP_GET_PRIVATE (gobject); switch (prop_id) { case PROP_NAME: - g_value_set_string (value, app->priv->name); + g_value_set_string (value, priv->name); break; case PROP_PLUGIN: - g_value_set_string (value, app->priv->plugin); + g_value_set_string (value, priv->plugin); break; case PROP_ICON: - g_value_set_string (value, app->priv->icon); + g_value_set_string (value, priv->icon); break; case PROP_CATEGORY: - g_value_set_string (value, app->priv->category); + g_value_set_string (value, priv->category); break; case PROP_IS_RUNNING: - g_value_set_boolean (value, app->priv->is_running); + g_value_set_boolean (value, priv->is_running); break; case PROP_GRID: - g_value_set_object (value, app->priv->grid); + g_value_set_object (value, priv->grid); break; case PROP_ITEM_POS: - g_value_set_int (value, app->priv->item_pos); + g_value_set_int (value, priv->item_pos); break; default: @@ -287,42 +306,44 @@ const GValue *value, GParamSpec *pspec) { - HCPApp *app = HCP_APP (gobject); + HCPAppPrivate *priv; + + priv = HCP_APP_GET_PRIVATE (gobject); switch (prop_id) { case PROP_NAME: - g_free (app->priv->name); - app->priv->name = g_strdup (g_value_get_string (value)); + g_free (priv->name); + priv->name = g_strdup (g_value_get_string (value)); break; case PROP_PLUGIN: - g_free (app->priv->plugin); - app->priv->plugin = g_strdup (g_value_get_string (value)); + g_free (priv->plugin); + priv->plugin = g_strdup (g_value_get_string (value)); break; case PROP_ICON: - g_free (app->priv->icon); - app->priv->icon = g_strdup (g_value_get_string (value)); + g_free (priv->icon); + priv->icon = g_strdup (g_value_get_string (value)); break; case PROP_CATEGORY: - g_free (app->priv->category); - app->priv->category = g_strdup (g_value_get_string (value)); + g_free (priv->category); + priv->category = g_strdup (g_value_get_string (value)); break; case PROP_IS_RUNNING: - app->priv->is_running = g_value_get_boolean (value); + priv->is_running = g_value_get_boolean (value); break; case PROP_GRID: - if (app->priv->grid) - g_object_unref (app->priv->grid); - app->priv->grid = g_object_ref (g_value_get_object (value)); + if (priv->grid) + g_object_unref (priv->grid); + priv->grid = g_object_ref (g_value_get_object (value)); break; case PROP_ITEM_POS: - app->priv->item_pos = g_value_get_int (value); + priv->item_pos = g_value_get_int (value); break; default: @@ -416,6 +437,9 @@ PluginLaunchData *d; HCPProgram *program = hcp_program_get_instance (); + g_return_if_fail (app); + g_return_if_fail (HCP_IS_APP (app)); + if (!program->execute) { program->execute = 1; @@ -434,13 +458,20 @@ void hcp_app_focus (HCPApp *app) { - if (app->priv->grid) + HCPAppPrivate *priv; + + g_return_if_fail (app); + g_return_if_fail (HCP_IS_APP (app)); + + priv = HCP_APP_GET_PRIVATE (app); + + if (priv->grid) { GtkTreePath *path; - gtk_widget_grab_focus (app->priv->grid); - path = gtk_tree_path_new_from_indices (app->priv->item_pos, -1); - gtk_icon_view_select_path (GTK_ICON_VIEW (app->priv->grid), path); + gtk_widget_grab_focus (priv->grid); + path = gtk_tree_path_new_from_indices (priv->item_pos, -1); + gtk_icon_view_select_path (GTK_ICON_VIEW (priv->grid), path); gtk_tree_path_free (path); } } @@ -448,22 +479,42 @@ void hcp_app_save_state (HCPApp *app) { + HCPAppPrivate *priv; HCPProgram *program = hcp_program_get_instance (); - if (app->priv->save_state) - app->priv->save_state (program->osso, NULL /* What is expected here? -- Jobi */); + g_return_if_fail (app); + g_return_if_fail (HCP_IS_APP (app)); + + priv = HCP_APP_GET_PRIVATE (app); + + if (priv->save_state) + priv->save_state (program->osso, NULL /* What is expected here? -- Jobi */); } gboolean hcp_app_is_running (HCPApp *app) { - return app->priv->is_running; + HCPAppPrivate *priv; + + g_return_val_if_fail (app, FALSE); + g_return_val_if_fail (HCP_IS_APP (app), FALSE); + + priv = HCP_APP_GET_PRIVATE (app); + + return priv->is_running; } gboolean hcp_app_can_save_state (HCPApp *app) { - return (app->priv->save_state == NULL); + HCPAppPrivate *priv; + + g_return_val_if_fail (app, FALSE); + g_return_val_if_fail (HCP_IS_APP (app), FALSE); + + priv = HCP_APP_GET_PRIVATE (app); + + return (priv->save_state == NULL); } gint Modified: projects/haf/branches/hildon-control-panel/refactoring/src/hcp-grid.c =================================================================== --- projects/haf/branches/hildon-control-panel/refactoring/src/hcp-grid.c 2006-11-28 10:26:54 UTC (rev 8404) +++ projects/haf/branches/hildon-control-panel/refactoring/src/hcp-grid.c 2006-11-28 11:31:05 UTC (rev 8405) @@ -23,7 +23,6 @@ #include <math.h> -#include <osso-log.h> #include <hildon-widgets/hildon-defines.h> #include <gtk/gtk.h> @@ -44,12 +43,12 @@ gboolean can_move_focus; gboolean focused_in; HCPIconSize icon_size; - HCPIconSize row_height; + gint row_height; }; enum { - HCP_GRID_FOCUS_FROM_ABOVE = 0, + HCP_GRID_FOCUS_FROM_ABOVE, HCP_GRID_FOCUS_FROM_BELOW, HCP_GRID_FOCUS_FIRST, HCP_GRID_FOCUS_LAST @@ -61,15 +60,18 @@ GtkTreeIter *iter, gpointer user_data) { - HCPGrid *grid; + HCPGridPrivate *priv; HCPApp *app; GtkIconTheme *icon_theme; GdkPixbuf *icon_pixbuf; gchar *icon = NULL; GError *error = NULL; - grid = HCP_GRID (user_data); + g_return_val_if_fail (user_data, TRUE); + g_return_val_if_fail (HCP_IS_GRID (user_data), TRUE); + priv = HCP_GRID_GET_PRIVATE (user_data); + gtk_tree_model_get (GTK_TREE_MODEL (model), iter, HCP_STORE_APP, &app, -1); @@ -82,39 +84,39 @@ icon_pixbuf = gtk_icon_theme_load_icon (icon_theme, icon, - grid->priv->icon_size, + priv->icon_size, 0, &error); if (icon_pixbuf == NULL) { - ULOG_WARN("Couldn't load icon \"%s\": %s", icon, error->message); + g_warning ("Couldn't load icon \"%s\": %s", icon, error->message); g_error_free (error); error = NULL; icon_pixbuf = gtk_icon_theme_load_icon (icon_theme, HCP_DEFAULT_ICON_BASENAME, - grid->priv->icon_size, + priv->icon_size, 0, &error); if (icon_pixbuf == NULL) { - ULOG_WARN("Couldn't load default icon: %s!", error->message); + g_warning ("Couldn't load default icon: %s", error->message); g_error_free (error); } } - if (grid->priv->row_height == -1) + if (priv->row_height == -1) { - if (grid->priv->icon_size == HCP_ICON_SIZE_SMALL) + if (priv->icon_size == HCP_ICON_SIZE_SMALL) { - grid->priv->row_height = gdk_pixbuf_get_height (icon_pixbuf) + 10; + priv->row_height = gdk_pixbuf_get_height (icon_pixbuf) + 10; } - else if (grid->priv->icon_size == HCP_ICON_SIZE_LARGE) + else if (priv->icon_size == HCP_ICON_SIZE_LARGE) { - grid->priv->row_height = gdk_pixbuf_get_height (icon_pixbuf) + 2; + priv->row_height = gdk_pixbuf_get_height (icon_pixbuf) + 2; } } @@ -174,12 +176,16 @@ static void hcp_grid_selection_changed (GtkWidget *widget, gpointer user_data) { + HCPGridPrivate *priv; GtkTreeModel *model; GtkTreePath *path; gint n_items, item_pos, y, last_row; - g_return_if_fail (widget != NULL); + g_return_if_fail (widget); + g_return_if_fail (HCP_IS_GRID (widget)); + priv = HCP_GRID_GET_PRIVATE (widget); + model = gtk_icon_view_get_model (GTK_ICON_VIEW (widget)); n_items = gtk_tree_model_iter_n_children (model, NULL); @@ -191,13 +197,13 @@ y = item_pos / HCP_GRID_NUM_COLUMNS; last_row = ceil ((double) n_items / HCP_GRID_NUM_COLUMNS) - 1; - if ((y == 0 || y == last_row) && !HCP_GRID (widget)->priv->focused_in) + if ((y == 0 || y == last_row) && !priv->focused_in) { - HCP_GRID (widget)->priv->can_move_focus = FALSE; + priv->can_move_focus = FALSE; } - else if (HCP_GRID (widget)->priv->focused_in) + else if (priv->focused_in) { - HCP_GRID (widget)->priv->focused_in = FALSE; + priv->focused_in = FALSE; } gtk_tree_path_free (path); @@ -265,6 +271,8 @@ if (widget == NULL) return; + g_return_if_fail (HCP_IS_GRID (widget)); + model = gtk_icon_view_get_model (GTK_ICON_VIEW (widget)); n_items = gtk_tree_model_iter_n_children (model, NULL); @@ -340,13 +348,17 @@ hcp_grid_keyboard_listener (GtkWidget *widget, GdkEventKey *keyevent) { + HCPGridPrivate *priv; GtkTreeModel *model; GtkTreePath *path; gint n_items, item_pos, last_row, x, y; gboolean result = FALSE; - g_return_val_if_fail (widget != NULL, FALSE); + g_return_val_if_fail (widget, FALSE); + g_return_val_if_fail (HCP_IS_GRID (widget), FALSE); + priv = HCP_GRID_GET_PRIVATE (widget); + model = gtk_icon_view_get_model (GTK_ICON_VIEW (widget)); n_items = gtk_tree_model_iter_n_children (model, NULL); @@ -367,28 +379,28 @@ case HILDON_HARDKEY_UP: if (y == 0) { - if (HCP_GRID (widget)->priv->can_move_focus) + if (priv->can_move_focus) { hcp_grid_select_from_outside (hcp_grid_get_previous (widget), HCP_GRID_FOCUS_FROM_BELOW, x); result = TRUE; } else - HCP_GRID (widget)->priv->can_move_focus = TRUE; + priv->can_move_focus = TRUE; } break; case HILDON_HARDKEY_DOWN: if (y == last_row) { - if (HCP_GRID (widget)->priv->can_move_focus) + if (priv->can_move_focus) { hcp_grid_select_from_outside (hcp_grid_get_next (widget), HCP_GRID_FOCUS_FROM_ABOVE, x); result = TRUE; } else - HCP_GRID (widget)->priv->can_move_focus = TRUE; + priv->can_move_focus = TRUE; } break; @@ -396,8 +408,8 @@ case HILDON_HARDKEY_RIGHT: if (y == 0 || y == last_row) { - if (!HCP_GRID (widget)->priv->can_move_focus) - HCP_GRID (widget)->priv->can_move_focus = TRUE; + if (!priv->can_move_focus) + priv->can_move_focus = TRUE; } break; } @@ -411,19 +423,22 @@ static void hcp_grid_size_request (GtkWidget *widget, GtkRequisition *req) { - HCPGrid *grid; + HCPGridPrivate *priv; GtkTreeModel *store; gint num_items; - grid = HCP_GRID (widget); + g_return_if_fail (widget); + g_return_if_fail (HCP_IS_GRID (widget)); + priv = HCP_GRID_GET_PRIVATE (widget); + store = gtk_icon_view_get_model (GTK_ICON_VIEW (widget)); num_items = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL); if (num_items > 0) { - req->height = (ceil ((double) num_items / HCP_GRID_NUM_COLUMNS)) * grid->priv->row_height; + req->height = (ceil ((double) num_items / HCP_GRID_NUM_COLUMNS)) * priv->row_height; } } @@ -464,6 +479,8 @@ gtk_icon_view_set_columns (GTK_ICON_VIEW (grid), HCP_GRID_NUM_COLUMNS); + /* FIXME: This should not be hardcoded. It should be defined + based on HCPAppView width. */ gtk_icon_view_set_item_width (GTK_ICON_VIEW (grid), 330); g_signal_connect (G_OBJECT (grid), "selection-changed", @@ -486,7 +503,7 @@ GtkTreePath *path; GList *list; - g_return_val_if_fail (grid != NULL, NULL); + g_return_val_if_fail (grid, NULL); g_return_val_if_fail (HCP_IS_GRID (grid), NULL); list = gtk_icon_view_get_selected_items (GTK_ICON_VIEW (grid)); @@ -504,15 +521,18 @@ void hcp_grid_set_icon_size (HCPGrid *grid, HCPIconSize icon_size) { + HCPGridPrivate *priv; GtkTreeModel *model; - g_return_if_fail (grid != NULL); + g_return_if_fail (grid); g_return_if_fail (HCP_IS_GRID (grid)); - grid->priv->icon_size = icon_size; + priv = HCP_GRID_GET_PRIVATE (grid); - grid->priv->row_height = -1; + priv->icon_size = icon_size; + priv->row_height = -1; + model = gtk_icon_view_get_model (GTK_ICON_VIEW (grid)); gtk_tree_model_foreach (model, hcp_grid_update_icon, grid); Modified: projects/haf/branches/hildon-control-panel/refactoring/src/hcp-main.c =================================================================== --- projects/haf/branches/hildon-control-panel/refactoring/src/hcp-main.c 2006-11-28 10:26:54 UTC (rev 8404) +++ projects/haf/branches/hildon-control-panel/refactoring/src/hcp-main.c 2006-11-28 11:31:05 UTC (rev 8405) @@ -36,29 +36,29 @@ int main (int argc, char **argv) { - HCPProgram *program = NULL; + HCPProgram *program = NULL; - setlocale (LC_ALL, ""); + setlocale (LC_ALL, ""); - bindtextdomain (PACKAGE, LOCALEDIR); + bindtextdomain (PACKAGE, LOCALEDIR); - bind_textdomain_codeset (PACKAGE, "UTF-8"); + bind_textdomain_codeset (PACKAGE, "UTF-8"); - textdomain (PACKAGE); + textdomain (PACKAGE); - /* Set application name to "" as we only need - * the window title in the title bar */ - g_set_application_name (""); - - gtk_init (&argc, &argv); + /* Set application name to "" as we only need + * the window title in the title bar */ + g_set_application_name (""); + + gtk_init (&argc, &argv); - program = hcp_program_get_instance (); + program = hcp_program_get_instance (); - hcp_program_run (program); + hcp_program_run (program); - gtk_main(); + gtk_main(); - g_object_unref (program); + g_object_unref (program); - return 0; + return 0; } Modified: projects/haf/branches/hildon-control-panel/refactoring/src/hcp-program.c =================================================================== --- projects/haf/branches/hildon-control-panel/refactoring/src/hcp-program.c 2006-11-28 10:26:54 UTC (rev 8404) +++ projects/haf/branches/hildon-control-panel/refactoring/src/hcp-program.c 2006-11-28 11:31:05 UTC (rev 8405) @@ -187,6 +187,9 @@ static void hcp_program_init_rpc (HCPProgram *program) { + g_return_if_fail (program); + g_return_if_fail (HCP_IS_PROGRAM (program)); + program->osso = osso_initialize (HCP_APP_NAME, HCP_APP_VERSION, TRUE, NULL); if (!program->osso) @@ -203,6 +206,9 @@ static void hcp_program_hw_signal_cb (osso_hw_state_t *state, HCPProgram *program) { + g_return_if_fail (program); + g_return_if_fail (HCP_IS_PROGRAM (program)); + if (state != NULL) { if (state->shutdown_ind) @@ -236,7 +242,7 @@ { HCPProgram *program; - g_return_if_fail (object != NULL); + g_return_if_fail (object); g_return_if_fail (HCP_IS_PROGRAM (object)); program = HCP_PROGRAM (object); @@ -281,6 +287,9 @@ { gboolean dbus_activated; + g_return_if_fail (program); + g_return_if_fail (HCP_IS_PROGRAM (program)); + dbus_activated = g_getenv ("DBUS_STARTER_BUS_TYPE")?TRUE:FALSE; #if 0 Modified: projects/haf/branches/hildon-control-panel/refactoring/src/hcp-rfs.c =================================================================== --- projects/haf/branches/hildon-control-panel/refactoring/src/hcp-rfs.c 2006-11-28 10:26:54 UTC (rev 8404) +++ projects/haf/branches/hildon-control-panel/refactoring/src/hcp-rfs.c 2006-11-28 11:31:05 UTC (rev 8405) @@ -37,14 +37,14 @@ #define HCP_CODE_DIALOG_HELP_TOPIC "Features_restorefactorysettings_passwordquerydialog" -#define HCP_RFS_INFOBANNER_OK _("rfs_bd_ok") -#define HCP_RFS_INFOBANNER_CANCEL _("rfs_bd_cancel") -#define HCP_RFS_IB_WRONG_LOCKCODE dgettext("hildon-libs", "secu_info_incorrectcode") +#define HCP_RFS_INFOBANNER_OK _("rfs_bd_ok") +#define HCP_RFS_INFOBANNER_CANCEL _("rfs_bd_cancel") +#define HCP_RFS_IB_WRONG_LOCKCODE dgettext("hildon-libs", "secu_info_incorrectcode") -#define HCP_MCE_DBUS_SERVICE "com.nokia.mce" -#define HCP_MCE_DBUS_REQUEST_IF "com.nokia.mce.request" -#define HCP_MCE_DBUS_REQUEST_PATH "/com/nokia/mce/request" -#define HCP_MCE_PASSWORD_VALIDATE "validate_devicelock_code" +#define HCP_MCE_DBUS_SERVICE "com.nokia.mce" +#define HCP_MCE_DBUS_REQUEST_IF "com.nokia.mce.request" +#define HCP_MCE_DBUS_REQUEST_PATH "/com/nokia/mce/request" +#define HCP_MCE_PASSWORD_VALIDATE "validate_devicelock_code" #define HCP_DEFAULT_SALT "$1$JE5Gswee$" Modified: projects/haf/branches/hildon-control-panel/refactoring/src/hcp-window.c =================================================================== --- projects/haf/branches/hildon-control-panel/refactoring/src/hcp-window.c 2006-11-28 10:26:54 UTC (rev 8404) +++ projects/haf/branches/hildon-control-panel/refactoring/src/hcp-window.c 2006-11-28 11:31:05 UTC (rev 8405) @@ -23,7 +23,6 @@ */ #include <libosso.h> -#include <osso-log.h> #include <osso-helplib.h> #include <hildon-widgets/hildon-window.h> #include <hildon-widgets/hildon-program.h> @@ -96,44 +95,52 @@ static void hcp_window_enforce_state (HCPWindow *window) { - /* Actually enforce the saved state */ - if (window->priv->icon_size == 0) - hcp_app_view_set_icon_size (window->priv->view, - HCP_ICON_SIZE_SMALL); - else if (window->priv->icon_size == 1) - hcp_app_view_set_icon_size (window->priv->view, - HCP_ICON_SIZE_LARGE); - else - ULOG_ERR("Unknown iconsize"); + HCPWindowPrivate *priv; - /* If the saved focused item filename is defined, try to - * focus on the item. */ - if (window->priv->saved_focused_filename) - { - GHashTable *apps = NULL; - HCPApp *app = NULL; + g_return_if_fail (window); + g_return_if_fail (HCP_IS_WINDOW (window)); - g_object_get (G_OBJECT (window->priv->al), - "apps", &apps, - NULL); + priv = HCP_WINDOW_GET_PRIVATE (window); - app = g_hash_table_lookup (apps, - window->priv->saved_focused_filename); + /* Actually enforce the saved state */ + if (priv->icon_size == 0) + hcp_app_view_set_icon_size (priv->view, + HCP_ICON_SIZE_SMALL); + else if (priv->icon_size == 1) + hcp_app_view_set_icon_size (priv->view, + HCP_ICON_SIZE_LARGE); + else + g_warning ("Unknown iconsize"); - if (app) - hcp_app_focus (app); + /* If the saved focused item filename is defined, try to + * focus on the item. */ + if (priv->saved_focused_filename) + { + GHashTable *apps = NULL; + HCPApp *app = NULL; - g_free (window->priv->saved_focused_filename); - window->priv->saved_focused_filename = NULL; - } + g_object_get (G_OBJECT (priv->al), + "apps", &apps, + NULL); - /* HCPProgram will start the possible plugin in - * program->execute */ + app = g_hash_table_lookup (apps, + priv->saved_focused_filename); + + if (app) + hcp_app_focus (app); + + g_free (priv->saved_focused_filename); + priv->saved_focused_filename = NULL; + } + + /* HCPProgram will start the possible plugin in + * program->execute */ } static void hcp_window_retrieve_state (HCPWindow *window) { + HCPWindowPrivate *priv; HCPProgram *program = hcp_program_get_instance (); osso_state_t state = { 0, }; GKeyFile *keyfile = NULL; @@ -143,11 +150,16 @@ gint scroll_value; gboolean execute; + g_return_if_fail (window); + g_return_if_fail (HCP_IS_WINDOW (window)); + + priv = HCP_WINDOW_GET_PRIVATE (window); + ret = osso_state_read (program->osso, &state); if (ret != OSSO_OK) { - ULOG_ERR ("An error occured when reading application state"); + g_warning ("An error occured when reading application state"); return; } @@ -167,8 +179,8 @@ if (error) { - ULOG_ERR ("An error occured when reading application state: %s", - error->message); + g_warning ("An error occured when reading application state: %s", + error->message); goto cleanup; } @@ -179,12 +191,12 @@ if (error) { - ULOG_ERR ("An error occured when reading application state: %s", - error->message); + g_warning ("An error occured when reading application state: %s", + error->message); goto cleanup; } - window->priv->saved_focused_filename = focused; + priv->saved_focused_filename = focused; scroll_value = g_key_file_get_integer (keyfile, HCP_STATE_GROUP, @@ -193,12 +205,12 @@ if (error) { - ULOG_ERR ("An error occured when reading application state: %s", - error->message); + g_warning ("An error occured when reading application state: %s", + error->message); goto cleanup; } - window->priv->scroll_value = scroll_value; + priv->scroll_value = scroll_value; execute = g_key_file_get_boolean (keyfile, HCP_STATE_GROUP, @@ -207,8 +219,8 @@ if (error) { - ULOG_ERR ("An error occured when reading application state: %s", - error->message); + g_warning ("An error occured when reading application state: %s", + error->message); goto cleanup; } @@ -227,23 +239,28 @@ static void hcp_window_save_state (HCPWindow *window, gboolean clear_state) { + HCPWindowPrivate *priv; HCPProgram *program = hcp_program_get_instance (); - HCPWindowPrivate *priv; osso_state_t state = { 0, }; GKeyFile *keyfile = NULL; osso_return_t ret; gchar *focused = NULL; GError *error = NULL; - priv = window->priv; + g_return_if_fail (window); + g_return_if_fail (HCP_IS_WINDOW (window)); + priv = HCP_WINDOW_GET_PRIVATE (window); + if (clear_state) { state.state_data = ""; state.state_size = 1; + ret = osso_state_write (program->osso, &state); + if (ret != OSSO_OK) - ULOG_ERR ("An error occured when clearing application state"); + g_warning ("An error occured when clearing application state"); return; } @@ -282,7 +299,7 @@ if (ret != OSSO_OK) { - ULOG_ERR ("An error occured when reading application state"); + g_warning ("An error occured when reading application state"); } /* If a plugin is running, save its state */ @@ -295,8 +312,8 @@ cleanup: if (error) { - ULOG_ERR ("An error occured when reading application state: %s", - error->message); + g_warning ("An error occured when reading application state: %s", + error->message); g_error_free (error); } @@ -310,10 +327,16 @@ static void hcp_window_retrieve_configuration (HCPWindow *window) { + HCPWindowPrivate *priv; GConfClient *client = NULL; GError *error = NULL; gboolean icon_size; + g_return_if_fail (window); + g_return_if_fail (HCP_IS_WINDOW (window)); + + priv = HCP_WINDOW_GET_PRIVATE (window); + client = gconf_client_get_default (); g_return_if_fail (client); @@ -324,12 +347,12 @@ if (error) { - ULOG_ERR (error->message); + g_warning ("Error reading window settings from GConf: %s", error->message); g_error_free (error); } else { - window->priv->icon_size = icon_size?1:0; + priv->icon_size = icon_size ? TRUE : FALSE; } g_object_unref (client); @@ -339,15 +362,21 @@ static void hcp_window_save_configuration (HCPWindow *window) { + HCPWindowPrivate *priv; GConfClient *client = NULL; GError *error = NULL; gboolean icon_size; + g_return_if_fail (window); + g_return_if_fail (HCP_IS_WINDOW (window)); + + priv = HCP_WINDOW_GET_PRIVATE (window); + client = gconf_client_get_default (); g_return_if_fail (client); - icon_size = window->priv->icon_size?TRUE:FALSE; + icon_size = priv->icon_size ? TRUE : FALSE; gconf_client_set_bool (client, HCP_GCONF_ICON_SIZE_KEY, @@ -356,7 +385,7 @@ if (error) { - ULOG_ERR (error->message); + g_warning ("Error saving window settings to GConf: %s", error->message); g_error_free (error); } @@ -368,9 +397,15 @@ GdkEventKey * keyevent, gpointer data) { - HCPWindow *window = HCP_WINDOW (widget); - HCPWindowPrivate *priv = window->priv; + HCPWindow *window; + HCPWindowPrivate *priv; + g_return_val_if_fail (widget, FALSE); + g_return_val_if_fail (HCP_IS_WINDOW (widget), FALSE); + + window = HCP_WINDOW (widget); + priv = HCP_WINDOW_GET_PRIVATE (window); + if (keyevent->type == GDK_KEY_RELEASE) { switch (keyevent->keyval) @@ -379,10 +414,13 @@ if (priv->icon_size != 1) { priv->icon_size = 1; + gtk_check_menu_item_set_active ( GTK_CHECK_MENU_ITEM (priv->large_icons_menu_item), TRUE); + hcp_app_view_set_icon_size (priv->view, HCP_ICON_SIZE_LARGE); + hcp_window_save_configuration (window); return TRUE; @@ -393,10 +431,13 @@ if (priv->icon_size != 0) { priv->icon_size = 0; + gtk_check_menu_item_set_active ( GTK_CHECK_MENU_ITEM (priv->small_icons_menu_item), TRUE); + hcp_app_view_set_icon_size (priv->view, HCP_ICON_SIZE_SMALL); + hcp_window_save_configuration (window); return TRUE; @@ -414,7 +455,7 @@ gtk_window_fullscreen (GTK_WINDOW (window)); priv->fullscreen = TRUE; } - + return TRUE; break; } } @@ -437,19 +478,19 @@ break; case OSSO_ERROR: - ULOG_WARN ("HELP: ERROR (No help for such topic ID)\n"); + g_warning ("HELP: ERROR (No help for such topic ID)\n"); break; case OSSO_RPC_ERROR: - ULOG_WARN ("HELP: RPC ERROR (RPC failed for HelpApp/Browser)\n"); + g_warning ("HELP: RPC ERROR (RPC failed for HelpApp/Browser)\n"); break; case OSSO_INVALID: - ULOG_WARN ("HELP: INVALID (invalid argument)\n"); + g_warning ("HELP: INVALID (invalid argument)\n"); break; default: - ULOG_WARN ("HELP: Unknown error!\n"); + g_warning ("HELP: Unknown error!\n"); break; } } @@ -495,7 +536,7 @@ break; case OSSO_INVALID: - ULOG_ERR("Invalid parameter in operator_wizard launch"); + g_warning ("Invalid parameter in operator_wizard launch"); break; case OSSO_RPC_ERROR: @@ -505,37 +546,45 @@ case OSSO_ERROR_STATE_SIZE: if (returnvalues.type == DBUS_TYPE_STRING) { - ULOG_ERR("Operator wizard launch failed: %s\n",returnvalues.value.s); + g_warning ("Operator wizard launch failed: %s\n",returnvalues.value.s); } else { - ULOG_ERR("Operator wizard launch failed, unspecified"); + g_warning ("Operator wizard launch failed, unspecified"); } break; default: - ULOG_ERR("Unknown error type %d", returnstatus); + g_warning ("Unknown error type %d", returnstatus); } osso_rpc_free_val (&returnvalues); } -static void hcp_window_iconsize (GtkWidget *widget, HCPWindow *window) +static void +hcp_window_iconsize (GtkWidget *widget, HCPWindow *window) { + HCPWindowPrivate *priv; + + g_return_if_fail (window); + g_return_if_fail (HCP_IS_WINDOW (window)); + + priv = HCP_WINDOW_GET_PRIVATE (window); + if (!gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget))) return; - if (widget == window->priv->large_icons_menu_item) + if (widget == priv->large_icons_menu_item) { - hcp_app_view_set_icon_size (window->priv->view, + hcp_app_view_set_icon_size (priv->view, HCP_ICON_SIZE_LARGE); - window->priv->icon_size = 1; + priv->icon_size = 1; } - else if (widget == window->priv->small_icons_menu_item) + else if (widget == priv->small_icons_menu_item) { - hcp_app_view_set_icon_size (window->priv->view, + hcp_app_view_set_icon_size (priv->view, HCP_ICON_SIZE_SMALL); - window->priv->icon_size = 0; + priv->icon_size = 0; } hcp_window_save_configuration (window); @@ -544,7 +593,14 @@ static void hcp_window_open (GtkWidget *widget, HCPWindow *window) { - hcp_app_launch (window->priv->focused_item, TRUE); + HCPWindowPrivate *priv; + + g_return_if_fail (window); + g_return_if_fail (HCP_IS_WINDOW (window)); + + priv = HCP_WINDOW_GET_PRIVATE (window); + + hcp_app_launch (priv->focused_item, TRUE); } static void @@ -552,9 +608,14 @@ GParamSpec *arg1, HCPWindow *window) { + HCPWindowPrivate *priv; HildonProgram *program = HILDON_PROGRAM (gobject); - HCPWindowPrivate *priv = window->priv; + g_return_if_fail (window); + g_return_if_fail (HCP_IS_WINDOW (window)); + + priv = HCP_WINDOW_GET_PRIVATE (window); + if (hildon_program_get_is_topmost (program)) { hildon_program_set_can_hibernate (program, FALSE); } else { @@ -575,35 +636,48 @@ HCPApp *app, HCPWindow *window) { - if (window->priv->focused_item != NULL) - g_object_unref (window->priv->focused_item); + HCPWindowPrivate *priv; + g_return_if_fail (window); + g_return_if_fail (HCP_IS_WINDOW (window)); + + priv = HCP_WINDOW_GET_PRIVATE (window); + + if (priv->focused_item != NULL) + g_object_unref (priv->focused_item); + /* Increment reference count to avoid object * destruction on HCPAppList update. */ - window->priv->focused_item = g_object_ref (app); + priv->focused_item = g_object_ref (app); } static void hcp_window_app_list_updated_cb (HCPAppList *al, HCPWindow *window) { + HCPWindowPrivate *priv; GHashTable *apps = NULL; HCPApp *app = NULL; gchar *focused = NULL; - g_object_get (G_OBJECT (window->priv->focused_item), + g_return_if_fail (window); + g_return_if_fail (HCP_IS_WINDOW (window)); + + priv = HCP_WINDOW_GET_PRIVATE (window); + + g_object_get (G_OBJECT (priv->focused_item), "plugin", &focused, NULL); - g_object_unref (window->priv->focused_item); + g_object_unref (priv->focused_item); window->priv->focused_item = NULL; - g_object_get (G_OBJECT (window->priv->al), + g_object_get (G_OBJECT (priv->al), "apps", &apps, NULL); /* Update the view */ - hcp_app_view_populate (HCP_APP_VIEW (window->priv->view), al); - gtk_widget_show_all (window->priv->view); + hcp_app_view_populate (HCP_APP_VIEW (priv->view), al); + gtk_widget_show_all (priv->view); app = g_hash_table_lookup (apps, focused); @@ -618,6 +692,9 @@ static void hcp_window_quit (GtkWidget *widget, HCPWindow *window) { + g_return_if_fail (window); + g_return_if_fail (HCP_IS_WINDOW (window)); + hcp_window_save_state (window, TRUE); gtk_widget_destroy (GTK_WIDGET (window)); @@ -639,10 +716,10 @@ GtkWidget *scrolled_window = NULL; GSList *menugroup = NULL; - g_return_if_fail (window != NULL); + g_return_if_fail (window); g_return_if_fail (HCP_IS_WINDOW (window)); - priv = window->priv; + priv = HCP_WINDOW_GET_PRIVATE (window); /* Why is this not read from the gtkrc?? -- Jobi */ /* Control Panel Grid */ @@ -775,26 +852,6 @@ gtk_widget_show_all (GTK_WIDGET (menu)); - /* What is this for? -- Jobi */ -#if 0 - hcp->grids = hildon_cp_applist_get_grids(); - grids = hcp->grids; - - while (grids != 0) - { - grid = grids->data; - { - GValue val = { 0, }; - g_value_init(&val, G_TYPE_STRING); - g_value_set_string(&val, ""); - g_object_set_property(G_OBJECT(grid), "empty_label", &val); - g_value_unset(&val); - } - - grids = grids->next; - } -#endif - /* Set the keyboard listening callback */ gtk_widget_add_events (GTK_WIDGET(window), GDK_BUTTON_RELEASE_MASK); @@ -874,14 +931,12 @@ static void hcp_window_finalize (GObject *object) { - HCPWindow *window; HCPWindowPrivate *priv; - g_return_if_fail (object != NULL); + g_return_if_fail (object); g_return_if_fail (HCP_IS_WINDOW (object)); - window = HCP_WINDOW (object); - priv = window->priv; + priv = HCP_WINDOW_GET_PRIVATE (object); if (priv->al != NULL) { @@ -925,5 +980,8 @@ void hcp_window_close (HCPWindow *window) { + g_return_if_fail (window); + g_return_if_fail (HCP_IS_WINDOW (window)); + hcp_window_quit (NULL, window); }
- Previous message: [maemo-commits] r8404 - in projects/haf/trunk/libsdl1.2: debian src/events src/video src/video/dga src/video/directfb src/video/fbcon src/video/x11
- Next message: [maemo-commits] r8406 - projects/haf/branches/hildon-control-panel/refactoring
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]