[tracker/search-bar] tracker-search-bar: Moved to C implementation
- From: Martyn James Russell <mr src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [tracker/search-bar] tracker-search-bar: Moved to C implementation
- Date: Mon, 21 Sep 2009 11:43:05 +0000 (UTC)
commit a15da8682a383ed86592e332f5f1396f7356932b
Author: Martyn Russell <martyn lanedo com>
Date: Mon Sep 21 12:42:34 2009 +0100
tracker-search-bar: Moved to C implementation
src/tracker-search-bar/GNOME_Search_Bar_Applet.xml | 7 +
src/tracker-search-bar/Makefile.am | 30 +--
src/tracker-search-bar/tracker-applet.c | 229 ++++++++++++++++++++
src/tracker-search-bar/tracker-search-bar.ui | 47 ++++-
src/tracker-search-bar/tracker-search-bar.vala | 54 -----
src/tracker-status-icon/tracker-status-icon.c | 14 +-
6 files changed, 298 insertions(+), 83 deletions(-)
---
diff --git a/src/tracker-search-bar/GNOME_Search_Bar_Applet.xml b/src/tracker-search-bar/GNOME_Search_Bar_Applet.xml
new file mode 100644
index 0000000..5d425f1
--- /dev/null
+++ b/src/tracker-search-bar/GNOME_Search_Bar_Applet.xml
@@ -0,0 +1,7 @@
+<Root>
+ <popups>
+ <popup name="button3">
+ <menuitem name="About" verb="about" _label="_About" pixtype="stock" pixname="gtk-about"/>
+ </popup>
+ </popups>
+</Root>
diff --git a/src/tracker-search-bar/Makefile.am b/src/tracker-search-bar/Makefile.am
index 38d11bb..bec84b4 100644
--- a/src/tracker-search-bar/Makefile.am
+++ b/src/tracker-search-bar/Makefile.am
@@ -2,19 +2,13 @@ include $(top_srcdir)/Makefile.decl
libexec_PROGRAMS = tracker-search-bar
-tracker_search_bar_VALASOURCES = \
- tracker-search-bar.vala
-
tracker_search_bar_SOURCES = \
- $(tracker_search_bar_VALASOURCES:.vala=.c)
-
-tracker_search_bar.vala.stamp: $(tracker_search_bar_VALASOURCES)
- $(VALAC) -C -g --pkg gtk+-2.0 --pkg libgnomeui-2.0 --pkg libpanelapplet-2.0 $^
- touch tracker_search_bar.vala.stamp
+ tracker-applet.c \
+ tracker-applet.h
tracker_search_bar_CFLAGS = \
- -DTRACKER_UI_DIR=\"$(datadir)/tracker/\" \
- -DSRCDIR=\"$(abs_srcdir)/\" \
+ -DPKGDATADIR=\""$(pkgdatadir)"\" \
+ -DGNOMELOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
$(WARN_CFLAGS) \
$(GCOV_CFLAGS) \
$(TRACKER_SEARCH_BAR_CFLAGS)
@@ -33,10 +27,8 @@ server_DATA = $(server_in_files:.server.in=.server)
# Misc data
resourcesdir = $(pkgdatadir)
-resources_DATA =
-# GNOME_Search_Bar_Applet.xml
-
-tracker_search_bar_dir = $(libexecdir)
+resources_DATA = \
+ GNOME_Search_Bar_Applet.xml
# Build rules
@INTLTOOL_SERVER_RULE@
@@ -45,21 +37,11 @@ tracker_search_bar_dir = $(libexecdir)
$(server_in_files): $(server_in_files:.server.in=.server.in.in)
sed -e "s|\ LIBEXECDIR\@|$(tracker_search_bar_dir)|" $< > $@
-BUILT_SOURCES = \
- tracker_search_bar.vala.stamp
-
EXTRA_DIST = \
- $(tracker_search_bar_SOURCES) \
- $(tracker_search_bar_VALASOURCES) \
$(resources_DATA) \
- tracker_search_bar.vala.stamp \
tracker-search-bar.ui \
GNOME_Search_Bar_Applet.server.in.in
-MAINTAINERCLEANFILES = \
- $(tracker_search_bar_SOURCES) \
- tracker_search_bar.vala.stamp
-
DISTCLEANFILES = \
$(server_DATA) \
$(server_in_files)
diff --git a/src/tracker-search-bar/tracker-applet.c b/src/tracker-search-bar/tracker-applet.c
new file mode 100644
index 0000000..f888a61
--- /dev/null
+++ b/src/tracker-search-bar/tracker-applet.c
@@ -0,0 +1,229 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2006-2007 Imendio AB
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Authors: Martyn Russell <martyn imendio com>
+ */
+
+#include "config.h"
+
+#include <string.h>
+
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <bonobo/bonobo-ui-component.h>
+#include <panel-applet-gconf.h>
+
+typedef struct {
+ GtkBuilder *builder;
+
+ GtkWidget *widget;
+
+ GtkWidget *image;
+ GtkWidget *entry;
+} Applet;
+
+static void applet_about_cb (BonoboUIComponent *uic,
+ Applet *applet,
+ const gchar *verb_name);
+
+static const BonoboUIVerb applet_menu_verbs [] = {
+ BONOBO_UI_UNSAFE_VERB ("about", applet_about_cb),
+ BONOBO_UI_VERB_END
+};
+
+static void
+applet_about_cb (BonoboUIComponent *uic,
+ Applet *applet,
+ const gchar *verb_name)
+{
+ GObject *object;
+ GtkWidget *dialog;
+
+ object = gtk_builder_get_object (applet->builder, "dialog_about");
+ g_return_if_fail (object != NULL);
+
+ dialog = GTK_WIDGET (object);
+
+ g_signal_connect_swapped (object,
+ "response",
+ G_CALLBACK (gtk_widget_destroy),
+ dialog);
+
+ gtk_widget_show_all (dialog);
+}
+
+static void
+applet_entry_activate_cb (GtkEntry *entry,
+ Applet *applet)
+{
+ const gchar *text;
+
+ text = gtk_entry_get_text (entry);
+ if (strlen (text) < 1) {
+ return;
+ }
+
+ g_print ("Searching for: '%s'\n", text);
+
+ /* Do something */
+
+ gtk_entry_set_text (entry, "");
+}
+
+static gboolean
+applet_entry_button_press_event_cb (GtkWidget *widget,
+ GdkEventButton *event,
+ Applet *applet)
+{
+ panel_applet_request_focus (PANEL_APPLET (applet->widget), event->time);
+
+ return FALSE;
+}
+
+static void
+applet_size_allocate_cb (GtkWidget *widget,
+ GtkAllocation *allocation,
+ Applet *applet)
+{
+ PanelAppletOrient orient;
+ gint size;
+
+ orient = panel_applet_get_orient (PANEL_APPLET (widget));
+ if (orient == PANEL_APPLET_ORIENT_LEFT ||
+ orient == PANEL_APPLET_ORIENT_RIGHT) {
+ size = allocation->width;
+ } else {
+ size = allocation->height;
+ }
+
+ gtk_image_set_pixel_size (GTK_IMAGE (applet->image), size - 2);
+}
+
+static void
+applet_destroy_cb (BonoboObject *object,
+ Applet *applet)
+{
+ if (applet->builder) {
+ g_object_unref (applet->builder);
+ applet->builder = NULL;
+ }
+
+ g_free (applet);
+}
+
+static gboolean
+applet_new (PanelApplet *parent_applet)
+{
+ Applet *applet;
+ GError *error = NULL;
+ GtkBuilder *builder;
+ GtkWidget *hbox;
+ const gchar *filename;
+
+ builder = gtk_builder_new ();
+ filename = PKGDATADIR "/tracker-search-bar.ui";
+
+ if (gtk_builder_add_from_file (builder, filename, &error) == 0) {
+ g_printerr ("Could not load builder file, %s", error->message);
+ g_error_free (error);
+ g_object_unref (builder);
+
+ return FALSE;
+ }
+
+ g_print ("Added builder file:'%s'\n", filename);
+
+ applet = g_new0 (Applet, 1);
+
+ applet->widget = GTK_WIDGET (parent_applet);
+ applet->builder = builder;
+
+ hbox = gtk_hbox_new (FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (parent_applet), hbox);
+ gtk_widget_show (hbox);
+
+ applet->image = gtk_image_new ();
+ gtk_box_pack_start (GTK_BOX (hbox), applet->image, FALSE, FALSE, 0);
+ gtk_image_set_from_stock (GTK_IMAGE (applet->image),
+ GTK_STOCK_FIND,
+ GTK_ICON_SIZE_SMALL_TOOLBAR);
+ gtk_widget_show (applet->image);
+
+ applet->entry = gtk_entry_new ();
+ gtk_box_pack_start (GTK_BOX (hbox), applet->entry, TRUE, TRUE, 0);
+ gtk_entry_set_width_chars (GTK_ENTRY (applet->entry), 10);
+ gtk_widget_show (applet->entry);
+
+ g_signal_connect (applet->entry,
+ "activate",
+ G_CALLBACK (applet_entry_activate_cb), applet);
+ g_signal_connect (applet->entry,
+ "button_press_event",
+ G_CALLBACK (applet_entry_button_press_event_cb), applet);
+
+ panel_applet_set_flags (PANEL_APPLET (applet->widget),
+ PANEL_APPLET_EXPAND_MINOR);
+ panel_applet_set_background_widget (PANEL_APPLET (applet->widget),
+ GTK_WIDGET (applet->widget));
+
+ panel_applet_setup_menu_from_file (PANEL_APPLET (applet->widget),
+ NULL,
+ PKGDATADIR "/GNOME_Search_Bar_Applet.xml",
+ NULL,
+ applet_menu_verbs,
+ applet);
+
+ gtk_widget_show (applet->widget);
+
+ g_signal_connect (applet->widget,
+ "size_allocate",
+ G_CALLBACK (applet_size_allocate_cb), applet);
+ g_signal_connect (panel_applet_get_control (PANEL_APPLET (applet->widget)),
+ "destroy",
+ G_CALLBACK (applet_destroy_cb), applet);
+
+ /* Initialise other modules */
+
+ return TRUE;
+}
+
+/*
+ * The entry point for this factory. If the OAFIID matches, create an instance
+ * of the applet.
+ */
+static gboolean
+applet_factory (PanelApplet *applet,
+ const gchar *iid,
+ gpointer data)
+{
+ if (!strcmp (iid, "OAFIID:GNOME_Search_Bar_Applet")) {
+ g_print ("Creating applet\n");
+ return applet_new (applet);
+ }
+
+ return FALSE;
+}
+
+/*
+ * Generate the boilerplate to hook into GObject/Bonobo.
+ */
+PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_Search_Bar_Applet_Factory",
+ PANEL_TYPE_APPLET,
+ "GNOME_Search_Bar_Applet", PACKAGE_VERSION,
+ applet_factory,
+ NULL);
diff --git a/src/tracker-search-bar/tracker-search-bar.ui b/src/tracker-search-bar/tracker-search-bar.ui
index c081dde..07c3653 100644
--- a/src/tracker-search-bar/tracker-search-bar.ui
+++ b/src/tracker-search-bar/tracker-search-bar.ui
@@ -2,7 +2,50 @@
<interface>
<requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy project-wide -->
- <object class="GtkMenu" id="context_menu">
- <property name="visible">True</property>
+ <object class="GtkAboutDialog" id="dialog_about">
+ <property name="border_width">5</property>
+ <property name="type_hint">normal</property>
+ <property name="has_separator">False</property>
+ <property name="program_name">Search Bar</property>
+ <property name="version">0.7</property>
+ <property name="copyright" translatable="yes">Copyright Tracker Maintainers 2009</property>
+ <property name="comments" translatable="yes">A search bar applet for finding content stored in Tracker</property>
+ <property name="website">http://www.tracker-project.org/</property>
+ <property name="website_label" translatable="yes">http://www.tracker-project.org/</property>
+ <property name="license" translatable="yes">Tracker is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
+
+Tracker 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 General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with Tracker; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</property>
+ <property name="authors">Martyn Russell
+Jürg Billeter
+Carlos Garnacho
+Philip Van Hoof
+Mikael Ottela
+Ivan Frade
+</property>
+ <property name="logo_icon_name">tracker</property>
+ <property name="wrap_license">True</property>
+ <child internal-child="vbox">
+ <object class="GtkVBox" id="dialog-vbox1">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ <child>
+ <placeholder/>
+ </child>
+ <child internal-child="action_area">
+ <object class="GtkHButtonBox" id="dialog-action_area1">
+ <property name="visible">True</property>
+ <property name="layout_style">end</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
</object>
</interface>
diff --git a/src/tracker-status-icon/tracker-status-icon.c b/src/tracker-status-icon/tracker-status-icon.c
index 5a02ee6..1bcf216 100644
--- a/src/tracker-status-icon/tracker-status-icon.c
+++ b/src/tracker-status-icon/tracker-status-icon.c
@@ -622,9 +622,17 @@ context_menu_about_cb (GtkMenuItem *item,
};
const gchar *license[] = {
- N_("Tracker is free software; you can redistribute it and/or modify " "it under the terms of the GNU General Public License as published by " "the Free Software Foundation; either version 2 of the License, or " "(at your option) any later version."),
- N_("Tracker 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 General Public License for more details."),
- N_("You should have received a copy of the GNU General Public License " "along with Tracker; if not, write to the Free Software Foundation, Inc., " "51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.")
+ N_("Tracker is free software; you can redistribute it and/or modify "
+ "it under the terms of the GNU General Public License as published by "
+ "the Free Software Foundation; either version 2 of the License, or "
+ "(at your option) any later version."),
+ N_("Tracker 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 General Public License for more details."),
+ N_("You should have received a copy of the GNU General Public License "
+ "along with Tracker; if not, write to the Free Software Foundation, Inc., "
+ "51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.")
};
gchar *license_trans;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]