[anjal] Do basic stuff for Search. Now we have a Icon entry. Next make it work



commit 15db51d9ae006d7ac01a7678c0f83019ba410eeb
Author: Srinivasa Ragavan <sragavan novell com>
Date:   Tue May 12 00:07:37 2009 +0530

    Do basic stuff for Search. Now we have a Icon entry. Next make it work
    :-)
---
 src/Makefile.am   |    4 +-
 src/mail-search.c |  147 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/mail-search.h |   57 ++++++++++++++++++++
 src/mail-shell.c  |    4 +-
 4 files changed, 209 insertions(+), 3 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index 0cb997a..711113e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -54,7 +54,9 @@ anjal_SOURCES = \
 	mail-account-view.c \
 	mail-account-view.h \
 	mail-settings-view.c \
-	mail-settings-view.h
+	mail-settings-view.h \
+	mail-search.c \
+	mail-search.h
 
 if ENABLE_WEBKIT
 anjal_SOURCES += em-webkit-stream.c \
diff --git a/src/mail-search.c b/src/mail-search.c
new file mode 100644
index 0000000..1cbfbbc
--- /dev/null
+++ b/src/mail-search.c
@@ -0,0 +1,147 @@
+/*
+ * This program 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; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program 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 the program; if not, see <http://www.gnu.org/licenses/>  
+ *
+ *
+ * Authors:
+ *		Srinivasa Ragavan <sragavan novell com>
+ *
+ * Copyright (C) 2009 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+#include <glib/gi18n.h>
+#include <gconf/gconf-client.h>
+#include "mail-shell.h"
+#include "mail-view.h"
+#include "mail-component.h"
+#include <gdk/gdkkeysyms.h>
+#include "misc/e-icon-entry.h"
+
+#include "mail-search.h"
+
+enum {
+	SEARCH_ACTIVATE,
+	SEARCH_CLEAR,
+	LAST_SIGNAL
+};
+
+static guint mail_search_signals[LAST_SIGNAL];
+
+struct  _MailSearchPrivate {
+	GtkWidget *entry;
+	GtkWidget *entry_box;
+	GtkWidget *icon_entry;
+
+	GtkWidget *clear_button;
+	GtkWidget *option_button;
+};
+
+G_DEFINE_TYPE (MailSearch, mail_search, GTK_TYPE_HBOX)
+
+static void
+mail_search_init (MailSearch  *shell)
+{
+	shell->priv = g_new0(MailSearchPrivate, 1);
+}
+
+static void
+mail_search_finalize (GObject *object)
+{
+	G_OBJECT_CLASS (mail_search_parent_class)->finalize (object);
+}
+
+static void
+mail_search_class_init (MailSearchClass *klass)
+{
+	GObjectClass * object_class = G_OBJECT_CLASS (klass);
+
+	mail_search_parent_class = g_type_class_peek_parent (klass);
+	object_class->finalize = mail_search_finalize;
+	/*klass->backspace_pressed = ms_backspace_pressed;
+	klass->slash_pressed = ms_slash_pressed;*/
+	
+	mail_search_signals [SEARCH_ACTIVATE] =
+		g_signal_new ("search-activate",
+				G_TYPE_FROM_CLASS (object_class),
+				G_SIGNAL_RUN_FIRST,
+				G_STRUCT_OFFSET (MailSearchClass, search_activate),
+				NULL, NULL,
+				g_cclosure_marshal_VOID__VOID,
+				G_TYPE_NONE, 0);
+	
+	mail_search_signals [SEARCH_CLEAR] =
+		g_signal_new ("slash_pressed",
+				G_TYPE_FROM_CLASS (object_class),
+				G_SIGNAL_RUN_FIRST,
+				G_STRUCT_OFFSET (MailSearchClass, search_clear),
+				NULL, NULL,
+				g_cclosure_marshal_VOID__VOID,
+				G_TYPE_NONE, 0);
+	
+};
+
+
+void
+mail_search_construct (MailSearch *search_bar)
+{
+	MailSearchPrivate *priv = search_bar->priv;
+	GtkWidget *tmp, *img, *box, *ar1, *ar2;
+
+	gtk_box_set_spacing (GTK_BOX (search_bar), 3);
+	gtk_box_set_homogeneous (GTK_BOX (search_bar), FALSE);
+
+	priv->entry_box = gtk_hbox_new (0, FALSE);
+	priv->icon_entry = e_icon_entry_new ();
+	priv->entry = e_icon_entry_get_entry (E_ICON_ENTRY (priv->icon_entry));
+
+/*	g_signal_connect (priv->entry, "changed",
+			  G_CALLBACK (entry_changed_cb), search_bar);
+	g_signal_connect (priv->entry, "activate",
+			  G_CALLBACK (entry_activated_cb), search_bar);
+	g_signal_connect (priv->entry, "focus-in-event",
+			  G_CALLBACK (entry_focus_in_cb), search_bar);
+	g_signal_connect (priv->entry, "focus-out-event",
+			  G_CALLBACK (entry_focus_out_cb), search_bar);
+	g_signal_connect (priv->entry, "key-press-event",
+			  G_CALLBACK (entry_key_press_cb), search_bar);	
+*/
+	priv->clear_button = e_icon_entry_create_button ("gtk-clear");
+//	g_signal_connect (G_OBJECT (search_bar->clear_button), "button-press-event", G_CALLBACK(clear_button_clicked_cb), search_bar);
+	e_icon_entry_pack_widget (E_ICON_ENTRY (priv->icon_entry), priv->clear_button, FALSE);
+
+	priv->option_button = e_icon_entry_create_button ("gtk-find");
+//	g_signal_connect (G_OBJECT (search_bar->option_button), "button-press-event", G_CALLBACK(option_button_clicked_cb), search_bar);
+	e_icon_entry_pack_widget (E_ICON_ENTRY (priv->icon_entry), priv->option_button, TRUE);
+
+	gtk_box_pack_start (GTK_BOX(priv->entry_box), priv->icon_entry, TRUE, TRUE, 0);
+
+	gtk_widget_show_all (priv->entry_box);
+	gtk_widget_set_sensitive (priv->clear_button, FALSE);
+	gtk_box_pack_start(search_bar, priv->entry_box, TRUE, TRUE, 0);
+
+	gtk_widget_show (search_bar);
+}
+
+MailSearch *
+mail_search_new ()
+{
+	MailSearch *shell = g_object_new (MAIL_SEARCH_TYPE, NULL);
+	mail_search_construct (shell);
+
+	return shell;
+}
+
diff --git a/src/mail-search.h b/src/mail-search.h
new file mode 100644
index 0000000..f715631
--- /dev/null
+++ b/src/mail-search.h
@@ -0,0 +1,57 @@
+/*
+ * This program 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; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program 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 the program; if not, see <http://www.gnu.org/licenses/>  
+ *
+ *
+ * Authors:
+ *		Srinivasa Ragavan <sragavan novell com>
+ *
+ * Copyright (C) 2009 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#ifndef _MAIL_SEARCH_H_
+#define _MAIL_SEARCH_H_
+
+#include <gtk/gtk.h>
+#include "mail-component.h"
+#include "mail-view.h"
+
+#define MAIL_SEARCH_TYPE        (mail_search_get_type ())
+#define MAIL_SEARCH(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), MAIL_SEARCH_TYPE, MailSearch))
+#define MAIL_SEARCH_CLASS(k)    (G_TYPE_CHECK_CLASS_CAST((k), MAIL_SEARCH_TYPE, MailSearchClass))
+#define IS_MAIL_SEARCH(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), MAIL_SEARCH_TYPE))
+#define IS_MAIL_SEARCH_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MAIL_SEARCH_TYPE))
+#define MAIL_SEARCH_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), MAIL_SEARCH_TYPE, MailSearchClass))
+
+typedef struct _MailSearchPrivate MailSearchPrivate;
+
+typedef struct _MailSearch {
+	GtkHBox parent;
+	
+	MailSearchPrivate *priv;
+} MailSearch;
+
+typedef struct _MailSearchClass {
+	GtkHBoxClass parent_class;
+
+	void (* search_activate)    (MailSearch *class);
+	void (* search_clear)    (MailSearch *class);	
+} MailSearchClass;
+
+MailSearch * mail_search_new (void);
+
+#endif
+
+
+
diff --git a/src/mail-shell.c b/src/mail-shell.c
index 154b034..48e6615 100644
--- a/src/mail-shell.c
+++ b/src/mail-shell.c
@@ -27,6 +27,7 @@
 #include <gconf/gconf-client.h>
 #include "mail-shell.h"
 #include "mail-view.h"
+#include "mail-search.h"
 #include "mail-component.h"
 #include <gdk/gdkkeysyms.h>
 #include <misc/e-spinner.h>
@@ -326,8 +327,7 @@ mail_shell_construct (MailShell *shell)
 	priv->search_bar = (GtkWidget *) gtk_hbox_new (FALSE, 6);
 	gtk_box_pack_start ((GtkBox *)priv->top_bar, priv->search_bar, TRUE, TRUE, 0);
 	gtk_widget_show (priv->search_bar);
-	priv->search_entry = gtk_entry_new ();
-	gtk_entry_set_text ((GtkEntry *)priv->search_entry, _("Type to Search email"));
+	priv->search_entry = mail_search_new ();
 	gtk_widget_show (priv->search_entry);
 	gtk_box_pack_start ((GtkBox *)priv->search_bar, priv->search_entry, TRUE, TRUE, 24);
 	



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]