gtranslator r3458 - in branches/GOBJECT_WORK: . plugins/dictionary



Author: sdeburca
Date: Sat Jan 26 19:16:45 2008
New Revision: 3458
URL: http://svn.gnome.org/viewvc/gtranslator?rev=3458&view=rev

Log:
2008-01-26  SeÃn de BÃrca  <sdeburca svn gnome org>
    * plugins/dictionary/dict-panel.c:
    * plugins/dictionary/dictionary-plugin.c:
    * plugins/dictionary/gdict-sidebar.c:
    * plugins/dictionary/dictionary-plugin.h:
    * plugins/dictionary/gdict-sidebar.h:
        Fix compile errors and warnings.


Modified:
   branches/GOBJECT_WORK/ChangeLog
   branches/GOBJECT_WORK/plugins/dictionary/dict-panel.c
   branches/GOBJECT_WORK/plugins/dictionary/dictionary-plugin.c
   branches/GOBJECT_WORK/plugins/dictionary/dictionary-plugin.h
   branches/GOBJECT_WORK/plugins/dictionary/gdict-sidebar.c
   branches/GOBJECT_WORK/plugins/dictionary/gdict-sidebar.h

Modified: branches/GOBJECT_WORK/plugins/dictionary/dict-panel.c
==============================================================================
--- branches/GOBJECT_WORK/plugins/dictionary/dict-panel.c	(original)
+++ branches/GOBJECT_WORK/plugins/dictionary/dict-panel.c	Sat Jan 26 19:16:45 2008
@@ -21,6 +21,7 @@
 
 #include "dict-panel.h"
 #include "gdict-sidebar.h"
+#include "plugin.h"
 
 #include <glib.h>
 #include <glib-object.h>
@@ -28,7 +29,7 @@
 #include <gtk/gtk.h>
 #include <gdict/gdict.h>
 #include <gconf/gconf-client.h>
-#include <gtranslator/plugin.h>
+#include <string.h>
 
 #define GTR_DICT_PANEL_GET_PRIVATE(object)	(G_TYPE_INSTANCE_GET_PRIVATE ( \
 						 (object),		       \
@@ -106,20 +107,6 @@
 }
 
 static void
-clear_cb (GtkWidget   *widget,
-	  GtranslatorDictPanel *panel)
-{
-	GtranslatorDictPanelPrivate *priv = panel->priv;
-
-	gtk_entry_set_text (GTK_ENTRY (priv->entry), "");
-
-	if (!priv->defbox)
-		return;
-  
-	gdict_defbox_clear (GDICT_DEFBOX (priv->defbox));
-}
-
-static void
 gtranslator_dict_panel_entry_activate_cb (GtkWidget   *widget,
 					  GtranslatorDictPanel *panel)
 {
@@ -290,9 +277,9 @@
                        const gchar          *strat_desc,
                        GtranslatorDictPanel *panel)
 {
-	GtranslatorDictPanelPrivate *priv = panel->priv;
+/*	GtranslatorDictPanelPrivate *priv = panel->priv;
 	gtranslator_dict_panel_set_strategy (panel, strat_name);
-/*
+
   if (window->status)
     {
       gchar *message;
@@ -309,9 +296,9 @@
 		       const gchar          *db_desc,
 		       GtranslatorDictPanel *panel)
 {
-	GtranslatorDictPanelPrivate *priv = panel->priv;
+/*	GtranslatorDictPanelPrivate *priv = panel->priv;
 	gtranslator_dict_panel_set_database (panel, db_name);
-	/*
+
   if (window->status)
     {
       gchar *message;
@@ -328,19 +315,18 @@
 				 const gchar *database)
 {
 	GtranslatorDictPanelPrivate *priv = panel->priv;
-	gchar *title;
-	
+
 	g_free (priv->word);
 	priv->word = NULL;
-	
+
 	if (word && word[0] != '\0')
 		priv->word = g_strdup (word);
 	else
 		return;
-	
+
 	if (!database || database[0] == '\0')
 		database = priv->database;
-	
+
 	if (priv->defbox)
 	{
 		gdict_defbox_set_database (GDICT_DEFBOX (priv->defbox), database);
@@ -580,7 +566,6 @@
 			      gpointer     user_data)
 {
 	GtranslatorDictPanel *panel = GTR_DICT_PANEL (user_data);
-	GtranslatorDictPanelPrivate *priv = panel->priv;
 
 	if (strcmp (entry->key, GDICT_GCONF_SOURCE_KEY) == 0)
 	{

Modified: branches/GOBJECT_WORK/plugins/dictionary/dictionary-plugin.c
==============================================================================
--- branches/GOBJECT_WORK/plugins/dictionary/dictionary-plugin.c	(original)
+++ branches/GOBJECT_WORK/plugins/dictionary/dictionary-plugin.c	Sat Jan 26 19:16:45 2008
@@ -21,13 +21,12 @@
 
 #include "dictionary-plugin.h"
 #include "dict-panel.h"
+#include "panel.h"
+#include "window.h"
 
 #include <glib/gi18n-lib.h>
 #include <gconf/gconf-client.h>
 //#include <gtranslator/gtranslator-debug.h>
-#include <gtranslator/window.h>
-#include <gtranslator/panel.h>
-
 
 #define WINDOW_DATA_KEY	"GtranslatorDictPluginWindowData"
 #define PANEL_KEY "/apps/gtranslator/plugins/dictionary"
@@ -103,7 +102,6 @@
 	GtranslatorPanel *panel;
 	GtkWidget *image;
 	GtkIconTheme *theme;
-	GtkStatusbar *statusbar;
 	WindowData *data;
 
 	//gtranslator_debug (DEBUG_PLUGINS);

Modified: branches/GOBJECT_WORK/plugins/dictionary/dictionary-plugin.h
==============================================================================
--- branches/GOBJECT_WORK/plugins/dictionary/dictionary-plugin.h	(original)
+++ branches/GOBJECT_WORK/plugins/dictionary/dictionary-plugin.h	Sat Jan 26 19:16:45 2008
@@ -18,9 +18,10 @@
 #ifndef __GTR_Dict_PLUGIN_H__
 #define __GTR_Dict_PLUGIN_H__
 
+#include "plugin.h"
+
 #include <glib.h>
 #include <glib-object.h>
-#include <gtranslator/plugin.h>
 
 G_BEGIN_DECLS
 
@@ -60,7 +61,7 @@
 /*
  * Public methods
  */
-GType	gtranslator_Dict_plugin_get_type	(void) G_GNUC_CONST;
+GType	gtranslator_dict_plugin_get_type	(void) G_GNUC_CONST;
 
 /* All the plugins must implement this function */
 G_MODULE_EXPORT GType register_gtranslator_plugin (GTypeModule *module);

Modified: branches/GOBJECT_WORK/plugins/dictionary/gdict-sidebar.c
==============================================================================
--- branches/GOBJECT_WORK/plugins/dictionary/gdict-sidebar.c	(original)
+++ branches/GOBJECT_WORK/plugins/dictionary/gdict-sidebar.c	Sat Jan 26 19:16:45 2008
@@ -1,19 +1,18 @@
 /* gdict-sidebar.c - sidebar widget
  *
  * Copyright (C) 2006  Emmanuele Bassi <ebassi gmail com>
- * 		 2007  Ignacio Casal Quinteiro <nacho resa gmail com>
  *
  * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
+ * 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) any later version.
+ * version 2.1 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
- * Library General Public License for more details.
+ * Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public
+ * You should have received a copy of the GNU Lesser General Public
  * License along with this program; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  *
@@ -59,6 +58,7 @@
   GtkWidget *hbox;
   GtkWidget *notebook;
   GtkWidget *menu;
+  GtkWidget *close_button;
   GtkWidget *label;
   GtkWidget *select_button;
 };
@@ -72,17 +72,11 @@
 };
 
 static guint sidebar_signals[LAST_SIGNAL] = { 0 };
+static GQuark sidebar_page_id_quark = 0;
 
 G_DEFINE_TYPE (GdictSidebar, gdict_sidebar, GTK_TYPE_VBOX);
 
-#define SIDEBAR_PAGE_ID		(sidebar_page_id_quark ())
-static GQuark
-sidebar_page_id_quark (void)
-{
-  return g_quark_from_static_string ("gdict-sidebar-page-id");
-}
-
-SidebarPage *
+static SidebarPage *
 sidebar_page_new (const gchar *id,
 		  const gchar *name,
 		  GtkWidget   *widget)
@@ -100,7 +94,7 @@
   return page;
 }
 
-void
+static void
 sidebar_page_free (SidebarPage *page)
 {
   if (G_LIKELY (page))
@@ -220,6 +214,14 @@
   return FALSE;
 }
 
+static void
+gdict_sidebar_close_clicked_cb (GtkWidget *widget,
+				gpointer   user_data)
+{
+  GdictSidebar *sidebar = GDICT_SIDEBAR (user_data);
+
+  g_signal_emit (sidebar, sidebar_signals[CLOSED], 0);
+}
 
 static void
 gdict_sidebar_menu_deactivate_cb (GtkWidget *widget,
@@ -253,7 +255,7 @@
   gint current_index;
 
   menu_item = gtk_menu_get_active (GTK_MENU (priv->menu));
-  id = g_object_get_qdata (G_OBJECT (menu_item), SIDEBAR_PAGE_ID);
+  id = g_object_get_qdata (G_OBJECT (menu_item), sidebar_page_id_quark);
   g_assert (id != NULL);
   
   page = g_hash_table_lookup (priv->pages_by_id, id);
@@ -275,6 +277,10 @@
 {
   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
 
+  g_type_class_add_private (gobject_class, sizeof (GdictSidebarPrivate));
+  
+  sidebar_page_id_quark = g_quark_from_static_string ("gdict-sidebar-page-id");
+
   gobject_class->finalize = gdict_sidebar_finalize;
   gobject_class->dispose = gdict_sidebar_dispose;
 
@@ -294,8 +300,6 @@
 		  NULL, NULL,
 		  g_cclosure_marshal_VOID__VOID,
 		  G_TYPE_NONE, 0);
-
-  g_type_class_add_private (gobject_class, sizeof (GdictSidebarPrivate));
 }
 
 static void
@@ -305,6 +309,7 @@
   GtkWidget *hbox;
   GtkWidget *select_hbox;
   GtkWidget *select_button;
+  GtkWidget *close_button;
   GtkWidget *arrow;
 
   sidebar->priv = priv = GDICT_SIDEBAR_GET_PRIVATE (sidebar);
@@ -351,6 +356,18 @@
   gtk_box_pack_start (GTK_BOX (hbox), select_button, TRUE, TRUE, 0);
   gtk_widget_show (select_button);
 
+  close_button = gtk_button_new ();
+  gtk_button_set_relief (GTK_BUTTON (close_button), GTK_RELIEF_NONE);
+  gtk_button_set_image (GTK_BUTTON (close_button),
+		        gtk_image_new_from_stock (GTK_STOCK_CLOSE,
+						  GTK_ICON_SIZE_SMALL_TOOLBAR));
+  g_signal_connect (close_button, "clicked",
+		    G_CALLBACK (gdict_sidebar_close_clicked_cb),
+		    sidebar);
+  gtk_box_pack_end (GTK_BOX (hbox), close_button, FALSE, FALSE, 0);
+  gtk_widget_show (close_button);
+  priv->close_button = close_button;
+
   sidebar->priv->menu = gtk_menu_new ();
   g_signal_connect (sidebar->priv->menu, "deactivate",
 		    G_CALLBACK (gdict_sidebar_menu_deactivate_cb),
@@ -416,8 +433,8 @@
   /* add the menu item for the page */
   menu_item = gtk_image_menu_item_new_with_label (page_name);
   g_object_set_qdata_full (G_OBJECT (menu_item),
-		           SIDEBAR_PAGE_ID,
-			   g_strdup (page_id),
+			   sidebar_page_id_quark,
+                           g_strdup (page_id),
 			   (GDestroyNotify) g_free);
   g_signal_connect (menu_item, "activate",
 		    G_CALLBACK (gdict_sidebar_menu_item_activate),
@@ -437,7 +454,6 @@
 {
   GdictSidebarPrivate *priv;
   SidebarPage *page;
-  GtkWidget *menu_item;
   GList *children, *l;
   
   g_return_if_fail (GDICT_IS_SIDEBAR (sidebar));
@@ -500,8 +516,7 @@
   if (!page)
     return;
 
-  gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook),
-		  		 page->index);
+  gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), page->index);
   gtk_label_set_text (GTK_LABEL (priv->label), page->name);
   gtk_menu_shell_select_item (GTK_MENU_SHELL (priv->menu), page->menu_item);
 }
@@ -523,3 +538,28 @@
 
   return page->id;
 }
+
+gchar **
+gdict_sidebar_list_pages (GdictSidebar *sidebar,
+                          gsize        *length)
+{
+  GdictSidebarPrivate *priv;
+  gchar **retval;
+  gint i;
+  GSList *l;
+
+  g_return_val_if_fail (GDICT_IS_SIDEBAR (sidebar), NULL);
+
+  priv = sidebar->priv;
+
+  retval = g_new (gchar*, g_slist_length (priv->pages) + 1);
+  for (l = priv->pages, i = 0; l; l = l->next, i++)
+    retval[i++] = g_strdup (l->data);
+
+  retval[i] = NULL;
+
+  if (length)
+    *length = i;
+
+  return retval;
+}

Modified: branches/GOBJECT_WORK/plugins/dictionary/gdict-sidebar.h
==============================================================================
--- branches/GOBJECT_WORK/plugins/dictionary/gdict-sidebar.h	(original)
+++ branches/GOBJECT_WORK/plugins/dictionary/gdict-sidebar.h	Sat Jan 26 19:16:45 2008
@@ -3,16 +3,16 @@
  * Copyright (C) 2006  Emmanuele Bassi <ebassi gmail com>
  *
  * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
+ * 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) any later version.
+ * version 2.1 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
- * Library General Public License for more details.
+ * Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public
+ * You should have received a copy of the GNU Lesser General Public
  * License along with this program; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  *
@@ -69,5 +69,7 @@
 void                  gdict_sidebar_view_page    (GdictSidebar *sidebar,
 						  const gchar  *page_id);
 G_CONST_RETURN gchar *gdict_sidebar_current_page (GdictSidebar *sidebar);
+gchar **              gdict_sidebar_list_pages   (GdictSidebar *sidebar,
+                                                  gsize        *length) G_GNUC_MALLOC;
 
 #endif /* __GDICT_SIDEBAR_H__ */



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