Re: [Epiphany] mega-patch



On Fri, 2003-02-14 at 07:29, Marco Pesenti Gritti wrote:
> On Fri, 2003-02-14 at 05:42, James Willcox wrote:
> > Hi Marco,
> > 
> > Here's a patch that does 2 things:  adds load feedback to tabs, and adds
> > a context menu to the bookmark editor. 
> > http://www.cs.indiana.edu/~jwillcox/epiphany-loading-and-menu.png
> > 
> > It really should be 2 separate patches, but I am lame and didn't want to
> > separate it.  Of course, if you want one and not the other I will go
> > ahead and do it. :)
> > 
> > Thanks,
> > James
> > ----
> > 
> 
> Cool :) Review follow.
> 

Ah, all very good points.  Thanks.  I fixed them all except the
following and committed it....attached is the patch

> > +	/* setup load feedback image */
> > +	loading_pixbuf = gdk_pixbuf_animation_new_from_file (ephy_file ("epiphany-tab-loading.gif"), NULL);
> > +	loading_image = gtk_image_new_from_animation (loading_pixbuf);
> > +	g_object_unref (loading_pixbuf);
> > +	gtk_box_pack_start (GTK_BOX (hbox), loading_image, FALSE, FALSE, 0);
> > +
> 
> I'd prefer if we register this as a stock icon. Have a look at
> lib/ephy-stock-icons.c. So it's themable ...

I wanted to do this too, but currently gtk+ doesn't support registering
GdkPixbufAnimation stuff as stock icons.  I was thinking about using the
gnome icon theme stuff to do it, but it doesn't support gif (or mng).

Also, I totally ripped that gif out of mozilla....there may be licensing
issues or something.  One thing I was thinking about, is that we could
snarf the image by grabbing it through the mozilla vfs.  The tab loading
icon is available through chrome://communicator/skin/icons/loading.gif. 
That would also allow the icon to be themable (through the mozilla
chrome system).  What do you think?

Thanks,
James
? data/art/epiphany-tab-loading.gif
? data/ui/epiphany-bookmark-editor-ui.xml.in
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/epiphany/ChangeLog,v
retrieving revision 1.106
diff -u -r1.106 ChangeLog
--- ChangeLog	14 Feb 2003 17:35:51 -0000	1.106
+++ ChangeLog	14 Feb 2003 18:50:07 -0000
@@ -1,3 +1,21 @@
+2003-02-14  James Willcox  <jwillcox@gnome.org>
+
+	* data/art/Makefile.am:
+	* data/ui/Makefile.am:
+	* lib/widgets/ephy-notebook.c: (ephy_notebook_init),
+	(ephy_notebook_set_page_status), (tab_build_label):
+	* src/bookmarks/ephy-bookmarks-editor.c:
+	(popup_cmd_open_bookmarks_in_tabs),
+	(popup_cmd_open_bookmarks_in_browser),
+	(popup_cmd_remove_bookmarks), (ephy_bookmarks_editor_finalize),
+	(ephy_bookmarks_editor_show_popup_cb),
+	(ephy_bookmarks_editor_construct), (ephy_bookmarks_editor_new),
+	(ephy_bookmarks_editor_get_selected_bookmarks),
+	(ephy_bookmarks_editor_remove_selected):
+
+	Add tab load notification, and add a context menu to the bookmarks
+	editor.
+
 2003-02-14  Dave Bordoley <bordoley@msu.edu>
 
 	* data/ui/epiphany-toolbar.xml.in
Index: data/art/Makefile.am
===================================================================
RCS file: /cvs/gnome/epiphany/data/art/Makefile.am,v
retrieving revision 1.5
diff -u -r1.5 Makefile.am
--- data/art/Makefile.am	3 Feb 2003 13:23:20 -0000	1.5
+++ data/art/Makefile.am	14 Feb 2003 18:50:07 -0000
@@ -7,7 +7,8 @@
 	epiphany-history.png	\
 	epiphany-new-tab.png	\
 	epiphany-viewsource.png \
-	epiphany-send-link.png	
+	epiphany-send-link.png	\
+	epiphany-tab-loading.gif
 
 appicon_DATA = epiphany.png
 appicondir = $(datadir)/pixmaps
Index: data/ui/Makefile.am
===================================================================
RCS file: /cvs/gnome/epiphany/data/ui/Makefile.am,v
retrieving revision 1.2
diff -u -r1.2 Makefile.am
--- data/ui/Makefile.am	20 Jan 2003 18:57:15 -0000	1.2
+++ data/ui/Makefile.am	14 Feb 2003 18:50:07 -0000
@@ -1,5 +1,6 @@
 uixmldir = $(pkgdatadir)
 uixml_in_files = epiphany-ui.xml.in           \
+		 epiphany-bookmark-editor-ui.xml.in \
                  nautilus-epiphany-view.xml.in \
 		 epiphany-toolbar.xml.in
 
Index: lib/widgets/ephy-notebook.c
===================================================================
RCS file: /cvs/gnome/epiphany/lib/widgets/ephy-notebook.c,v
retrieving revision 1.2
diff -u -r1.2 ephy-notebook.c
--- lib/widgets/ephy-notebook.c	4 Jan 2003 20:08:24 -0000	1.2
+++ lib/widgets/ephy-notebook.c	14 Feb 2003 18:50:07 -0000
@@ -20,6 +20,7 @@
 #include "eel-gconf-extensions.h"
 #include "ephy-prefs.h"
 #include "ephy-marshal.h"
+#include "ephy-file-helpers.h"
 
 #include <gtk/gtk.h>
 #include <glib-object.h>
@@ -35,6 +36,8 @@
 	GList *focused_pages;
 	GList *opened_tabs;
 
+	EphyNotebookPageLoadStatus current_status;
+
 	/* Used during tab drag'n'drop */
 	gulong motion_notify_handler_id;
 	gint x_start, y_start;
@@ -587,6 +590,8 @@
 {
 	notebook->priv = g_new (EphyNotebookPrivate, 1);
 
+	notebook->priv->current_status = EPHY_NOTEBOOK_TAB_LOAD_NORMAL;
+
 	notebook->priv->drag_in_progress = FALSE;
 	notebook->priv->motion_notify_handler_id = 0;
 	notebook->priv->src_notebook = NULL;
@@ -629,6 +634,36 @@
 			       GtkWidget *child,
 			       EphyNotebookPageLoadStatus status)
 {
+	GtkWidget *tab, *image;
+
+	g_return_if_fail (nb != NULL);
+
+	if (status == nb->priv->current_status)
+	{
+		return;
+	}
+
+	tab = gtk_notebook_get_tab_label (GTK_NOTEBOOK (nb), child);
+
+	g_return_if_fail (tab != NULL);
+
+	image  = g_object_get_data (G_OBJECT (tab), "loading-image");
+
+	g_return_if_fail (image != NULL);
+
+	switch (status)
+	{
+		case EPHY_NOTEBOOK_TAB_LOAD_LOADING:
+			gtk_widget_show (image);
+			break;
+
+		case EPHY_NOTEBOOK_TAB_LOAD_COMPLETED:
+		case EPHY_NOTEBOOK_TAB_LOAD_NORMAL:
+			gtk_widget_hide (image);
+			break;
+	}
+
+	nb->priv->current_status = status;
 }
 
 static void
@@ -648,6 +683,8 @@
 	int h, w;
 	GClosure *closure;
 	GtkWidget *window;
+	GtkWidget *loading_image;
+	GdkPixbufAnimation *loading_pixbuf;
 
 	window = gtk_widget_get_toplevel (GTK_WIDGET (nb));
 
@@ -667,6 +704,12 @@
 	gtk_container_add (GTK_CONTAINER (close_button),
 			   image);
 
+	/* setup load feedback image */
+	loading_pixbuf = gdk_pixbuf_animation_new_from_file (ephy_file ("epiphany-tab-loading.gif"), NULL);
+	loading_image = gtk_image_new_from_animation (loading_pixbuf);
+	g_object_unref (loading_pixbuf);
+	gtk_box_pack_start (GTK_BOX (hbox), loading_image, FALSE, FALSE, 0);
+
 	/* setup label */
         label = gtk_label_new (_("Untitled"));
 	gtk_misc_set_alignment (GTK_MISC (label), 0.00, 0.5);
@@ -698,6 +741,7 @@
 	gtk_widget_show (close_button);
 
 	g_object_set_data (G_OBJECT (hbox), "label", label);
+	g_object_set_data (G_OBJECT (hbox), "loading-image", loading_image);
 
 	return hbox;
 }
Index: src/bookmarks/ephy-bookmarks-editor.c
===================================================================
RCS file: /cvs/gnome/epiphany/src/bookmarks/ephy-bookmarks-editor.c,v
retrieving revision 1.13
diff -u -r1.13 ephy-bookmarks-editor.c
--- src/bookmarks/ephy-bookmarks-editor.c	13 Feb 2003 17:16:12 -0000	1.13
+++ src/bookmarks/ephy-bookmarks-editor.c	14 Feb 2003 18:50:07 -0000
@@ -32,7 +32,12 @@
 #include "ephy-keywords-entry.h"
 #include "ephy-dnd.h"
 #include "ephy-prefs.h"
+#include "ephy-shell.h"
 #include "eel-gconf-extensions.h"
+#include "ephy-file-helpers.h"
+#include "egg-action-group.h"
+#include "egg-menu-merge.h"
+#include "popup-commands.h"
 
 static void ephy_bookmarks_editor_class_init (EphyBookmarksEditorClass *klass);
 static void ephy_bookmarks_editor_init (EphyBookmarksEditor *editor);
@@ -47,6 +52,13 @@
 						GValue *value,
 						GParamSpec *pspec);
 
+static void popup_cmd_open_bookmarks_in_tabs    (EggAction *action,
+						 EphyBookmarksEditor *editor);
+static void popup_cmd_open_bookmarks_in_browser (EggAction *action,
+						 EphyBookmarksEditor *editor);
+static void popup_cmd_remove_bookmarks          (EggAction *action,
+						 EphyBookmarksEditor *editor);
+
 struct EphyBookmarksEditorPrivate
 {
 	EphyBookmarks *bookmarks;
@@ -58,6 +70,8 @@
 	GtkWidget *keywords_entry;
 	GtkWidget *search_entry;
 	GtkWidget *go_button;
+	EggMenuMerge *ui_merge;
+	EggActionGroup *action_group;
 };
 
 enum
@@ -74,6 +88,87 @@
 
 static GObjectClass *parent_class = NULL;
 
+static EggActionGroupEntry ephy_bookmark_popup_entries [] = {
+	/* Toplevel */
+	{ "FakeToplevel", (""), NULL, NULL, NULL, NULL, NULL },
+
+	{ "OpenInTab", N_("Open In New Tab..."), GTK_STOCK_JUMP_TO, NULL,
+	  NULL, G_CALLBACK (popup_cmd_open_bookmarks_in_tabs), NULL },
+
+	{ "OpenInWindow", N_("Open In New Browser..."), GTK_STOCK_JUMP_TO, NULL,
+	  NULL, G_CALLBACK (popup_cmd_open_bookmarks_in_browser), NULL },
+
+	{ "Remove", N_("Remove..."), GTK_STOCK_REMOVE, NULL,
+	  NULL, G_CALLBACK (popup_cmd_remove_bookmarks), NULL },
+};
+static guint ephy_bookmark_popup_n_entries = G_N_ELEMENTS (ephy_bookmark_popup_entries);
+
+
+static void
+popup_cmd_open_bookmarks_in_tabs (EggAction *action,
+				  EphyBookmarksEditor *editor)
+{
+	EphyWindow *window;
+	GList *selection;
+	GList *l;
+
+	window = EPHY_WINDOW (gtk_window_get_transient_for (GTK_WINDOW (editor)));
+	selection = ephy_node_view_get_selection (editor->priv->bm_view);
+
+	for (l = selection; l; l = l->next)
+	{
+		EphyNode *node = EPHY_NODE (l->data);
+		const char *location;
+
+		location = ephy_node_get_property_string (node,
+						EPHY_NODE_BMK_PROP_LOCATION);
+
+		ephy_shell_new_tab (ephy_shell, window, NULL, location,
+			EPHY_NEW_TAB_APPEND|EPHY_NEW_TAB_IN_EXISTING_WINDOW);
+	}
+
+	if (selection)
+	{
+		g_list_free (selection);
+	}
+}
+
+static void
+popup_cmd_open_bookmarks_in_browser (EggAction *action,
+				    EphyBookmarksEditor *editor)
+{
+	EphyWindow *window;
+	GList *selection;
+	GList *l;
+
+	window = EPHY_WINDOW (gtk_window_get_transient_for (GTK_WINDOW (editor)));
+	selection = ephy_node_view_get_selection (editor->priv->bm_view);
+
+	for (l = selection; l; l = l->next)
+	{
+		EphyNode *node = EPHY_NODE (l->data);
+		const char *location;
+		
+		location = ephy_node_get_property_string (node,
+						EPHY_NODE_BMK_PROP_LOCATION);
+
+		ephy_shell_new_tab (ephy_shell, window, NULL, location,
+				    EPHY_NEW_TAB_IN_NEW_WINDOW);
+	}
+
+	if (selection)
+	{
+		g_list_free (selection);
+	}
+}
+
+static void
+popup_cmd_remove_bookmarks (EggAction *action,
+			    EphyBookmarksEditor *editor)
+{
+	ephy_node_view_remove (editor->priv->bm_view);
+}
+
 GType
 ephy_bookmarks_editor_get_type (void)
 {
@@ -180,6 +275,11 @@
 
 	g_object_unref (G_OBJECT (editor->priv->bookmarks_filter));
 
+	g_object_unref (editor->priv->action_group);
+	egg_menu_merge_remove_action_group (editor->priv->ui_merge,
+					    editor->priv->action_group);
+	g_object_unref (editor->priv->ui_merge);
+
 	g_free (editor->priv);
 
 	G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -228,6 +328,18 @@
 }
 
 static void
+ephy_bookmarks_editor_show_popup_cb (GtkWidget *view,
+				     EphyBookmarksEditor *editor)
+{
+	GtkWidget *widget;
+	
+	widget = egg_menu_merge_get_widget (editor->priv->ui_merge, 
+					    "/popups/EphyBookmarkEditorPopup");
+	gtk_menu_popup (GTK_MENU (widget), NULL, NULL, NULL, NULL, 2,
+			gtk_get_current_event_time ());	
+}
+
+static void
 ephy_bookmarks_editor_node_activated_cb (GtkWidget *view,
 				         EphyNode *node,
 					 EphyBookmarksEditor *editor)
@@ -514,6 +626,27 @@
 	long selected_id;
 	EphyNode *selected_node;
 	char *selected_id_str;
+	EggMenuMerge *ui_merge;
+	EggActionGroup *action_group;
+	int i;
+	
+	for (i = 0; i < ephy_bookmark_popup_n_entries; i++)
+	{
+		ephy_bookmark_popup_entries[i].user_data = editor;
+	}
+
+	ui_merge = egg_menu_merge_new ();
+	action_group = egg_action_group_new ("PopupActions");
+	egg_action_group_add_actions (action_group, ephy_bookmark_popup_entries,
+				      ephy_bookmark_popup_n_entries);
+	egg_menu_merge_insert_action_group (ui_merge,
+					    action_group, 0);
+	egg_menu_merge_add_ui_from_file (ui_merge,
+				ephy_file ("epiphany-bookmark-editor-ui.xml"),
+				NULL);
+	editor->priv->ui_merge = ui_merge;
+	editor->priv->action_group = action_group;
+	
 
 	gtk_window_set_title (GTK_WINDOW (editor), _("Bookmarks"));
 
@@ -573,6 +706,10 @@
 	g_signal_connect (G_OBJECT (bm_view),
 			  "node_selected",
 			  G_CALLBACK (ephy_bookmarks_editor_node_selected_cb),
+			  editor);
+	g_signal_connect (G_OBJECT (bm_view),
+			  "show_popup",
+			  G_CALLBACK (ephy_bookmarks_editor_show_popup_cb),
 			  editor);
 
 	gtk_box_pack_start (GTK_BOX (vbox),


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