[maemo-commits] [maemo-commits] r18800 - in projects/haf/trunk/hildon-control-panel: . src

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Mon Jun 29 17:21:32 EEST 2009
Author: paradi
Date: 2009-06-29 17:21:28 +0300 (Mon, 29 Jun 2009)
New Revision: 18800

Modified:
   projects/haf/trunk/hildon-control-panel/ChangeLog
   projects/haf/trunk/hildon-control-panel/src/hcp-app-view.c
   projects/haf/trunk/hildon-control-panel/src/hcp-app.c
   projects/haf/trunk/hildon-control-panel/src/hcp-app.h
   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:
 * src/hcp-app-view.c:
 * src/hcp-grid.c:
 * src/hcp-grid.h:
 * src/hcp-window.c:
 * src/hcp-app.c:
 * src/hcp-app.h:
 Interface changed from iconview to buttons in frame.
 Fixes: NB#116610 - Share account icon in not fully highlighted in
 Control Panel
 Fixes: NB#116128 - IN CP,horizontal scroll indicator is seen...
 Fixes: NB#115484 - Control panel: highlighted focus field for date and
 time settings too short...



Modified: projects/haf/trunk/hildon-control-panel/ChangeLog
===================================================================
--- projects/haf/trunk/hildon-control-panel/ChangeLog	2009-06-29 07:52:24 UTC (rev 18799)
+++ projects/haf/trunk/hildon-control-panel/ChangeLog	2009-06-29 14:21:28 UTC (rev 18800)
@@ -1,3 +1,17 @@
+2009-06-29 Peter Aradi <peter.aradi at maemo.org>
+	* src/hcp-app-view.c:
+	* src/hcp-grid.c:
+	* src/hcp-grid.h:
+	* src/hcp-window.c:
+	* src/hcp-app.c:
+	* src/hcp-app.h:
+	Fixes: NB#116610 - Share account icon in not fully highlighted in
+	Control Panel
+	Fixes: NB#116128 - IN CP,horizontal scroll indicator is seen...
+	Fixes: NB#115484 - Control panel: highlighted focus field for date and
+	time settings too short...
+
+
 2009-05-29 Kimmo Hämäläinen <kimmo.hamalainen at nokia.com>
 
 	Release 2.2.8

Modified: projects/haf/trunk/hildon-control-panel/src/hcp-app-view.c
===================================================================
--- projects/haf/trunk/hildon-control-panel/src/hcp-app-view.c	2009-06-29 07:52:24 UTC (rev 18799)
+++ projects/haf/trunk/hildon-control-panel/src/hcp-app-view.c	2009-06-29 14:21:28 UTC (rev 18800)
@@ -75,47 +75,25 @@
 {
   GtkWidget *grid;
 
-  grid = hcp_grid_new (HILDON_UI_MODE_NORMAL);
+  grid = hcp_grid_new ();
   gtk_widget_set_name (grid, "hildon-control-panel-grid");
 
   return grid;
 }
 
-static GtkWidget*
-hcp_app_view_create_separator (const gchar *label)
-{
-  GtkWidget *hbox = gtk_hbox_new (FALSE, 5);
-  GtkWidget *separator_1 = gtk_hseparator_new ();
-  GtkWidget *separator_2 = gtk_hseparator_new ();
-  GtkWidget *label_1 = gtk_label_new (label);
-
-  gtk_widget_set_name (separator_1, "hildon-control-panel-separator");
-  gtk_widget_set_name (separator_2, "hildon-control-panel-separator");
-  gtk_box_pack_start (GTK_BOX(hbox), separator_1, TRUE, TRUE, 0);
-  gtk_box_pack_start (GTK_BOX(hbox), label_1, FALSE, FALSE, 5);
-  gtk_box_pack_start (GTK_BOX(hbox), separator_2, TRUE, TRUE, 0);
-
-  return hbox;
-}
-
 static HCPApp *
-hcp_app_view_get_selected_app (GtkWidget *widget, GtkTreePath *path)
+hcp_app_view_get_selected_app (GtkWidget *widget, gpointer pos)
 {
   GtkTreeModel *model;
   HCPApp *app = NULL;
   GtkTreeIter iter;
-  gint item_pos;
+  gint item_pos = GPOINTER_TO_INT(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);
+  g_return_val_if_fail (HCP_IS_GRID (widget), NULL);
 
-  model = gtk_icon_view_get_model (GTK_ICON_VIEW (widget));
+  model = hcp_grid_get_model (HCP_GRID(widget));
 
-  if (path == NULL) return NULL;
-
-  item_pos = gtk_tree_path_get_indices (path) [0];
-
   if (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (model), 
                                      &iter, NULL, item_pos)) {
     gtk_tree_model_get (GTK_TREE_MODEL (model), &iter, 
@@ -128,12 +106,11 @@
 
 static void
 hcp_app_view_launch_app (GtkWidget *widget, 
-                         GtkTreePath *path, 
+                         gpointer pos,
                          gpointer user_data)
 {
+  HCPApp *app = hcp_app_view_get_selected_app (widget, pos);
 
-  HCPApp *app = hcp_app_view_get_selected_app (widget, path);
-
   /* important for state saving of executed app */
   g_signal_emit (G_OBJECT (widget->parent), 
                  signals[SIGNAL_FOCUS_CHANGED], 
@@ -152,7 +129,7 @@
   gchar *name = NULL;
   gchar *text_domain = NULL;
 
-  store = gtk_icon_view_get_model (GTK_ICON_VIEW (grid));
+  store = hcp_grid_get_model(grid);
 
   g_object_get (G_OBJECT (app),
                 "name", &name,
@@ -185,7 +162,7 @@
   /* If a group has items */
   if (category->apps)
   {
-    GtkWidget *grid, *separator;
+    GtkWidget *grid, *frame;
     GtkListStore *store;
     GList *focus_chain = NULL;
 
@@ -195,21 +172,20 @@
     g_signal_connect (grid, "item-activated",
                       G_CALLBACK (hcp_app_view_launch_app),
                       NULL);
-  
-    /* If we are creating a group with a defined name, we use
-     * it in the separator */
-    separator = hcp_app_view_create_separator (_(category->name));
 
-    /* Pack the separator and the corresponding grid to the vbox */
-    gtk_box_pack_start (GTK_BOX (view), separator, FALSE, FALSE, 0);
-    gtk_box_pack_start (GTK_BOX (view), grid, FALSE, TRUE, 0);
+    /* frame title is used instead of separator */
+    frame = gtk_frame_new (_(category->name));
+    gtk_frame_set_label_align (GTK_FRAME(frame), 0.5, 0.5);
+    gtk_container_add (GTK_CONTAINER(frame), grid);
 
+    gtk_box_pack_start (GTK_BOX (view), frame, FALSE, TRUE, 0);
+
     gtk_container_get_focus_chain (GTK_CONTAINER (view), &focus_chain);
     focus_chain = g_list_append (focus_chain, grid);
     gtk_container_set_focus_chain (GTK_CONTAINER (view), focus_chain);
     g_list_free (focus_chain);
 
-    gtk_icon_view_set_model (GTK_ICON_VIEW (grid), 
+    hcp_grid_set_model (HCP_GRID(grid), 
                              GTK_TREE_MODEL (store));
 
     g_slist_foreach (category->apps,
@@ -232,7 +208,7 @@
 
   g_object_set (G_OBJECT (view), 
                 "homogeneous", FALSE,
-                "spacing", 6, 
+                "spacing", 35, 
                 NULL);
 }
 

Modified: projects/haf/trunk/hildon-control-panel/src/hcp-app.c
===================================================================
--- projects/haf/trunk/hildon-control-panel/src/hcp-app.c	2009-06-29 07:52:24 UTC (rev 18799)
+++ projects/haf/trunk/hildon-control-panel/src/hcp-app.c	2009-06-29 14:21:28 UTC (rev 18800)
@@ -494,27 +494,6 @@
 }
 
 void
-hcp_app_focus (HCPApp *app)
-{
-  HCPAppPrivate *priv;
-
-  g_return_if_fail (app);
-  g_return_if_fail (HCP_IS_APP (app));
-
-  priv = app->priv;
-
-  if (priv->grid) 
-  {
-    GtkTreePath *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);
-  }
-}
-
-void
 hcp_app_save_state (HCPApp *app)
 {
   HCPAppPrivate *priv;

Modified: projects/haf/trunk/hildon-control-panel/src/hcp-app.h
===================================================================
--- projects/haf/trunk/hildon-control-panel/src/hcp-app.h	2009-06-29 07:52:24 UTC (rev 18799)
+++ projects/haf/trunk/hildon-control-panel/src/hcp-app.h	2009-06-29 14:21:28 UTC (rev 18800)
@@ -70,8 +70,6 @@
 void         hcp_app_launch         (HCPApp   *app, 
                                      gboolean  user_activated);
 
-void         hcp_app_focus          (HCPApp   *app); 
-
 void         hcp_app_save_state     (HCPApp   *app);
 
 gboolean     hcp_app_is_running     (HCPApp   *app);

Modified: projects/haf/trunk/hildon-control-panel/src/hcp-grid.c
===================================================================
--- projects/haf/trunk/hildon-control-panel/src/hcp-grid.c	2009-06-29 07:52:24 UTC (rev 18799)
+++ projects/haf/trunk/hildon-control-panel/src/hcp-grid.c	2009-06-29 14:21:28 UTC (rev 18800)
@@ -39,22 +39,41 @@
 #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_TABLE)
 
-#define HCP_GRID_ITEM_WIDTH  328 
+#define HCP_GRID_ITEM_WIDTH  372
 #define HCP_GRID_X_PADDING   4
 #define HCP_GRID_Y_PADDING   2
-#define HCP_ICON_SIZE        HILDON_ICON_PIXEL_SIZE_THUMB
+#define HCP_ICON_SIZE        HILDON_ICON_PIXEL_SIZE_FINGER
+typedef enum
+{
+  SIGNAL_ITEM_ACTIVATED,
+  N_SIGNALS
+} HCPGridSignals;
 
+static gint signals[N_SIGNALS];
+
 struct _HCPGridPrivate {
-  GtkCellRenderer *text_cell;
-  GtkCellRenderer *pixbuf_cell;
   gboolean         can_move_focus;
   gboolean         focused_in;
-/*  gint             row_height;*/
   gint             icon_size;
+  GtkTreeModel     *model;
 };
 
+static void
+hcp_grid_button_clicked (GtkButton* button,
+                         gpointer pos)
+{
+  g_return_if_fail (button);
+  g_return_if_fail (GTK_IS_BUTTON(button));
+
+  GtkWidget* grid = gtk_widget_get_parent (GTK_WIDGET(button));
+
+  g_return_if_fail (grid);
+  g_return_if_fail (HCP_IS_GRID(grid));
+  g_signal_emit (grid, signals[SIGNAL_ITEM_ACTIVATED], 0, pos);
+}
+
 static gboolean
 hcp_grid_update_icon (GtkTreeModel *model,
                       GtkTreePath  *path,
@@ -70,8 +89,6 @@
   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; */
-
   gtk_tree_model_get (GTK_TREE_MODEL (model), iter, 
                       HCP_STORE_APP, &app,
                       -1);
@@ -101,9 +118,8 @@
 
     icon_pixbuf = gtk_icon_theme_load_icon (icon_theme,
                                             HCP_DEFAULT_ICON_BASENAME,
-                                        /*    priv->icon_size, */
-     					    HCP_ICON_SIZE,
-                                            0, 
+                                            HCP_ICON_SIZE,
+                                            0,
                                             &error);
 
     if (icon_pixbuf == NULL) 
@@ -117,6 +133,44 @@
                       HCP_STORE_ICON, icon_pixbuf, 
                       -1);
 
+  /* refreshing buttons */
+  gchar *l;
+  gtk_tree_model_get (GTK_TREE_MODEL (model), iter, 
+                      HCP_STORE_LABEL, &l,
+                      -1);
+
+  GtkWidget *label = gtk_label_new(l);
+
+  GtkWidget *image = gtk_image_new_from_pixbuf (icon_pixbuf);
+
+  GtkWidget *hbox = gtk_hbox_new (FALSE, HILDON_MARGIN_DEFAULT);
+
+  GtkWidget *align = gtk_alignment_new (0,0.5,0,0);
+  gtk_alignment_set_padding (GTK_ALIGNMENT(align), 0, 0, 0, HILDON_MARGIN_DOUBLE);
+
+  gtk_widget_set_size_request (label, 290, -1);
+  gtk_misc_set_alignment (GTK_MISC(label), 0,0.5);
+
+  gtk_box_pack_start (GTK_BOX(hbox), image, FALSE, FALSE, 0);
+  gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 0);
+
+  gtk_label_set_line_wrap (label, FALSE);
+
+  gtk_container_add (GTK_CONTAINER(align), hbox);
+
+  GtkWidget *button = gtk_button_new();
+  gtk_widget_set_size_request (button, HCP_GRID_ITEM_WIDTH, 70);
+
+  gtk_container_add (GTK_CONTAINER(button), align);
+
+  gint *i;
+  i = gtk_tree_path_get_indices (path);
+  gtk_table_attach_defaults (GTK_TABLE(user_data), button, *i%2, *i%2+1, *i/2, *i/2+1);
+
+  g_signal_connect (button, "clicked",
+                      G_CALLBACK (hcp_grid_button_clicked),
+                      GINT_TO_POINTER(*i));
+
   g_free (icon);
 
   return FALSE;
@@ -125,6 +179,15 @@
 static void
 hcp_grid_class_init (HCPGridClass *klass)
 {
+  signals[SIGNAL_ITEM_ACTIVATED] =
+        g_signal_new ("item-activated",
+                      G_OBJECT_CLASS_TYPE (klass),
+                      G_SIGNAL_RUN_FIRST,
+                      0,
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__POINTER,
+                      G_TYPE_NONE, 1,
+                      G_TYPE_POINTER);
 
   g_type_class_add_private (klass, sizeof (HCPGridPrivate));
 
@@ -134,68 +197,54 @@
 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 = HCP_ICON_SIZE;
 
-  grid->priv->pixbuf_cell = gtk_cell_renderer_pixbuf_new ();
-
-  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (grid), 
-		  	      grid->priv->pixbuf_cell, 
-			      FALSE);
-
-  g_object_set (grid->priv->pixbuf_cell, 
-		"xpad", HCP_GRID_X_PADDING, 
-		"ypad", HCP_GRID_Y_PADDING, 
+  g_object_set (grid, 
+		"n-rows", 1, 
+		"n-columns", 2, 
+		"homogeneous", TRUE,
                 NULL);
 
-  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (grid),
-                                  grid->priv->pixbuf_cell, 
-			          "pixbuf", 0,
-                                  NULL);
+/*  gtk_table_set_col_spacings (GTK_TABLE(grid), 8); */
 
-  grid->priv->text_cell = gtk_cell_renderer_text_new ();
+}
 
-  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (grid), 
-		  	      grid->priv->text_cell, 
-			      FALSE);
+GtkTreeModel *
+hcp_grid_get_model (HCPGrid *grid)
+{
+  g_return_val_if_fail (HCP_GRID(grid), NULL);
 
-  g_object_set (grid->priv->text_cell, 
-                "yalign", 0.5,
-                NULL);
+  return grid->priv->model;
+}
 
-  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (grid),
-                                  grid->priv->text_cell, 
-				  "text", 1, 
-				  NULL);  
+void
+hcp_grid_set_model (HCPGrid *grid, GtkTreeModel *model)
+{
+  g_return_if_fail (HCP_GRID(grid));
+  g_return_if_fail (model == NULL || GTK_IS_TREE_MODEL (model));
 
-  gtk_icon_view_set_margin (GTK_ICON_VIEW (grid), 0);
+  if (grid->priv->model == model)
+    return;
 
-  gtk_icon_view_set_column_spacing (GTK_ICON_VIEW (grid), 8);
-  gtk_icon_view_set_row_spacing (GTK_ICON_VIEW (grid), 0);
-  gtk_icon_view_set_spacing (GTK_ICON_VIEW (grid), 6);
+/* TODO free up previous model. disconnect handlers? */
 
-  gtk_icon_view_set_orientation (GTK_ICON_VIEW (grid), 
-                                 GTK_ORIENTATION_HORIZONTAL);
+  grid->priv->model = model;
+}
 
-  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), 
-		  		HCP_GRID_ITEM_WIDTH);
- 
-}
 void
 hcp_grid_refresh_icons (HCPGrid* grid)
 {
   GtkTreeModel* model;
 
-  model = gtk_icon_view_get_model (GTK_ICON_VIEW (grid));
+  model = hcp_grid_get_model (HCP_GRID(grid));
+
   gtk_tree_model_foreach (model, hcp_grid_update_icon, grid);
+
   GtkRequisition req;
   gtk_widget_size_request (GTK_WIDGET(grid), &req);
   GtkAllocation alloc = {0,0,req.width, req.height};
@@ -204,7 +253,7 @@
 }
 
 GtkWidget *
-hcp_grid_new (HildonUIMode uimode)
+hcp_grid_new (void)
 {
   GtkWidget *grid = g_object_new (HCP_TYPE_GRID, NULL);
 

Modified: projects/haf/trunk/hildon-control-panel/src/hcp-grid.h
===================================================================
--- projects/haf/trunk/hildon-control-panel/src/hcp-grid.h	2009-06-29 07:52:24 UTC (rev 18799)
+++ projects/haf/trunk/hildon-control-panel/src/hcp-grid.h	2009-06-29 14:21:28 UTC (rev 18800)
@@ -25,7 +25,6 @@
 #define HCP_GRID_H
 
 #include <gtk/gtk.h>
-
 G_BEGIN_DECLS
 
 typedef struct _HCPGridPrivate HCPGridPrivate;
@@ -42,12 +41,12 @@
 #define HCP_GRID_NUM_COLUMNS       2
 
 typedef struct {
-  GtkIconView parent;
+  GtkTable parent;
   HCPGridPrivate* priv;
 } HCPGrid;
 
 typedef struct {
-  GtkIconViewClass parent_class;
+  GtkTableClass parent_class;
 } HCPGridClass;
 
 GType hcp_grid_get_type (void);
@@ -59,9 +58,10 @@
   HCP_STORE_NUM_COLUMNS
 } HCPStoreColumn;
 
-GtkWidget* hcp_grid_new (HildonUIMode);
+GtkWidget* hcp_grid_new (void);
 void hcp_grid_refresh_icons (HCPGrid*);
-
+void hcp_grid_set_model (HCPGrid *grid, GtkTreeModel *model);
+GtkTreeModel* hcp_grid_get_model (HCPGrid *grid);
 G_END_DECLS
 
 #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	2009-06-29 07:52:24 UTC (rev 18799)
+++ projects/haf/trunk/hildon-control-panel/src/hcp-window.c	2009-06-29 14:21:28 UTC (rev 18800)
@@ -473,9 +473,6 @@
 
   g_free (focused);
 
-  if (app)
-    hcp_app_focus (app);
-
   hcp_window_enforce_state (window);
 }
 
@@ -512,28 +509,10 @@
 
   priv = window->priv;
 
-  /* Why is this not read from the gtkrc?? -- Jobi */
-#if 0 
-  /* Control Panel Grid */
-  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\"");
-#endif
-  
   program = HILDON_PROGRAM (hildon_program_get_instance ());
 
   hildon_program_add_window (program, HILDON_WINDOW (window));
-  
+
   gtk_window_set_title (GTK_WINDOW (window),
                         HCP_TITLE);
 
@@ -588,11 +567,11 @@
   gtk_container_add (GTK_CONTAINER (window), scrolled_window);
 
   GtkWidget *align = gtk_alignment_new (0,0,0,0);
-  gtk_alignment_set_padding (GTK_ALIGNMENT(align),0,0, 68,0);
 
+  gtk_alignment_set_padding (GTK_ALIGNMENT(align),0,0, HILDON_MARGIN_TRIPLE,HILDON_MARGIN_TRIPLE);
+
   gtk_container_add (GTK_CONTAINER(align), GTK_WIDGET(priv->view));
 
-  /*gtk_container_add (GTK_CONTAINER(view), align); */
   hildon_pannable_area_add_with_viewport (
           HILDON_PANNABLE_AREA (scrolled_window),
           align);

More information about the maemo-commits mailing list