[gnome-builder/wip/project-selector: 36/72] project-selector: close windows after launching project
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/project-selector: 36/72] project-selector: close windows after launching project
- Date: Tue, 7 Apr 2015 23:00:42 +0000 (UTC)
commit 4c0533aa0b39905d41423ffc9252a91d8883d507
Author: Christian Hergert <christian hergert me>
Date: Thu Apr 2 20:37:47 2015 -0700
project-selector: close windows after launching project
src/dialogs/gb-new-project-dialog.c | 22 +++++++++++++---------
src/workbench/gb-project-window.c | 25 +++++++++++++++++++++++++
2 files changed, 38 insertions(+), 9 deletions(-)
---
diff --git a/src/dialogs/gb-new-project-dialog.c b/src/dialogs/gb-new-project-dialog.c
index b4433e9..bf68fed 100644
--- a/src/dialogs/gb-new-project-dialog.c
+++ b/src/dialogs/gb-new-project-dialog.c
@@ -18,7 +18,6 @@
#include <glib/gi18n.h>
-#include "gb-application.h"
#include "gb-new-project-dialog.h"
#include "gb-widget.h"
@@ -46,6 +45,7 @@ enum {
enum {
BACK,
CLOSE,
+ OPEN_PROJECT,
LAST_SIGNAL
};
@@ -91,14 +91,11 @@ static void
gb_new_project_dialog__create_button_clicked (GbNewProjectDialog *self,
GtkButton *cancel_button)
{
- GApplication *app;
GtkWidget *visible_child;
g_assert (GB_IS_NEW_PROJECT_DIALOG (self));
g_assert (GTK_IS_BUTTON (cancel_button));
- app = g_application_get_default ();
-
visible_child = gtk_stack_get_visible_child (self->stack);
if (visible_child == GTK_WIDGET (self->file_chooser))
@@ -106,12 +103,8 @@ gb_new_project_dialog__create_button_clicked (GbNewProjectDialog *self,
g_autoptr(GFile) file = NULL;
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (self->file_chooser));
-
if (file != NULL)
- {
- gb_application_open_project (GB_APPLICATION (app), file, NULL);
- gtk_window_close (GTK_WINDOW (self));
- }
+ g_signal_emit (self, gSignals [OPEN_PROJECT], 0, file);
}
}
@@ -271,6 +264,17 @@ gb_new_project_dialog_class_init (GbNewProjectDialogClass *klass)
G_TYPE_NONE,
0);
+ gSignals [OPEN_PROJECT] =
+ g_signal_new ("open-project",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_FILE);
+
binding_set = gtk_binding_set_by_class (klass);
gtk_binding_entry_add_signal (binding_set,
diff --git a/src/workbench/gb-project-window.c b/src/workbench/gb-project-window.c
index fc3629c..3aacf22 100644
--- a/src/workbench/gb-project-window.c
+++ b/src/workbench/gb-project-window.c
@@ -25,6 +25,7 @@
#include <glib/gi18n.h>
#include <ide.h>
+#include "gb-application.h"
#include "gb-editor-document.h"
#include "gb-glib.h"
#include "gb-new-project-dialog.h"
@@ -607,6 +608,23 @@ gb_project_window__search_entry_changed (GbProjectWindow *self,
}
static void
+gb_project_window__window_open_project (GbProjectWindow *self,
+ GFile *project_file,
+ GbNewProjectDialog *dialog)
+{
+ GApplication *app = g_application_get_default ();
+
+ g_assert (GB_IS_PROJECT_WINDOW (self));
+ g_assert (G_IS_FILE (project_file));
+ g_assert (GB_IS_NEW_PROJECT_DIALOG (dialog));
+ g_assert (GB_IS_APPLICATION (app));
+
+ gb_application_open_project (GB_APPLICATION (app), project_file, NULL);
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ gtk_widget_destroy (GTK_WIDGET (self));
+}
+
+static void
gb_project_window__new_button_clicked (GbProjectWindow *self,
GtkButton *new_button)
{
@@ -622,6 +640,13 @@ gb_project_window__new_button_clicked (GbProjectWindow *self,
"type-hint", GDK_WINDOW_TYPE_HINT_DIALOG,
"visible", TRUE,
NULL);
+
+ g_signal_connect_object (window,
+ "open-project",
+ G_CALLBACK (gb_project_window__window_open_project),
+ self,
+ G_CONNECT_SWAPPED);
+
gtk_window_present (window);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]