[gnome-builder/wip/project-selector: 9/10] projects: allow opening a new project from application menu
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/project-selector: 9/10] projects: allow opening a new project from application menu
- Date: Mon, 30 Mar 2015 21:10:24 +0000 (UTC)
commit 9f4b117928ed629d242df408450b1db593d12c8c
Author: Christian Hergert <christian hergert me>
Date: Mon Mar 30 13:09:53 2015 -0700
projects: allow opening a new project from application menu
data/gtk/menus.ui | 7 +++++++
src/app/gb-application-actions.c | 21 +++++++++++++++++----
src/app/gb-application.c | 27 ++++++++++++++++++++++++---
src/app/gb-application.h | 2 ++
4 files changed, 50 insertions(+), 7 deletions(-)
---
diff --git a/data/gtk/menus.ui b/data/gtk/menus.ui
index 538efde..8b2cfe5 100644
--- a/data/gtk/menus.ui
+++ b/data/gtk/menus.ui
@@ -3,6 +3,13 @@
<!-- interface-requires gtk+ 3.0 -->
<menu id="app-menu">
<section>
+ <attribute name="id">open-section</attribute>
+ <item>
+ <attribute name="label" translatable="yes">_Open Project</attribute>
+ <attribute name="action">app.open-project</attribute>
+ </item>
+ </section>
+ <section>
<attribute name="id">preferences-section</attribute>
<item>
<attribute name="label" translatable="yes">_Preferences</attribute>
diff --git a/src/app/gb-application-actions.c b/src/app/gb-application-actions.c
index 29ca446..9462e18 100644
--- a/src/app/gb-application-actions.c
+++ b/src/app/gb-application-actions.c
@@ -180,11 +180,24 @@ gb_application_actions_about (GSimpleAction *action,
gtk_window_present (GTK_WINDOW (dialog));
}
+static void
+gb_application_actions_open_project (GSimpleAction *action,
+ GVariant *variant,
+ gpointer user_data)
+{
+ GbApplication *self = user_data;
+
+ g_assert (GB_IS_APPLICATION (self));
+
+ gb_application_show_projects_window (self);
+}
+
static const GActionEntry GbApplicationActions[] = {
- { "about", gb_application_actions_about },
- { "preferences", gb_application_actions_preferences },
- { "quit", gb_application_actions_quit },
- { "support", gb_application_actions_support },
+ { "about", gb_application_actions_about },
+ { "open-project", gb_application_actions_open_project },
+ { "preferences", gb_application_actions_preferences },
+ { "quit", gb_application_actions_quit },
+ { "support", gb_application_actions_support },
};
void
diff --git a/src/app/gb-application.c b/src/app/gb-application.c
index 431da89..4d1ae96 100644
--- a/src/app/gb-application.c
+++ b/src/app/gb-application.c
@@ -428,14 +428,25 @@ gb_application_open (GApplication *application,
IDE_EXIT;
}
-static void
-gb_application_activate (GApplication *application)
+void
+gb_application_show_projects_window (GbApplication *self)
{
- GbApplication *self = (GbApplication *)application;
GbProjectWindow *window;
+ GList *windows;
g_assert (GB_IS_APPLICATION (self));
+ windows = gtk_application_get_windows (GTK_APPLICATION (self));
+
+ for (; windows; windows = windows->next)
+ {
+ if (GB_IS_PROJECT_WINDOW (windows->data))
+ {
+ gtk_window_present (windows->data);
+ return;
+ }
+ }
+
window = g_object_new (GB_TYPE_PROJECT_WINDOW,
"application", self,
NULL);
@@ -444,6 +455,16 @@ gb_application_activate (GApplication *application)
}
static void
+gb_application_activate (GApplication *application)
+{
+ GbApplication *self = (GbApplication *)application;
+
+ g_assert (GB_IS_APPLICATION (self));
+
+ gb_application_show_projects_window (self);
+}
+
+static void
gb_application_startup (GApplication *app)
{
GbApplication *self = (GbApplication *)app;
diff --git a/src/app/gb-application.h b/src/app/gb-application.h
index 43d2666..93650a2 100644
--- a/src/app/gb-application.h
+++ b/src/app/gb-application.h
@@ -27,6 +27,8 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (GbApplication, gb_application, GB, APPLICATION, GtkApplication)
+void gb_application_show_projects_window (GbApplication *self);
+
G_END_DECLS
#endif /* GB_APPLICATION_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]