[nautilus] window: make NautilusWindow a GtkApplicationWindow



commit 581a1df69a19d7ac7236202ca2a1839e667bce88
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Apr 23 18:33:15 2012 -0400

    window: make NautilusWindow a GtkApplicationWindow
    
    So we can use the application menu with it.
    Note that we set show_menubar always to FALSE, since we already show a
    menubar ourselves.
    This will probably need a little more tweaking to make sure that in
    fallback mode we get the same number of options in the menus.

 src/nautilus-application.c    |   12 +++++-------
 src/nautilus-desktop-window.c |    4 +++-
 src/nautilus-desktop-window.h |    3 ++-
 src/nautilus-window.c         |   14 ++++++++------
 src/nautilus-window.h         |    7 ++++---
 5 files changed, 22 insertions(+), 18 deletions(-)
---
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
index 26be4a5..6838361 100644
--- a/src/nautilus-application.c
+++ b/src/nautilus-application.c
@@ -400,7 +400,8 @@ nautilus_application_create_desktop_windows (NautilusApplication *application)
 		
 		selection_widget = get_desktop_manager_selection (display, i);
 		if (selection_widget != NULL) {
-			window = nautilus_desktop_window_new (gdk_display_get_screen (display, i));
+			window = nautilus_desktop_window_new (GTK_APPLICATION (application),
+							      gdk_display_get_screen (display, i));
 
 			g_signal_connect (selection_widget, "selection_clear_event",
 					  G_CALLBACK (selection_clear_event_cb), window);
@@ -416,9 +417,6 @@ nautilus_application_create_desktop_windows (NautilusApplication *application)
 
 			nautilus_application_desktop_windows =
 				g_list_prepend (nautilus_application_desktop_windows, window);
-
-			gtk_application_add_window (GTK_APPLICATION (application),
-						    GTK_WINDOW (window));
 		}
 	}
 }
@@ -484,9 +482,7 @@ nautilus_application_create_window (NautilusApplication *application,
 
 	g_return_val_if_fail (NAUTILUS_IS_APPLICATION (application), NULL);
 
-	window = nautilus_window_new (screen);
-	gtk_application_add_window (GTK_APPLICATION (application),
-				    GTK_WINDOW (window));
+	window = nautilus_window_new (GTK_APPLICATION (application), screen);
 
 	maximized = g_settings_get_boolean
 		(nautilus_window_state, NAUTILUS_WINDOW_STATE_MAXIMIZED);
@@ -513,6 +509,8 @@ nautilus_application_create_window (NautilusApplication *application,
 	}
 	g_free (geometry_string);
 
+	nautilus_undo_manager_attach (application->undo_manager, G_OBJECT (window));
+
 	DEBUG ("Creating a new navigation window");
 	
 	return window;
diff --git a/src/nautilus-desktop-window.c b/src/nautilus-desktop-window.c
index d0d48cc..ad01588 100644
--- a/src/nautilus-desktop-window.c
+++ b/src/nautilus-desktop-window.c
@@ -148,7 +148,8 @@ nautilus_desktop_window_screen_size_changed (GdkScreen             *screen,
 }
 
 NautilusDesktopWindow *
-nautilus_desktop_window_new (GdkScreen *screen)
+nautilus_desktop_window_new (GtkApplication *application,
+			     GdkScreen      *screen)
 {
 	NautilusDesktopWindow *window;
 	int width_request, height_request;
@@ -157,6 +158,7 @@ nautilus_desktop_window_new (GdkScreen *screen)
 	height_request = gdk_screen_get_height (screen);
 
 	window = g_object_new (NAUTILUS_TYPE_DESKTOP_WINDOW,
+			       "application", application,
 			       "disable-chrome", TRUE,
 			       "width_request", width_request,
 			       "height_request", height_request,
diff --git a/src/nautilus-desktop-window.h b/src/nautilus-desktop-window.h
index a5ce391..f6183c4 100644
--- a/src/nautilus-desktop-window.h
+++ b/src/nautilus-desktop-window.h
@@ -54,7 +54,8 @@ typedef struct {
 } NautilusDesktopWindowClass;
 
 GType                  nautilus_desktop_window_get_type            (void);
-NautilusDesktopWindow *nautilus_desktop_window_new                 (GdkScreen *screen);
+NautilusDesktopWindow *nautilus_desktop_window_new                 (GtkApplication        *application,
+								    GdkScreen             *screen);
 gboolean               nautilus_desktop_window_loaded              (NautilusDesktopWindow *window);
 
 #endif /* NAUTILUS_DESKTOP_WINDOW_H */
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index f0cc616..33e0ecb 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -32,7 +32,6 @@
 #include "nautilus-window-private.h"
 
 #include "nautilus-actions.h"
-#include "nautilus-application.h"
 #include "nautilus-bookmarks-window.h"
 #include "nautilus-location-bar.h"
 #include "nautilus-mime-actions.h"
@@ -123,7 +122,7 @@ static void cancel_view_as_callback         (NautilusWindowSlot      *slot);
 static void action_view_as_callback         (GtkAction               *action,
 					     ActivateViewData        *data);
 
-G_DEFINE_TYPE (NautilusWindow, nautilus_window, GTK_TYPE_WINDOW);
+G_DEFINE_TYPE (NautilusWindow, nautilus_window, GTK_TYPE_APPLICATION_WINDOW);
 
 static const struct {
 	unsigned int keyval;
@@ -525,13 +524,15 @@ nautilus_window_constructed (GObject *self)
 	GtkWidget *vbox;
 	NautilusWindowPane *pane;
 	NautilusWindowSlot *slot;
-	NautilusApplication *application;
 
 	window = NAUTILUS_WINDOW (self);
-	application = nautilus_application_get_singleton ();
 
 	G_OBJECT_CLASS (nautilus_window_parent_class)->constructed (self);
 
+	/* disable automatic menubar handling, since we show our regular
+	 * menubar together with the app menu.
+	 */
+	gtk_application_window_set_show_menubar (GTK_APPLICATION_WINDOW (self), FALSE);
 
 	grid = gtk_grid_new ();
 	gtk_orientable_set_orientation (GTK_ORIENTABLE (grid), GTK_ORIENTATION_VERTICAL);
@@ -602,7 +603,6 @@ nautilus_window_constructed (GObject *self)
 
 	nautilus_window_initialize_bookmarks_menu (window);
 	nautilus_window_set_initial_window_geometry (window);
-	nautilus_undo_manager_attach (application->undo_manager, G_OBJECT (window));
 
 	slot = nautilus_window_pane_open_slot (window->details->active_pane, 0);
 	nautilus_window_set_active_slot (window, slot);
@@ -2009,9 +2009,11 @@ nautilus_window_class_init (NautilusWindowClass *class)
 }
 
 NautilusWindow *
-nautilus_window_new (GdkScreen *screen)
+nautilus_window_new (GtkApplication *application,
+		     GdkScreen      *screen)
 {
 	return g_object_new (NAUTILUS_TYPE_WINDOW,
+			     "application", application,
 			     "screen", screen,
 			     NULL);
 }
diff --git a/src/nautilus-window.h b/src/nautilus-window.h
index cbda474..ce6023b 100644
--- a/src/nautilus-window.h
+++ b/src/nautilus-window.h
@@ -73,7 +73,7 @@ typedef enum {
 typedef struct NautilusWindowDetails NautilusWindowDetails;
 
 typedef struct {
-        GtkWindowClass parent_spot;
+        GtkApplicationWindowClass parent_spot;
 
 	/* Function pointers for overriding, without corresponding signals */
 
@@ -91,13 +91,14 @@ typedef struct {
 } NautilusWindowClass;
 
 struct NautilusWindow {
-        GtkWindow parent_object;
+        GtkApplicationWindow parent_object;
         
         NautilusWindowDetails *details;
 };
 
 GType            nautilus_window_get_type             (void);
-NautilusWindow * nautilus_window_new                  (GdkScreen         *screen);
+NautilusWindow * nautilus_window_new                  (GtkApplication    *application,
+                                                       GdkScreen         *screen);
 void             nautilus_window_close                (NautilusWindow    *window);
 
 void             nautilus_window_connect_content_view (NautilusWindow    *window,



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