[maemo-commits] [maemo-commits] r16621 - in projects/haf/trunk/hildon-control-panel: data src
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Sat Nov 8 19:01:20 EET 2008
- Previous message: [maemo-commits] r16619 - in projects/haf/trunk/hildon-thumbnail: . debian
- Next message: [maemo-commits] r16622 - projects/haf/trunk/hildon-control-panel
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: paradi Date: 2008-11-08 19:01:16 +0200 (Sat, 08 Nov 2008) New Revision: 16621 Modified: projects/haf/trunk/hildon-control-panel/data/hildon-control-panel.schemas projects/haf/trunk/hildon-control-panel/src/hcp-app-view.c projects/haf/trunk/hildon-control-panel/src/hcp-app-view.h projects/haf/trunk/hildon-control-panel/src/hcp-app.c projects/haf/trunk/hildon-control-panel/src/hcp-grid.c projects/haf/trunk/hildon-control-panel/src/hcp-grid.h projects/haf/trunk/hildon-control-panel/src/hcp-window.c Log: 2008-11-07 Peter Aradi <peter.aradi at blumsoft.eu> * src/hcp-app-view.c * src/hcp-grid.h * src/hcp-app-view.h * src/hcp-window.c * src/hcp-app.c * src/hcp-grid.c * data/hildon-control-panel.schemas Changes for supporting new Hildon style touch grid Please see NB#91702. Modified: projects/haf/trunk/hildon-control-panel/data/hildon-control-panel.schemas =================================================================== --- projects/haf/trunk/hildon-control-panel/data/hildon-control-panel.schemas 2008-11-07 15:29:52 UTC (rev 16620) +++ projects/haf/trunk/hildon-control-panel/data/hildon-control-panel.schemas 2008-11-08 17:01:16 UTC (rev 16621) @@ -19,13 +19,5 @@ <default>[general,connectivity,personalisation]</default> <locale name="C"/> </schema> - <schema> - <key>/schemas/apps/osso/apps/controlpanel/icon_size</key> - <applyto>/apps/osso/apps/controlpanel/icon_size</applyto> - <owner>controlpanel</owner> - <type>bool</type> - <default>true</default> - <locale name="C"/> - </schema> </schemalist> </gconfschemafile> Modified: projects/haf/trunk/hildon-control-panel/src/hcp-app-view.c =================================================================== --- projects/haf/trunk/hildon-control-panel/src/hcp-app-view.c 2008-11-07 15:29:52 UTC (rev 16620) +++ projects/haf/trunk/hildon-control-panel/src/hcp-app-view.c 2008-11-08 17:01:16 UTC (rev 16621) @@ -33,7 +33,7 @@ #include "hcp-app.h" #include "hcp-grid.h" #include "hcp-marshalers.h" - +#include <hildon/hildon-gtk.h> #define HCP_APP_VIEW_GET_PRIVATE(object) \ (G_TYPE_INSTANCE_GET_PRIVATE ((object), HCP_TYPE_APP_VIEW, HCPAppViewPrivate)) @@ -55,7 +55,6 @@ struct _HCPAppViewPrivate { GtkWidget *first_grid; - HCPIconSize icon_size; }; static GtkListStore* @@ -76,7 +75,7 @@ { GtkWidget *grid; - grid = hcp_grid_new (); + grid = hcp_grid_new (HILDON_UI_MODE_NORMAL); gtk_widget_set_name (grid, "hildon-control-panel-grid"); return grid; @@ -100,21 +99,19 @@ } static HCPApp * -hcp_app_view_get_selected_app (GtkWidget *widget) +hcp_app_view_get_selected_app (GtkWidget *widget, GtkTreePath *path) { GtkTreeModel *model; - GtkTreePath *path; HCPApp *app = NULL; GtkTreeIter iter; gint item_pos; g_return_val_if_fail (widget, NULL); g_return_val_if_fail (GTK_IS_ICON_VIEW (widget), NULL); + g_return_val_if_fail (path, NULL); model = gtk_icon_view_get_model (GTK_ICON_VIEW (widget)); - path = hcp_grid_get_selected_item (HCP_GRID (widget)); - if (path == NULL) return NULL; item_pos = gtk_tree_path_get_indices (path) [0]; @@ -126,8 +123,6 @@ -1); } - gtk_tree_path_free (path); - return app; } @@ -136,69 +131,16 @@ GtkTreePath *path, gpointer user_data) { - HCPApp *app = hcp_app_view_get_selected_app (widget); - if (app != NULL) - hcp_app_launch (app, TRUE); -} + HCPApp *app = hcp_app_view_get_selected_app (widget, path); -static void -hcp_app_view_grid_selection_changed (GtkWidget *widget, gpointer user_data) -{ - GtkWidget *view = GTK_WIDGET (user_data); - GtkWidget *scrolled_window = view->parent->parent; - HCPApp *app = hcp_app_view_get_selected_app (widget); - GtkTreePath *path; - GtkAllocation allocation; - GtkAdjustment *adj; - guint row, row_height, position, visible_y; - - if (app == NULL) return; - - g_return_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window)); - - path = hcp_grid_get_selected_item (HCP_GRID (widget)); - position = gtk_tree_path_get_indices (path) [0]; - - row = position / HCP_GRID_NUM_COLUMNS; - row_height = hcp_grid_get_row_height (HCP_GRID (widget)); - - gtk_tree_path_free (path); - - adj = gtk_scrolled_window_get_vadjustment ( - GTK_SCROLLED_WINDOW (scrolled_window)); - - g_return_if_fail ((adj->upper - adj->lower) && view->allocation.height); - - visible_y = view->allocation.y + - (gint)(view->allocation.height * adj->value / (adj->upper - adj->lower)); - - allocation.y = widget->allocation.y + (row * row_height); - allocation.height = row_height; - - if (allocation.y >= 0) - { - if (allocation.y < visible_y) - { - adj->value = allocation.y * (adj->upper - adj->lower) - / view->allocation.height; - - gtk_adjustment_value_changed (adj); - } - else if (allocation.y + allocation.height > - visible_y + scrolled_window->allocation.height) - { - adj->value = (allocation.y + allocation.height - - scrolled_window->allocation.height) * (adj->upper - adj->lower) - / view->allocation.height; - - gtk_adjustment_value_changed (adj); - } - } - + /* important for state saving of executed app */ g_signal_emit (G_OBJECT (widget->parent), signals[SIGNAL_FOCUS_CHANGED], 0, app); + + if (app != NULL) + hcp_app_launch (app, TRUE); } static void @@ -249,10 +191,6 @@ grid = hcp_app_view_create_grid (); store = hcp_app_view_create_store (); - - g_signal_connect (grid, "selection-changed", - G_CALLBACK (hcp_app_view_grid_selection_changed), - view); g_signal_connect (grid, "item-activated", G_CALLBACK (hcp_app_view_launch_app), @@ -278,6 +216,8 @@ (GFunc) hcp_app_view_add_app, grid); + hcp_grid_refresh_icons (HCP_GRID(grid)); + if (!view->priv->first_grid) view->priv->first_grid = grid; } @@ -308,10 +248,6 @@ switch (prop_id) { - case PROP_ICON_SIZE: - g_value_set_int (value, priv->icon_size); - break; - default: G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); break; @@ -330,10 +266,6 @@ switch (prop_id) { - case PROP_ICON_SIZE: - priv->icon_size = g_value_get_int (value); - break; - default: G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); break; @@ -358,27 +290,13 @@ G_TYPE_NONE, 1, HCP_TYPE_APP); - g_object_class_install_property (g_object_class, - PROP_ICON_SIZE, - g_param_spec_int ("icon-size", - "Icon Size", - "Set view's icon size", - HCP_ICON_SIZE_SMALL, - HCP_ICON_SIZE_LARGE, - HCP_ICON_SIZE_LARGE, - (G_PARAM_READABLE | - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT))); - g_type_class_add_private (g_object_class, sizeof (HCPAppViewPrivate)); } GtkWidget * -hcp_app_view_new (HCPIconSize icon_size) +hcp_app_view_new (void) { - GtkWidget *view = g_object_new (HCP_TYPE_APP_VIEW, - "icon-size", icon_size, - NULL); + GtkWidget *view = g_object_new (HCP_TYPE_APP_VIEW, NULL); return view; } @@ -412,49 +330,4 @@ (GFunc) hcp_app_view_add_category, view); - 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 (priv->first_grid); - gtk_icon_view_select_path (GTK_ICON_VIEW (priv->first_grid), - gtk_tree_path_new_first ()); - } } - -void -hcp_app_view_set_icon_size (GtkWidget *view, HCPIconSize size) -{ - GtkWidget *grid = NULL; - 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 */ - while (iter != 0) - { - if (HCP_IS_GRID (iter->data)) - { - grid = GTK_WIDGET (iter->data); - - if (size == HCP_ICON_SIZE_SMALL) - { - hcp_grid_set_icon_size (HCP_GRID (grid), HCP_ICON_SIZE_SMALL); - } - - if (size == HCP_ICON_SIZE_LARGE) - { - hcp_grid_set_icon_size (HCP_GRID (grid), HCP_ICON_SIZE_LARGE); - } - } - - iter = iter->next; - } - - g_list_free (list); -} Modified: projects/haf/trunk/hildon-control-panel/src/hcp-app-view.h =================================================================== --- projects/haf/trunk/hildon-control-panel/src/hcp-app-view.h 2008-11-07 15:29:52 UTC (rev 16620) +++ projects/haf/trunk/hildon-control-panel/src/hcp-app-view.h 2008-11-08 17:01:16 UTC (rev 16621) @@ -60,13 +60,11 @@ GType hcp_app_view_get_type (void); -GtkWidget* hcp_app_view_new (HCPIconSize icon_size); +GtkWidget* hcp_app_view_new (void); void hcp_app_view_populate (HCPAppView *view, HCPAppList *al); -void hcp_app_view_set_icon_size (GtkWidget *view, - HCPIconSize size); G_END_DECLS Modified: projects/haf/trunk/hildon-control-panel/src/hcp-app.c =================================================================== --- projects/haf/trunk/hildon-control-panel/src/hcp-app.c 2008-11-07 15:29:52 UTC (rev 16620) +++ projects/haf/trunk/hildon-control-panel/src/hcp-app.c 2008-11-08 17:01:16 UTC (rev 16621) @@ -474,6 +474,7 @@ g_return_if_fail (app); g_return_if_fail (HCP_IS_APP (app)); + g_return_if_fail (!hcp_app_is_running (app)); if (!program->execute) { Modified: projects/haf/trunk/hildon-control-panel/src/hcp-grid.c =================================================================== --- projects/haf/trunk/hildon-control-panel/src/hcp-grid.c 2008-11-07 15:29:52 UTC (rev 16620) +++ projects/haf/trunk/hildon-control-panel/src/hcp-grid.c 2008-11-08 17:01:16 UTC (rev 16621) @@ -33,42 +33,33 @@ #include "hcp-grid.h" #include "hcp-app.h" +#include <hildon/hildon-gtk.h> #define HCP_GRID_GET_PRIVATE(object) \ (G_TYPE_INSTANCE_GET_PRIVATE ((object), HCP_TYPE_GRID, HCPGridPrivate)) -G_DEFINE_TYPE (HCPGrid, hcp_grid, GTK_TYPE_ICON_VIEW); +G_DEFINE_TYPE (HCPGrid, hcp_grid, GTK_TYPE_ICON_VIEW) #define HCP_GRID_ITEM_WIDTH 328 #define HCP_GRID_X_PADDING 4 #define HCP_GRID_Y_PADDING 2 -#define HCP_GRID_NO_FOCUS -1 +#define HCP_ICON_SIZE 66 -struct _HCPGridPrivate -{ +struct _HCPGridPrivate { GtkCellRenderer *text_cell; GtkCellRenderer *pixbuf_cell; gboolean can_move_focus; gboolean focused_in; - HCPIconSize icon_size; - gint row_height; +/* gint row_height;*/ + gint icon_size; }; -enum -{ - HCP_GRID_FOCUS_FROM_ABOVE, - HCP_GRID_FOCUS_FROM_BELOW, - HCP_GRID_FOCUS_FIRST, - HCP_GRID_FOCUS_LAST -}; - static gboolean hcp_grid_update_icon (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer user_data) { - HCPGridPrivate *priv; HCPApp *app; GtkIconTheme *icon_theme; GdkPixbuf *icon_pixbuf; @@ -78,7 +69,7 @@ g_return_val_if_fail (user_data, TRUE); g_return_val_if_fail (HCP_IS_GRID (user_data), TRUE); - priv = HCP_GRID (user_data)->priv; +/* priv = HCP_GRID (user_data)->priv; */ gtk_tree_model_get (GTK_TREE_MODEL (model), iter, HCP_STORE_APP, &app, @@ -87,12 +78,13 @@ g_object_get (G_OBJECT (app), "icon", &icon, NULL); - + icon_theme = gtk_icon_theme_get_default (); icon_pixbuf = gtk_icon_theme_load_icon (icon_theme, icon, - priv->icon_size, + /* priv->icon_size, */ + HCP_ICON_SIZE, 0, &error); @@ -105,7 +97,8 @@ icon_pixbuf = gtk_icon_theme_load_icon (icon_theme, HCP_DEFAULT_ICON_BASENAME, - priv->icon_size, + /* priv->icon_size, */ + HCP_ICON_SIZE, 0, &error); @@ -116,20 +109,6 @@ } } - if (priv->row_height == -1) - { - if (priv->icon_size == HCP_ICON_SIZE_SMALL) - { - priv->row_height = gdk_pixbuf_get_height (icon_pixbuf); - } - else if (priv->icon_size == HCP_ICON_SIZE_LARGE) - { - priv->row_height = gdk_pixbuf_get_height (icon_pixbuf); - } - - priv->row_height += 2 * HCP_GRID_Y_PADDING; - } - gtk_list_store_set (GTK_LIST_STORE (model), iter, HCP_STORE_ICON, icon_pixbuf, -1); @@ -139,320 +118,24 @@ return FALSE; } -static gboolean -hcp_grid_button_pressed (GtkWidget *widget, - GdkEventButton *event) -{ - GtkTreePath *selected_path, *clicked_path; - - if (event->type == GDK_2BUTTON_PRESS || - event->type == GDK_3BUTTON_PRESS) { - return FALSE; - } - - if (event->button == 1 && event->type == GDK_BUTTON_PRESS) - { - selected_path = hcp_grid_get_selected_item (HCP_GRID (widget)); - - clicked_path = gtk_icon_view_get_path_at_pos (GTK_ICON_VIEW (widget), - (gint) event->x, - (gint) event->y); - - if (clicked_path != NULL && selected_path != NULL) - { - if (gtk_tree_path_get_indices (clicked_path) [0] == - gtk_tree_path_get_indices (selected_path) [0]) - { - gtk_icon_view_item_activated (GTK_ICON_VIEW (widget), clicked_path); - } - } - - if (clicked_path != NULL) - { - gtk_widget_grab_focus (widget); - gtk_icon_view_select_path (GTK_ICON_VIEW (widget), clicked_path); - } - - gtk_tree_path_free (clicked_path); - gtk_tree_path_free (selected_path); - - return TRUE; - } - - return FALSE; -} - -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); - g_return_if_fail (HCP_IS_GRID (widget)); - - priv = HCP_GRID (widget)->priv; - - model = gtk_icon_view_get_model (GTK_ICON_VIEW (widget)); - n_items = gtk_tree_model_iter_n_children (model, NULL); - - path = hcp_grid_get_selected_item (HCP_GRID (widget)); - - if (path == NULL) return; - - item_pos = gtk_tree_path_get_indices (path) [0]; - y = item_pos / HCP_GRID_NUM_COLUMNS; - last_row = ceil ((double) n_items / HCP_GRID_NUM_COLUMNS) - 1; - - gtk_icon_view_set_cursor (GTK_ICON_VIEW (widget), path, NULL, FALSE); - - if ((y == 0 || y == last_row) && !priv->focused_in) - { - priv->can_move_focus = FALSE; - } - else if (priv->focused_in) - { - priv->focused_in = FALSE; - } - - gtk_tree_path_free (path); -} - -static GtkWidget * -hcp_grid_get_previous (GtkWidget *grid) -{ - GtkWidget *previous; - GList *focusable, *focus_chain; - - gtk_container_get_focus_chain (GTK_CONTAINER (grid->parent), &focus_chain); - - focusable = g_list_first (focus_chain); - - while (GTK_WIDGET (focusable->data) != grid) - { - focusable = g_list_next (focusable); - } - - if (focusable->prev == NULL) - return NULL; - - previous = GTK_WIDGET (g_list_previous (focusable)->data); - - g_list_free (focus_chain); - - return previous; -} - -static GtkWidget * -hcp_grid_get_next (GtkWidget *grid) -{ - GtkWidget *next; - GList *focusable, *focus_chain; - - gtk_container_get_focus_chain (GTK_CONTAINER(grid->parent), &focus_chain); - - focusable = g_list_first (focus_chain); - - while (GTK_WIDGET (focusable->data) != grid) - { - focusable = g_list_next (focusable); - } - - if (focusable->next == NULL) - return NULL; - - next = GTK_WIDGET (g_list_next (focusable)->data); - - g_list_free (focus_chain); - - return next; -} - -static void -hcp_grid_select_from_outside (GtkWidget *widget, - gint direction, - gint x) -{ - GtkTreeModel *model; - GtkTreePath *path; - gint n_items, last_row; - gint item_pos = HCP_GRID_NO_FOCUS; - - 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); - - switch (direction) - { - case HCP_GRID_FOCUS_FROM_ABOVE: - if (x + 1 > n_items) - item_pos = n_items - 1; - else - item_pos = x; - break; - - case HCP_GRID_FOCUS_FROM_BELOW: - last_row = n_items % HCP_GRID_NUM_COLUMNS; - - if (last_row == 0) - item_pos = n_items - HCP_GRID_NUM_COLUMNS + x; - else if (x < last_row) - item_pos = n_items - last_row + x; - else - item_pos = n_items - 1; - break; - - case HCP_GRID_FOCUS_FIRST: - item_pos = 0; - break; - - case HCP_GRID_FOCUS_LAST: - item_pos = n_items - 1; - break; - } - - if (item_pos != HCP_GRID_NO_FOCUS) - { - gtk_widget_grab_focus (widget); - path = gtk_tree_path_new_from_indices (item_pos, -1); - gtk_icon_view_select_path (GTK_ICON_VIEW (widget), path); - gtk_tree_path_free (path); - } -} - -static gboolean -hcp_grid_focus_in (GtkWidget *widget, - GdkEventFocus *event) -{ - GList *iter = NULL; - GList *list = NULL; - - /* - * Unselect all on other grids - */ - list = iter = gtk_container_get_children (GTK_CONTAINER (widget->parent)); - - while (iter != 0) - { - if (HCP_IS_GRID (iter->data) && widget != iter->data) - { - gtk_icon_view_unselect_all (GTK_ICON_VIEW (iter->data)); - } - - iter = iter->next; - } - - g_list_free (list); - - HCP_GRID (widget)->priv->focused_in = TRUE; - HCP_GRID (widget)->priv->can_move_focus = TRUE; - - return TRUE; -} - -static gint -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, FALSE); - g_return_val_if_fail (HCP_IS_GRID (widget), FALSE); - - priv = HCP_GRID (widget)->priv; - - model = gtk_icon_view_get_model (GTK_ICON_VIEW (widget)); - n_items = gtk_tree_model_iter_n_children (model, NULL); - - path = hcp_grid_get_selected_item (HCP_GRID (widget)); - - if (path == NULL) - return FALSE; - - item_pos = gtk_tree_path_get_indices (path) [0]; - x = item_pos % HCP_GRID_NUM_COLUMNS; - y = item_pos / HCP_GRID_NUM_COLUMNS; - last_row = ceil ((double) n_items / HCP_GRID_NUM_COLUMNS) - 1; - - if (keyevent->type == GDK_KEY_RELEASE) - { - switch (keyevent->keyval) - { - case HILDON_HARDKEY_UP: - if (y == 0) - { - if (priv->can_move_focus) - { - hcp_grid_select_from_outside (hcp_grid_get_previous (widget), - HCP_GRID_FOCUS_FROM_BELOW, x); - result = TRUE; - } - else - priv->can_move_focus = TRUE; - } - break; - - case HILDON_HARDKEY_DOWN: - if (y == last_row) - { - if (priv->can_move_focus) - { - hcp_grid_select_from_outside (hcp_grid_get_next (widget), - HCP_GRID_FOCUS_FROM_ABOVE, x); - result = TRUE; - } - else - priv->can_move_focus = TRUE; - } - break; - - case HILDON_HARDKEY_LEFT: - case HILDON_HARDKEY_RIGHT: - if (y == 0 || y == last_row) - { - if (!priv->can_move_focus) - priv->can_move_focus = TRUE; - } - break; - } - } - - gtk_tree_path_free (path); - - return result; -} - static void -hcp_grid_class_init (HCPGridClass *class) +hcp_grid_class_init (HCPGridClass *klass) { - GObjectClass *g_object_class = G_OBJECT_CLASS (class); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class); - widget_class->key_release_event = hcp_grid_keyboard_listener; - widget_class->focus_in_event = hcp_grid_focus_in; - widget_class->button_press_event = hcp_grid_button_pressed; + g_type_class_add_private (klass, sizeof (HCPGridPrivate)); - g_type_class_add_private (g_object_class, sizeof (HCPGridPrivate)); } static void hcp_grid_init (HCPGrid *grid) { grid->priv = HCP_GRID_GET_PRIVATE (grid); - + grid->priv->can_move_focus = FALSE; grid->priv->focused_in = FALSE; - grid->priv->icon_size = 0; + grid->priv->icon_size = HCP_ICON_SIZE; + grid->priv->pixbuf_cell = gtk_cell_renderer_pixbuf_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (grid), @@ -500,67 +183,22 @@ based on HCPAppView width. */ gtk_icon_view_set_item_width (GTK_ICON_VIEW (grid), HCP_GRID_ITEM_WIDTH); + +} +void +hcp_grid_refresh_icons (HCPGrid* grid) +{ + GtkTreeModel* model; - g_signal_connect (G_OBJECT (grid), "selection-changed", - G_CALLBACK (hcp_grid_selection_changed), - NULL); + model = gtk_icon_view_get_model (GTK_ICON_VIEW (grid)); + gtk_tree_model_foreach (model, hcp_grid_update_icon, grid); + gtk_widget_queue_resize (GTK_WIDGET (grid)); } GtkWidget * -hcp_grid_new (void) +hcp_grid_new (HildonUIMode uimode) { GtkWidget *grid = g_object_new (HCP_TYPE_GRID, NULL); return grid; } - -GtkTreePath * -hcp_grid_get_selected_item (HCPGrid *grid) -{ - GtkTreePath *path; - GList *list; - - 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)); - - if (list == NULL) - return NULL; - - path = gtk_tree_path_copy ((GtkTreePath *) list->data); - g_list_foreach (list, (GFunc) gtk_tree_path_free, NULL); - g_list_free (list); - - return path; -} - -guint -hcp_grid_get_row_height (HCPGrid *grid) -{ - g_return_val_if_fail (HCP_IS_GRID (grid), 0); - - return grid->priv->row_height; -} - -void -hcp_grid_set_icon_size (HCPGrid *grid, HCPIconSize icon_size) -{ - HCPGridPrivate *priv; - GtkTreeModel *model; - - g_return_if_fail (grid); - g_return_if_fail (HCP_IS_GRID (grid)); - - priv = grid->priv; - - 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); - - gtk_widget_queue_resize (GTK_WIDGET (grid)); -} Modified: projects/haf/trunk/hildon-control-panel/src/hcp-grid.h =================================================================== --- projects/haf/trunk/hildon-control-panel/src/hcp-grid.h 2008-11-07 15:29:52 UTC (rev 16620) +++ projects/haf/trunk/hildon-control-panel/src/hcp-grid.h 2008-11-08 17:01:16 UTC (rev 16621) @@ -28,28 +28,30 @@ G_BEGIN_DECLS -typedef struct _HCPGrid HCPGrid; -typedef struct _HCPGridClass HCPGridClass; typedef struct _HCPGridPrivate HCPGridPrivate; -#define HCP_TYPE_GRID (hcp_grid_get_type ()) -#define HCP_GRID(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), HCP_TYPE_GRID, HCPGrid)) -#define HCP_GRID_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), HCP_TYPE_GRID, HCPGridClass)) -#define HCP_IS_GRID(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), HCP_TYPE_GRID)) -#define HCP_IS_GRID_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), HCP_TYPE_GRID)) -#define HCP_GRID_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), HCP_TYPE_GRID, HCPGridClass)) +#define HCP_TYPE_GRID (hcp_grid_get_type()) +#define HCP_GRID(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), HCP_TYPE_GRID, HCPGrid)) +#define HCP_GRID_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), HCP_TYPE_GRID, HCPGridClass)) +#define HCP_IS_GRID(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), HCP_TYPE_GRID)) +#define HCP_IS_GRID_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), HCP_TYPE_GRID)) +#define HCP_GRID_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), HCP_TYPE_GRID, HCPGridClass)) #define HCP_DEFAULT_ICON_BASENAME "qgn_list_gene_unknown_file" #define HCP_GRID_NUM_COLUMNS 2 +typedef struct { + GtkIconView parent; + HCPGridPrivate* priv; +} HCPGrid; -typedef enum -{ - HCP_ICON_SIZE_SMALL = 27, - HCP_ICON_SIZE_LARGE = 66 -} HCPIconSize; +typedef struct { + GtkIconViewClass parent_class; +} HCPGridClass; +GType hcp_grid_get_type (void); + typedef enum { HCP_STORE_ICON = 0, HCP_STORE_LABEL, @@ -57,29 +59,9 @@ HCP_STORE_NUM_COLUMNS } HCPStoreColumn; -struct _HCPGrid -{ - GtkIconView icon_view; +GtkWidget* hcp_grid_new (HildonUIMode); +void hcp_grid_refresh_icons (HCPGrid*); - HCPGridPrivate *priv; -}; - -struct _HCPGridClass -{ - GtkIconViewClass icon_view_class; -}; - -GType hcp_grid_get_type (void); - -GtkWidget *hcp_grid_new (void); - -GtkTreePath *hcp_grid_get_selected_item (HCPGrid *grid); - -guint hcp_grid_get_row_height (HCPGrid *grid); - -void hcp_grid_set_icon_size (HCPGrid *grid, - HCPIconSize icon_size); - G_END_DECLS -#endif +#endif /* HCP_GRID_H */ Modified: projects/haf/trunk/hildon-control-panel/src/hcp-window.c =================================================================== --- projects/haf/trunk/hildon-control-panel/src/hcp-window.c 2008-11-07 15:29:52 UTC (rev 16620) +++ projects/haf/trunk/hildon-control-panel/src/hcp-window.c 2008-11-08 17:01:16 UTC (rev 16621) @@ -59,11 +59,8 @@ HCPApp *focused_item; HCPAppList *al; GtkWidget *view; - GtkWidget *large_icons_menu_item; - GtkWidget *small_icons_menu_item; /* For state save data */ - gint icon_size; gchar *saved_focused_filename; gint scroll_value; }; @@ -111,15 +108,6 @@ priv = window->priv; /* 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 the saved focused item filename is defined, try to * focus on the item. */ if (priv->saved_focused_filename) @@ -135,7 +123,8 @@ priv->saved_focused_filename); if (app) - hcp_app_focus (app); + /* hcp_app_focus (app); */ + priv->focused_item = app; g_free (priv->saved_focused_filename); priv->saved_focused_filename = NULL; @@ -346,8 +335,7 @@ HCPWindowPrivate *priv; GConfClient *client = NULL; GError *error = NULL; - gboolean icon_size; - + g_return_if_fail (window); g_return_if_fail (HCP_IS_WINDOW (window)); @@ -357,57 +345,15 @@ g_return_if_fail (client); - icon_size = gconf_client_get_bool (client, - HCP_GCONF_ICON_SIZE_KEY, - &error); - if (error) { g_warning ("Error reading window settings from GConf: %s", error->message); g_error_free (error); } - else - { - priv->icon_size = icon_size ? TRUE : FALSE; - } g_object_unref (client); } -/* Save the configuration (large/small icons) */ -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 = window->priv; - - client = gconf_client_get_default (); - - g_return_if_fail (client); - - icon_size = priv->icon_size ? TRUE : FALSE; - - gconf_client_set_bool (client, - HCP_GCONF_ICON_SIZE_KEY, - icon_size, - &error); - - if (error) - { - g_warning ("Error saving window settings to GConf: %s", error->message); - g_error_free (error); - } - - g_object_unref (client); -} - static gint hcp_window_keyboard_listener (GtkWidget * widget, GdkEventKey * keyevent, @@ -426,39 +372,8 @@ { switch (keyevent->keyval) { - case HILDON_HARDKEY_INCREASE: - 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; - } - break; - - case HILDON_HARDKEY_DECREASE: - 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; - } - break; + default: + break; } } @@ -566,48 +481,6 @@ #endif 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 = window->priv; - - if (!gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget))) - return; - - if (widget == priv->large_icons_menu_item) - { - hcp_app_view_set_icon_size (priv->view, - HCP_ICON_SIZE_LARGE); - priv->icon_size = 1; - } - else if (widget == priv->small_icons_menu_item) - { - hcp_app_view_set_icon_size (priv->view, - HCP_ICON_SIZE_SMALL); - priv->icon_size = 0; - } - - hcp_window_save_configuration (window); -} - -static void -hcp_window_open (GtkWidget *widget, HCPWindow *window) -{ - HCPWindowPrivate *priv; - - g_return_if_fail (window); - g_return_if_fail (HCP_IS_WINDOW (window)); - - priv = window->priv; - - hcp_app_launch (priv->focused_item, TRUE); -} - -static void hcp_window_topmost_status_change (GObject *gobject, GParamSpec *arg1, HCPWindow *window) @@ -703,6 +576,11 @@ g_return_if_fail (window); g_return_if_fail (HCP_IS_WINDOW (window)); + /* we can only close the window, when no applets are running */ + /**@TODO review this */ + HCPProgram *program = hcp_program_get_instance (); + program->execute = 0; + hcp_window_save_state (window, FALSE); gtk_widget_destroy (GTK_WIDGET (window)); @@ -719,13 +597,12 @@ GtkMenu *menu = NULL; GtkAccelGroup *accel_group; - GtkWidget *sub_view = NULL; + #ifdef MAEMO_TOOLS GtkWidget *sub_tools = NULL; #endif GtkWidget *mi = NULL; GtkWidget *scrolled_window = NULL; - GSList *menugroup = NULL; g_return_if_fail (window); g_return_if_fail (HCP_IS_WINDOW (window)); @@ -737,17 +614,17 @@ gtk_rc_parse_string (" style \"hildon-control-panel-grid\" {" " CPGrid::n_columns = 2" " CPGrid::label_pos = 1" + " GtkWidget::hildon-mode = 1" " }" " widget \"*.hildon-control-panel-grid\" " " style \"hildon-control-panel-grid\""); - /* Separators style */ gtk_rc_parse_string (" style \"hildon-control-panel-separator\" {" " GtkSeparator::hildonlike-drawing = 1" " }" " widget \"*.hildon-control-panel-separator\" " " style \"hildon-control-panel-separator\""); - + program = HILDON_PROGRAM (hildon_program_get_instance ()); hildon_program_add_window (program, HILDON_WINDOW (window)); @@ -765,52 +642,6 @@ hildon_window_set_menu (HILDON_WINDOW (window), menu); - mi = gtk_menu_item_new_with_label (HCP_MENU_OPEN); - - g_signal_connect (G_OBJECT (mi), "activate", - G_CALLBACK (hcp_window_open), window); - - gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); - - /* View submenu */ - sub_view = gtk_menu_new (); - - mi = gtk_menu_item_new_with_label (HCP_MENU_SUB_VIEW); - - gtk_menu_item_set_submenu (GTK_MENU_ITEM (mi), sub_view); - - gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); - - /* Small icon size */ - mi = gtk_radio_menu_item_new_with_label - (menugroup, HCP_MENU_SMALL_ITEMS); - menugroup = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (mi)); - priv->small_icons_menu_item = mi; - - if (priv->icon_size == 0) { - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(mi), TRUE); - } - - gtk_menu_shell_append (GTK_MENU_SHELL(sub_view), mi); - - g_signal_connect (G_OBJECT (mi), "activate", - G_CALLBACK (hcp_window_iconsize), window); - - /* Large icon size */ - mi = gtk_radio_menu_item_new_with_label - (menugroup, HCP_MENU_LARGE_ITEMS); - priv->large_icons_menu_item = mi; - - if (priv->icon_size == 1) { - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (mi), TRUE); - } - menugroup = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (mi)); - - gtk_menu_shell_append (GTK_MENU_SHELL (sub_view), mi); - - g_signal_connect (G_OBJECT (mi), "activate", - G_CALLBACK (hcp_window_iconsize), window); - #ifdef MAEMO_TOOLS /* Tools submenu */ sub_tools = gtk_menu_new (); @@ -906,7 +737,6 @@ priv = window->priv; - priv->icon_size = 1; priv->focused_item = NULL; priv->saved_focused_filename = NULL; priv->scroll_value = 0; @@ -915,11 +745,7 @@ hcp_window_retrieve_configuration (window); - if (priv->icon_size == 0) - priv->view = hcp_app_view_new (HCP_ICON_SIZE_SMALL); - else - priv->view = hcp_app_view_new (HCP_ICON_SIZE_LARGE); - + priv->view = hcp_app_view_new (); g_signal_connect (G_OBJECT (priv->view), "focus-changed", G_CALLBACK (hcp_window_app_view_focus_cb), window); @@ -967,7 +793,8 @@ static void hcp_window_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { - static gboolean enforce_state = TRUE; +/* Buggy applets can crash controlpanel, so disabled for now */ + static gboolean enforce_state = FALSE; GTK_WIDGET_CLASS (hcp_window_parent_class)->size_allocate (widget, allocation); @@ -983,7 +810,6 @@ program->execute = 0; hcp_app_launch (window->priv->focused_item, FALSE); } - enforce_state = FALSE; } }
- Previous message: [maemo-commits] r16619 - in projects/haf/trunk/hildon-thumbnail: . debian
- Next message: [maemo-commits] r16622 - projects/haf/trunk/hildon-control-panel
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]