[maemo-commits] [maemo-commits] r12798 - in projects/haf/trunk/hildon-1: . examples src

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Tue Jul 24 11:24:46 EEST 2007
Author: mdk
Date: 2007-07-24 11:24:43 +0300 (Tue, 24 Jul 2007)
New Revision: 12798

Added:
   projects/haf/trunk/hildon-1/examples/hildon-find-toolbar-example.c
Modified:
   projects/haf/trunk/hildon-1/ChangeLog
   projects/haf/trunk/hildon-1/examples/Makefile.am
   projects/haf/trunk/hildon-1/src/hildon-find-toolbar.c
   projects/haf/trunk/hildon-1/src/hildon-find-toolbar.h
Log:
Adding a few new functions to control the selected item: hildon_find_toolbar_set_active, hildon_find_toolbar_set_active_iter, hildon_find_toolbar_get_active,  hildon_find_toolbar_get_active_iter . They correspond to respective GtkComboBox functions. Fixes NB#52301.
Adding the example to test the new functionality.


Modified: projects/haf/trunk/hildon-1/ChangeLog
===================================================================
--- projects/haf/trunk/hildon-1/ChangeLog	2007-07-23 15:59:22 UTC (rev 12797)
+++ projects/haf/trunk/hildon-1/ChangeLog	2007-07-24 08:24:43 UTC (rev 12798)
@@ -1,3 +1,16 @@
+2007-07-24  Michael Dominic Kostrzewa  <michael.kostrzewa at nokia.com> 
+
+	* src/hildon-find-toolbar.c:
+	* src/hildon-find-toolbar.h: Adding a few new functions to control the
+	selected item: hildon_find_toolbar_set_active,
+	hildon_find_toolbar_set_active_iter, hildon_find_toolbar_get_active, 
+	hildon_find_toolbar_get_active_iter . They correspond to respective
+	GtkComboBox functions. Fixes NB#52301.
+
+	* examples/Makefile.am:
+	* examples/hildon-find-toolbar-example.c: Adding the example to test the
+	new functionality.
+
 2007-07-23  Michael Dominic Kostrzewa  <michael.kostrzewa at nokia.com> 
 
 	* examples/Makefile.am:

Modified: projects/haf/trunk/hildon-1/examples/Makefile.am
===================================================================
--- projects/haf/trunk/hildon-1/examples/Makefile.am	2007-07-23 15:59:22 UTC (rev 12797)
+++ projects/haf/trunk/hildon-1/examples/Makefile.am	2007-07-24 08:24:43 UTC (rev 12798)
@@ -33,13 +33,19 @@
 					  hildon-date-editor-example			\
 					  hildon-bread-crumb-trail-example		\
 					  hildon-finger-example				\
-					  hildon-seekbar-example
+					  hildon-seekbar-example			\
+					  hildon-find-toolbar-example
 
 # Hildon window
 hildon_window_example_LDADD		= $(HILDON_OBJ_LIBS)
 hildon_window_example_CFLAGS		= $(HILDON_OBJ_CFLAGS)
 hildon_window_example_SOURCES		= hildon-window-example.c
 
+# Hildon find toolbar
+hildon_find_toolbar_example_LDADD	= $(HILDON_OBJ_LIBS)
+hildon_find_toolbar_example_CFLAGS	= $(HILDON_OBJ_CFLAGS)
+hildon_find_toolbar_example_SOURCES	= hildon-find-toolbar-example.c
+
 # Hildon seekbar
 hildon_seekbar_example_LDADD		= $(HILDON_OBJ_LIBS)
 hildon_seekbar_example_CFLAGS		= $(HILDON_OBJ_CFLAGS)

Added: projects/haf/trunk/hildon-1/examples/hildon-find-toolbar-example.c
===================================================================
--- projects/haf/trunk/hildon-1/examples/hildon-find-toolbar-example.c	2007-07-23 15:59:22 UTC (rev 12797)
+++ projects/haf/trunk/hildon-1/examples/hildon-find-toolbar-example.c	2007-07-24 08:24:43 UTC (rev 12798)
@@ -0,0 +1,69 @@
+/*
+ * This file is a part of hildon examples
+ *
+ * Copyright (C) 2005, 2006 Nokia Corporation, all rights reserved.
+ *
+ * Author: Michael Dominic Kostrzewa <michael.kostrzewa at nokia.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#include                                        <stdio.h>
+#include                                        <stdlib.h>
+#include                                        <glib.h>
+#include                                        <gtk/gtk.h>
+#include                                        "hildon.h"
+
+int
+main                                            (int argc, 
+                                                 char **args)
+{
+    gtk_init (&argc, &args);
+    
+    HildonProgram *program = hildon_program_get_instance ();
+
+    GtkWidget *window = hildon_window_new ();
+    hildon_program_add_window (program, HILDON_WINDOW (window));    
+
+    gtk_container_set_border_width (GTK_CONTAINER (window), 6);
+
+    GtkListStore *store = gtk_list_store_new (1, G_TYPE_STRING);
+    GtkTreeIter iter;
+    gtk_list_store_append (store, &iter);
+    gtk_list_store_set (store, &iter, 0, "First", -1);
+    
+    gtk_list_store_append (store, &iter);
+    gtk_list_store_set (store, &iter, 0, "Second", -1);
+
+    gtk_list_store_append (store, &iter);
+    gtk_list_store_set (store, &iter, 0, "Third", -1);
+
+    HildonFindToolbar *toolbar = HILDON_FIND_TOOLBAR (hildon_find_toolbar_new_with_model ("Find", store, 0));
+    hildon_find_toolbar_set_active (toolbar, 0);
+    
+    g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (gtk_main_quit), NULL);
+    
+    hildon_window_add_toolbar (HILDON_WINDOW (window), GTK_TOOLBAR (toolbar));
+    gtk_widget_show_all (GTK_WIDGET (toolbar));
+
+    gtk_widget_show_all (GTK_WIDGET (window));
+    
+    gtk_main ();
+    return 0;
+}
+
+

Modified: projects/haf/trunk/hildon-1/src/hildon-find-toolbar.c
===================================================================
--- projects/haf/trunk/hildon-1/src/hildon-find-toolbar.c	2007-07-23 15:59:22 UTC (rev 12797)
+++ projects/haf/trunk/hildon-1/src/hildon-find-toolbar.c	2007-07-24 08:24:43 UTC (rev 12798)
@@ -829,3 +829,89 @@
         gtk_widget_grab_focus (GTK_WIDGET (entry));
 }
 
+/**
+ * hildon_find_toolbar_set_active:
+ * @toolbar: A find toolbar to operate on
+ * @index: An index in the model passed during construction, or -1 to have no active item
+ *
+ * Sets the active item on the toolbar's combo-box. Simply calls gtk_combo_box_set_active on 
+ * the HildonFindToolbar's combo.
+ * 
+ */
+void
+hildon_find_toolbar_set_active                  (HildonFindToolbar *toolbar,
+                                                 gint index)
+{
+    HildonFindToolbarPrivate *priv;
+
+    g_return_if_fail (HILDON_IS_FIND_TOOLBAR (toolbar));
+    priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (toolbar);
+
+    gtk_combo_box_set_active (GTK_COMBO_BOX (priv->entry_combo_box), index);
+}
+
+/**
+ * hildon_find_toolbar_get_active:
+ * @toolbar: A find toolbar to query
+ *
+ * Gets the index of the currently active item, or -1 if there's no active item. Simply 
+ * calls gtk_combo_box_get_active on the HildonFindToolbar's combo.
+ *
+ * Returns: An integer which is the index of the currently active item, or -1 if there's no active item.
+ * 
+ */
+gint
+hildon_find_toolbar_get_active                  (HildonFindToolbar *toolbar)
+{
+    HildonFindToolbarPrivate *priv;
+
+    g_return_val_if_fail (HILDON_IS_FIND_TOOLBAR (toolbar), -1);
+    priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (toolbar);
+
+    return gtk_combo_box_get_active (GTK_COMBO_BOX (priv->entry_combo_box));
+}
+
+/**
+ * hildon_find_toolbar_set_active_iter:
+ * @toolbar: A find toolbar to operate on
+ * @iter: An iter to make active
+ *
+ * Sets the current active item to be the one referenced by iter. Simply calls 
+ * gtk_combo_box_set_active_iter on the HildonFindToolbar's combo.
+ * 
+ */
+void
+hildon_find_toolbar_set_active_iter             (HildonFindToolbar *toolbar, 
+                                                 GtkTreeIter *iter)
+{
+    HildonFindToolbarPrivate *priv;
+
+    g_return_if_fail (HILDON_IS_FIND_TOOLBAR (toolbar));
+    priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (toolbar);
+
+    gtk_combo_box_set_active_iter (GTK_COMBO_BOX (priv->entry_combo_box), iter);
+}
+
+/**
+ * hildon_find_toolbar_get_active_iter:
+ * @toolbar: A find toolbar to query
+ * @iter: The uninitialized GtkTreeIter
+ *
+ * Sets iter to point to the current active item, if it exists. Simply calls 
+ * gtk_combo_box_get_active_iter on the HildonFindToolbar's combo.
+ * 
+ * Returns: TRUE, if iter was set
+ *
+ */
+gboolean
+hildon_find_toolbar_get_active_iter             (HildonFindToolbar *toolbar, 
+                                                 GtkTreeIter *iter)
+{
+    HildonFindToolbarPrivate *priv;
+
+    g_return_val_if_fail (HILDON_IS_FIND_TOOLBAR (toolbar), FALSE);
+    priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (toolbar);
+
+    return gtk_combo_box_get_active_iter (GTK_COMBO_BOX (priv->entry_combo_box), iter);
+}
+

Modified: projects/haf/trunk/hildon-1/src/hildon-find-toolbar.h
===================================================================
--- projects/haf/trunk/hildon-1/src/hildon-find-toolbar.h	2007-07-23 15:59:22 UTC (rev 12797)
+++ projects/haf/trunk/hildon-1/src/hildon-find-toolbar.h	2007-07-24 08:24:43 UTC (rev 12798)
@@ -88,6 +88,21 @@
 hildon_find_toolbar_highlight_entry             (HildonFindToolbar *ftb,
                                                  gboolean get_focus);
 
+void
+hildon_find_toolbar_set_active                  (HildonFindToolbar *toolbar,
+                                                 gint index);
+
+gint
+hildon_find_toolbar_get_active                  (HildonFindToolbar *toolbar);
+
+void
+hildon_find_toolbar_set_active_iter             (HildonFindToolbar *toolbar, 
+                                                 GtkTreeIter *iter);
+
+gboolean
+hildon_find_toolbar_get_active_iter             (HildonFindToolbar *toolbar, 
+                                                 GtkTreeIter *iter);
+
 G_END_DECLS
 
 #endif                                          /* __HILDON_FIND_TOOLBAR_H__ */


More information about the maemo-commits mailing list