* 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.
+ * 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
* #GtkListStore and can be accesed using a property 'list'. Entries are added
* automatically to the list when the search button is pressed.
*
- */
+ */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-#include "hildon-find-toolbar.h"
-#include "hildon-defines.h"
-#include <gdk/gdkkeysyms.h>
-#include <gtk/gtklabel.h>
-#include <gtk/gtkentry.h>
-#include <gtk/gtkbutton.h>
-#include <gtk/gtktoolbutton.h>
-#include <gtk/gtktoolitem.h>
-#include <gtk/gtkcomboboxentry.h>
-#include <gtk/gtkseparatortoolitem.h>
#include <string.h>
#include <libintl.h>
+#include <gdk/gdkkeysyms.h>
+
+#include "hildon-find-toolbar.h"
+#include "hildon-defines.h"
#include "hildon-find-toolbar-private.h"
#define _(String) \
hildon_find_toolbar_emit_close (GtkButton *button,
gpointer self);
+#ifdef MAEMO_GTK
static void
hildon_find_toolbar_emit_invalid_input (GtkEntry *entry,
GtkInvalidInputType type,
gpointer self);
+#endif
static void
hildon_find_toolbar_entry_activate (GtkWidget *widget,
g_free (string);
- return TRUE;
+ return FALSE;
}
static void
hildon_find_toolbar_emit_close (GtkButton *button,
gpointer self)
{
+#ifdef MAEMO_GTK
HildonFindToolbarPrivate *priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (self);
g_assert (priv);
{
hildon_gtk_im_context_hide (GTK_ENTRY (entry)->im_context);
}
+#endif
/* Clicked close button */
g_signal_emit_by_name (self, "close", NULL);
}
+#ifdef MAEMO_GTK
static void
hildon_find_toolbar_emit_invalid_input (GtkEntry *entry,
GtkInvalidInputType type,
if(type == GTK_INVALID_INPUT_MAX_CHARS_REACHED)
g_signal_emit_by_name (self, "invalid_input", NULL);
}
+#endif
static void
hildon_find_toolbar_entry_activate (GtkWidget *widget,
*
* Gets emitted when the maximum search prefix length is reached and
* user tries to type more.
- */
+ */
HildonFindToolbar_signal[INVALID_INPUT] =
g_signal_new(
"invalid_input", HILDON_TYPE_FIND_TOOLBAR,
{
GtkToolItem *label_container;
GtkToolItem *entry_combo_box_container;
+ GtkAlignment *alignment;
HildonFindToolbarPrivate *priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (self);
g_assert (priv);
/* ComboBoxEntry for search prefix string / history list */
priv->entry_combo_box = GTK_COMBO_BOX_ENTRY (gtk_combo_box_entry_new ());
+
+#ifdef MAEMO_GTK
g_signal_connect (hildon_find_toolbar_get_entry(priv),
"invalid_input",
G_CALLBACK(hildon_find_toolbar_emit_invalid_input), self);
+#endif
entry_combo_box_container = gtk_tool_item_new ();
+ alignment = GTK_ALIGNMENT (gtk_alignment_new (0, 0.5, 1, 0));
gtk_tool_item_set_expand (entry_combo_box_container, TRUE);
- gtk_container_add (GTK_CONTAINER (entry_combo_box_container),
+ gtk_container_add (GTK_CONTAINER (alignment),
GTK_WIDGET (priv->entry_combo_box));
+ gtk_container_add (GTK_CONTAINER (entry_combo_box_container),
+ GTK_WIDGET (alignment));
gtk_widget_show_all(GTK_WIDGET (entry_combo_box_container));
gtk_toolbar_insert (GTK_TOOLBAR (self), entry_combo_box_container, -1);
g_signal_connect (hildon_find_toolbar_get_entry (priv),
G_CALLBACK(hildon_find_toolbar_emit_search), self);
gtk_widget_show_all( GTK_WIDGET(priv->find_button));
gtk_toolbar_insert ( GTK_TOOLBAR(self), priv->find_button, -1);
+ gtk_widget_set_size_request (GTK_WIDGET (priv->find_button), 72, -1);
if ( GTK_WIDGET_CAN_FOCUS( GTK_BIN(priv->find_button)->child) )
GTK_WIDGET_UNSET_FLAGS(
GTK_BIN(priv->find_button)->child, GTK_CAN_FOCUS);
gtk_image_new_from_icon_name ("qgn_toolb_gene_close",
HILDON_ICON_SIZE_TOOLBAR),
"Close");
+ gtk_widget_set_size_request (GTK_WIDGET (priv->close_button), 72, -1);
g_signal_connect(priv->close_button, "clicked",
G_CALLBACK(hildon_find_toolbar_emit_close), self);
gtk_widget_show_all(GTK_WIDGET(priv->close_button));
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);
+}
+
+/**
+ * hildon_find_toolbar_get_last_index
+ * @toolbar: A find toolbar to query
+ *
+ * Returns the index of the last (most recently added) item in the toolbar.
+ * Can be used to set this item active in the history-append signal.
+ *
+ *
+ * Returns: Index of the last entry
+ *
+ */
+gint32
+hildon_find_toolbar_get_last_index (HildonFindToolbar *toolbar)
+{
+ HildonFindToolbarPrivate *priv;
+ GtkTreeModel *filter_model;
+
+ g_return_val_if_fail (HILDON_IS_FIND_TOOLBAR (toolbar), FALSE);
+ priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (toolbar);
+
+ filter_model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->entry_combo_box));
+
+ if (filter_model == NULL)
+ return 0;
+
+ gint i = 0;
+ GtkTreeIter iter;
+
+ gtk_tree_model_get_iter_first (filter_model, &iter);
+
+ while (gtk_tree_model_iter_next (filter_model, &iter))
+ i++;
+
+ return i;
+}
+