[PATCH] Merge notes and information panel



The attached proof-of-concept patch merges the notes and the information
panel.

-- 
Christian Neumair <chris gnome-de org>
? src/.nautilus-information-panel.c.swp
Index: src/nautilus-information-panel.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-information-panel.c,v
retrieving revision 1.234
diff -u -p -r1.234 nautilus-information-panel.c
--- src/nautilus-information-panel.c	18 Mar 2006 07:13:50 -0000	1.234
+++ src/nautilus-information-panel.c	30 Apr 2006 10:40:29 -0000
@@ -27,6 +27,7 @@
 #include "nautilus-information-panel.h"
 
 #include "nautilus-sidebar-title.h"
+#include "nautilus-notes-viewer.h"
 
 #include <eel/eel-background.h>
 #include <eel/eel-glib-extensions.h>
@@ -70,6 +71,7 @@ struct NautilusInformationPanelDetails {
 	NautilusSidebarTitle *title;
 	GtkHBox *button_box_centerer;
 	GtkVBox *button_box;
+	GtkWidget *notes_viewer;
 	gboolean has_buttons;
 	char *uri;
 	NautilusFile *file;
@@ -244,8 +246,9 @@ static void
 make_button_box (NautilusInformationPanel *information_panel)
 {
 	information_panel->details->button_box_centerer = GTK_HBOX (gtk_hbox_new (FALSE, 0));
-	gtk_box_pack_start_defaults (GTK_BOX (information_panel->details->container),
-			    	     GTK_WIDGET (information_panel->details->button_box_centerer));
+	gtk_box_pack_end (GTK_BOX (information_panel->details->container),
+			  GTK_WIDGET (information_panel->details->button_box_centerer),
+			  FALSE, FALSE, 0);
 
 	information_panel->details->button_box = GTK_VBOX (nautilus_keep_last_vertical_box_new (GNOME_PAD_SMALL));
 	gtk_container_set_border_width (GTK_CONTAINER (information_panel->details->button_box), GNOME_PAD);				
@@ -1202,6 +1205,10 @@ nautilus_information_panel_set_uri (Naut
 	nautilus_sidebar_title_set_file (information_panel->details->title,
 					 information_panel->details->file,
 					 initial_title);
+
+	if (information_panel->details->notes_viewer != NULL) {
+		nautilus_notes_viewer_set_uri (NAUTILUS_NOTES_VIEWER (information_panel->details->notes_viewer), new_uri);
+	}
 }
 
 static void
@@ -1256,6 +1263,15 @@ nautilus_information_panel_set_parent_wi
 	nautilus_information_panel_set_uri (panel, 
 					    location,
 					    title);
+
+	g_assert (panel->details->notes_viewer == NULL);
+
+	panel->details->notes_viewer = nautilus_notes_viewer_new
+		(nautilus_window_info_get_ui_manager (window));
+	gtk_container_add (GTK_CONTAINER (panel->details->container),
+			   panel->details->notes_viewer);
+	nautilus_notes_viewer_set_uri (NAUTILUS_NOTES_VIEWER (panel->details->notes_viewer), location);
+
 	g_free (location);
 	g_free (title);
 
Index: src/nautilus-notes-viewer.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-notes-viewer.c,v
retrieving revision 1.10
diff -u -p -r1.10 nautilus-notes-viewer.c
--- src/nautilus-notes-viewer.c	18 Mar 2006 07:13:50 -0000	1.10
+++ src/nautilus-notes-viewer.c	30 Apr 2006 10:40:31 -0000
@@ -23,7 +23,8 @@
  *
  */
 
-/* notes sidebar panel -- allows editing per-directory notes */
+/* notes widget -- allows editing file notes.
+ * Also implements property page provider. */
 
 #include <config.h>
 
@@ -46,7 +47,6 @@
 #include <libnautilus-private/nautilus-metadata.h>
 #include <libnautilus-private/nautilus-clipboard.h>
 #include <libnautilus-private/nautilus-module.h>
-#include <libnautilus-private/nautilus-sidebar-provider.h>
 #include <libnautilus-extension/nautilus-property-page-provider.h>
 
 #define SAVE_TIMEOUT (3 * 1000)
@@ -54,11 +54,9 @@
 static void load_note_text_from_metadata             (NautilusFile                      *file,
                                                       NautilusNotesViewer               *notes);
 static void notes_save_metainfo                      (NautilusNotesViewer               *notes);
-static void nautilus_notes_viewer_sidebar_iface_init (NautilusSidebarIface              *iface);
 static void on_changed                               (GtkEditable                       *editable,
                                                       NautilusNotesViewer               *notes);
 static void property_page_provider_iface_init        (NautilusPropertyPageProviderIface *iface);
-static void sidebar_provider_iface_init              (NautilusSidebarProviderIface       *iface);
 
 typedef struct {
 	GtkScrolledWindowClass parent;
@@ -73,20 +71,17 @@ typedef struct {
 } NautilusNotesViewerProviderClass;
 
 
-G_DEFINE_TYPE_WITH_CODE (NautilusNotesViewer, nautilus_notes_viewer, GTK_TYPE_SCROLLED_WINDOW,
-			 G_IMPLEMENT_INTERFACE (NAUTILUS_TYPE_SIDEBAR,
-						nautilus_notes_viewer_sidebar_iface_init));
+G_DEFINE_TYPE (NautilusNotesViewer, nautilus_notes_viewer, GTK_TYPE_SCROLLED_WINDOW);
 
 static GType nautilus_notes_viewer_provider_get_type (void);
 
 G_DEFINE_TYPE_WITH_CODE (NautilusNotesViewerProvider, nautilus_notes_viewer_provider, G_TYPE_OBJECT,
 			 G_IMPLEMENT_INTERFACE (NAUTILUS_TYPE_PROPERTY_PAGE_PROVIDER,
-						property_page_provider_iface_init);
-			 G_IMPLEMENT_INTERFACE (NAUTILUS_TYPE_SIDEBAR_PROVIDER,
-						sidebar_provider_iface_init));
+						property_page_provider_iface_init));
 
 
 struct _NautilusNotesViewerDetails {
+	GtkUIManager *ui_manager;
 	GtkWidget *note_text_field;
 	GtkTextBuffer *text_buffer;
 	char *uri;
@@ -138,11 +133,6 @@ set_saved_text (NautilusNotesViewer *not
 
 	old_text = notes->details->previous_saved_text;
 	notes->details->previous_saved_text = new_notes;        
-        
-	if (eel_strcmp (old_text, new_notes) != 0) {
-                g_signal_emit_by_name (NAUTILUS_SIDEBAR (notes),
-                                       "tab_icon_changed");
-	}
 
         g_free (old_text);
 }
@@ -278,19 +268,6 @@ notes_load_metainfo (NautilusNotesViewer
                           G_CALLBACK (load_note_text_from_metadata), notes);
 }
 
-static void
-loading_uri_callback (NautilusSidebar *sidebar,
-                      const char *location,
-                      NautilusNotesViewer *notes)
-{
-        if (strcmp (notes->details->uri, location) != 0) {
-                notes_save_metainfo (notes);
-                g_free (notes->details->uri);
-                notes->details->uri = g_strdup (location);
-                notes_load_metainfo (notes);
-        }
-}
-
 static gboolean
 on_text_field_focus_out_event (GtkWidget *widget,
 			       GdkEventFocus *event,
@@ -317,8 +294,6 @@ nautilus_notes_viewer_init (NautilusNote
         
         details = g_new0 (NautilusNotesViewerDetails, 1);
         sidebar->details = details;
-        
-        details->uri = g_strdup ("");
 
         image_path = nautilus_pixmap_file ("note-indicator.png");
         if (image_path) {
@@ -376,84 +351,34 @@ nautilus_notes_viewer_class_init (Nautil
 	G_OBJECT_CLASS (class)->finalize = nautilus_notes_viewer_finalize;
 }
 
-static const char *
-nautilus_notes_viewer_get_sidebar_id (NautilusSidebar *sidebar)
-{
-	return NAUTILUS_NOTES_SIDEBAR_ID;
-}
-
-static char *
-nautilus_notes_viewer_get_tab_label (NautilusSidebar *sidebar)
-{
-	return g_strdup (_("Notes"));
-}
-
-static char *
-nautilus_notes_viewer_get_tab_tooltip (NautilusSidebar *sidebar)
+void
+nautilus_notes_viewer_set_uri (NautilusNotesViewer *viewer,
+			       const char *uri)
 {
-	return g_strdup (_("Show Notes"));
-}
-
-static GdkPixbuf *
-nautilus_notes_viewer_get_tab_icon (NautilusSidebar *sidebar)
-{
-	NautilusNotesViewer *notes;
+	if (viewer->details->uri != NULL) {
+		notes_save_metainfo (viewer);
+	}
 
-        notes = NAUTILUS_NOTES_VIEWER (sidebar);
-        
-        if (notes->details->previous_saved_text != NULL &&
-            notes->details->previous_saved_text[0] != '\0') {
-                return g_object_ref (notes->details->icon);
-        }
-        
-        return NULL;
+	g_free (viewer->details->uri);
+	viewer->details->uri = g_strdup (uri);
+	notes_load_metainfo (viewer);
 }
 
-static void
-nautilus_notes_viewer_is_visible_changed (NautilusSidebar *sidebar,
-					     gboolean         is_visible)
-{
-	/* Do nothing */
-}
 
-static void
-nautilus_notes_viewer_sidebar_iface_init (NautilusSidebarIface *iface)
+GtkWidget *
+nautilus_notes_viewer_new (GtkUIManager *ui_manager)
 {
-	iface->get_sidebar_id = nautilus_notes_viewer_get_sidebar_id;
-	iface->get_tab_label = nautilus_notes_viewer_get_tab_label;
-	iface->get_tab_tooltip = nautilus_notes_viewer_get_tab_tooltip;
-	iface->get_tab_icon = nautilus_notes_viewer_get_tab_icon;
-	iface->is_visible_changed = nautilus_notes_viewer_is_visible_changed;
-}
-
-static void
-nautilus_notes_viewer_set_parent_window (NautilusNotesViewer *sidebar,
-                                          NautilusWindowInfo *window)
-{
-	g_signal_connect_object (window, "loading_uri",
-				 G_CALLBACK (loading_uri_callback), sidebar, 0);
-        
-        g_free (sidebar->details->uri);
-        sidebar->details->uri = nautilus_window_info_get_current_location (window);
-        notes_load_metainfo (sidebar);
+	NautilusNotesViewer *viewer;
 
-	nautilus_clipboard_set_up_text_view
-		(GTK_TEXT_VIEW (sidebar->details->note_text_field),
-		 nautilus_window_info_get_ui_manager (window));
-}
+	viewer = g_object_new (nautilus_notes_viewer_get_type (), NULL);
 
-static NautilusSidebar *
-nautilus_notes_viewer_create_sidebar (NautilusSidebarProvider *provider,
-                                      NautilusWindowInfo *window)
-{
-	NautilusNotesViewer *sidebar;
-	
-	sidebar = g_object_new (nautilus_notes_viewer_get_type (), NULL);
-	nautilus_notes_viewer_set_parent_window (sidebar, window);
-	g_object_ref (sidebar);
-	gtk_object_sink (GTK_OBJECT (sidebar));
+	if (ui_manager != NULL) {
+		nautilus_clipboard_set_up_text_view
+			(GTK_TEXT_VIEW (viewer->details->note_text_field),
+			 ui_manager);
+	}
 
-	return NAUTILUS_SIDEBAR (sidebar);
+	return GTK_WIDGET (viewer);
 }
 
 /* nautilus_property_page_provider_get_pages
@@ -475,9 +400,8 @@ get_property_pages (NautilusPropertyPage
 	NautilusPropertyPage *page;
 	NautilusFileInfo *file;
         char *uri;
-	NautilusNotesViewer *viewer;
-	
-	
+	GtkWidget *viewer;
+
 	/* Only show the property page if 1 file is selected */
 	if (!files || files->next != NULL) {
 		return NULL;
@@ -487,16 +411,14 @@ get_property_pages (NautilusPropertyPage
 	
 	file = NAUTILUS_FILE_INFO (files->data);
         uri = nautilus_file_info_get_uri (file);
-	
-	viewer = g_object_new (nautilus_notes_viewer_get_type (), NULL);
-        g_free (viewer->details->uri);
-        viewer->details->uri = uri;
-        notes_load_metainfo (viewer);
+
+	viewer = nautilus_notes_viewer_new (NULL);
+	nautilus_notes_viewer_set_uri (NAUTILUS_NOTES_VIEWER (viewer), uri);
+	g_free (uri);
 
         page = nautilus_property_page_new
                 ("NautilusNotesViewer::property_page", 
-                 gtk_label_new (_("Notes")),
-                 GTK_WIDGET (viewer));
+                 gtk_label_new (_("Notes")), viewer);
         pages = g_list_append (pages, page);
 
 	return pages;
@@ -508,19 +430,13 @@ property_page_provider_iface_init (Nauti
 	iface->get_pages = get_property_pages;
 }
 
-static void 
-sidebar_provider_iface_init (NautilusSidebarProviderIface *iface)
-{
-	iface->create = nautilus_notes_viewer_create_sidebar;
-}
-
 static void
 nautilus_notes_viewer_provider_init (NautilusNotesViewerProvider *sidebar)
 {
 }
 
 static void
-nautilus_notes_viewer_provider_class_init (NautilusNotesViewerProviderClass *class)
+nautilus_notes_viewer_provider_class_init (NautilusNotesViewerProviderClass *klass)
 {
 }
 
Index: src/nautilus-notes-viewer.h
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-notes-viewer.h,v
retrieving revision 1.2
diff -u -p -r1.2 nautilus-notes-viewer.h
--- src/nautilus-notes-viewer.h	22 Nov 2004 15:24:37 -0000	1.2
+++ src/nautilus-notes-viewer.h	30 Apr 2006 10:40:31 -0000
@@ -43,6 +43,10 @@ typedef struct {
 	NautilusNotesViewerDetails *details;
 } NautilusNotesViewer;
 
+GtkWidget *nautilus_notes_viewer_new (GtkUIManager *ui_manager);
+void       nautilus_notes_viewer_set_uri (NautilusNotesViewer *viewer,
+					  const char *uri);
+
 GType nautilus_notes_viewer_get_type (void);
 void nautilus_notes_viewer_register (void);
 


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