summarylogtreecommitdiffstats
path: root/menubar.patch
blob: 81298bd54ad31787e6ca3864b1749d49e2adf24e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
diff --git a/gedit/gedit-app.c b/gedit/gedit-app.c
index 77faf73e5..55ece43a0 100644
--- a/gedit/gedit-app.c
+++ b/gedit/gedit-app.c
@@ -640,6 +640,7 @@ add_accelerator (GtkApplication *app,
 static gboolean
 show_menubar (void)
 {
+	return TRUE;
 	GtkSettings *settings = gtk_settings_get_default ();
 	gboolean result;
 
@@ -1175,6 +1176,7 @@ gedit_app_create_window_impl (GeditApp *app)
 	window = g_object_new (GEDIT_TYPE_WINDOW,
 			       "application", app,
 			       NULL);
+	_gedit_window_set_menu_bar_from_app (window, GTK_APPLICATION(app));
 
 	g_signal_connect (window,
 			  "delete-event",
diff --git a/gedit/gedit-window.c b/gedit/gedit-window.c
index 8ef331e95..dd719ec10 100644
--- a/gedit/gedit-window.c
+++ b/gedit/gedit-window.c
@@ -2636,6 +2636,34 @@ gedit_window_init (GeditWindow *window)
 	gedit_debug_message (DEBUG_WINDOW, "END");
 }
 
+void
+_gedit_window_set_menu_bar_from_app (GeditWindow *window, GtkApplication *app)
+{
+	GtkWidget   *container;
+	GtkWidget   *menubar;
+	GMenuModel  *menumodel;
+	gboolean     visible;
+
+	g_object_get(G_OBJECT(window), "show-menubar", &visible, NULL);
+	if(! visible) return;
+
+	menumodel = gtk_application_get_menubar(app);
+	if(! menumodel) return;
+
+	menubar   = gtk_menu_bar_new_from_model(menumodel);
+	gtk_widget_show_all(menubar);
+
+	container = gtk_paned_get_child2(GTK_PANED(window->priv->hpaned));
+	if(! GTK_IS_BOX(container)) {
+		g_free(menubar);
+		return;
+	}
+
+	g_object_set(G_OBJECT(window), "show-menubar", FALSE, NULL);
+	gtk_box_pack_start(GTK_BOX(container), menubar, FALSE, FALSE, 0);
+	gtk_box_reorder_child(GTK_BOX(container), menubar, 0);
+}
+
 /**
  * gedit_window_get_active_view:
  * @window: a #GeditWindow.
diff --git a/gedit/gedit-window.h b/gedit/gedit-window.h
index 176c85adf..7a52ebf81 100644
--- a/gedit/gedit-window.h
+++ b/gedit/gedit-window.h
@@ -167,6 +167,9 @@ GList *		_gedit_window_get_all_tabs		(GeditWindow *window);
 G_GNUC_INTERNAL
 GFile *		_gedit_window_pop_last_closed_doc	(GeditWindow *window);
 
+void		_gedit_window_set_menu_bar_from_app	(GeditWindow         *window,
+							 GtkApplication      *app);
+
 G_END_DECLS
 
 #endif /* GEDIT_WINDOW_H */