[Glade-devel] [patch, glade3] close a project
- From: pborelli katamail com (paolo borelli)
- Subject: [Glade-devel] [patch, glade3] close a project
- Date: 17 Apr 2003 15:17:52 +0200
--=-Hd1ycMZ0e1CLV6To4anU
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Hi!
This patch is not submitted for inclusion yet (unless you think it's ok
as is)
The a attached patch is a first cut at adding the abilty to close a
project; what I am not sure about is what should be done when a project
is closed: for now what I do is
- remove the menu entry
- remove the projects from the projects list
- switch the current project to the first in the list (unless there are
no more)
- refresh the main window title
A thing that it lacks for sure is that it does not close all windows of
the project... what about views?
Any suggestion, advices ?
ciao
paolo
--=-Hd1ycMZ0e1CLV6To4anU
Content-Disposition: attachment; filename=close_project.patch
Content-Type: text/x-patch; name=close_project.patch; charset=UTF-8
Content-Transfer-Encoding: 7bit
diff -upr gnome2/glade3/src/glade-project.c glade3/src/glade-project.c
--- gnome2/glade3/src/glade-project.c 2003-04-17 09:51:55.000000000 +0200
+++ glade3/src/glade-project.c 2003-04-17 13:05:03.000000000 +0200
@@ -29,6 +29,7 @@
#include "glade.h"
#include "glade-project.h"
#include "glade-project-window.h"
+#include "glade-project-view.h"
#include "glade-widget.h"
#include "glade-widget-class.h"
#include "glade-xml-utils.h"
@@ -702,3 +703,36 @@ glade_project_save (GladeProject *projec
return TRUE;
}
+
+/**
+ * glade_project_close:
+ * @project:
+ *
+ * Close a project.
+ **/
+void
+glade_project_close (GladeProject *project)
+{
+ GladeProjectWindow *gpw;
+
+ g_return_if_fail (GLADE_IS_PROJECT (project));
+
+ gpw = glade_project_window_get ();
+
+ /* Remove the project from the /Project menu. */
+ gtk_item_factory_delete_entry (gpw->item_factory, &(project->entry));
+
+ gpw->projects = g_list_remove (gpw->projects, project);
+
+ /* if no more projects */
+ if (gpw->projects == NULL) {
+ gpw->project = NULL;
+ glade_project_window_refresh_title (gpw);
+ return;
+ }
+
+ glade_project_window_set_project (gpw, gpw->projects->data);
+
+}
+
+
diff -upr gnome2/glade3/src/glade-project.h glade3/src/glade-project.h
--- gnome2/glade3/src/glade-project.h 2003-04-17 09:51:55.000000000 +0200
+++ glade3/src/glade-project.h 2003-04-17 11:56:46.000000000 +0200
@@ -66,6 +66,7 @@ GladeProject *glade_project_new (gboolea
/* Project operations */
gboolean glade_project_save (GladeProject *project, const gchar *path);
gboolean glade_project_open (const gchar *path);
+void glade_project_close (GladeProject *project);
/* Widget related stuff */
diff -upr gnome2/glade3/src/glade-project-window.c glade3/src/glade-project-window.c
--- gnome2/glade3/src/glade-project-window.c 2003-04-17 09:51:55.000000000 +0200
+++ glade3/src/glade-project-window.c 2003-04-17 11:59:00.000000000 +0200
@@ -226,6 +226,23 @@ gpw_confirm_close_project (GladeProject
}
static void
+gpw_close_cb (void)
+{
+ GladeProject *project;
+ gboolean close;
+
+ project = glade_project_window_get_project ();
+
+ if (project->changed) {
+ close = gpw_confirm_close_project (project);
+ if (!close)
+ return;
+ }
+
+ glade_project_close (project);
+}
+
+static void
gpw_quit_cb (void)
{
GladeProjectWindow *gpw;
@@ -342,31 +359,32 @@ static GtkItemFactoryEntry menu_items[]
{ "/File/_Save", "<control>S", gpw_save_cb, 3, "<StockItem>", GTK_STOCK_SAVE },
{ "/File/Save _As...", "<control><shift>S", gpw_save_as_cb, 4, "<StockItem>", GTK_STOCK_SAVE_AS },
{ "/File/sep2", NULL, NULL, 0, "<Separator>" },
- { "/File/_Quit", "<control>Q", gpw_quit_cb, 5, "<StockItem>", GTK_STOCK_QUIT },
+ { "/File/_Close", "<control>W", gpw_close_cb, 5, "<StockItem>", GTK_STOCK_CLOSE },
+ { "/File/_Quit", "<control>Q", gpw_quit_cb, 6, "<StockItem>", GTK_STOCK_QUIT },
/* ============ EDIT ============ */
{ "/Edit", NULL, 0, 0, "<Branch>" },
- { "/Edit/_Undo", "<control>Z", gpw_undo_cb, 6, "<StockItem>", GTK_STOCK_UNDO },
- { "/Edit/_Redo", "<control>R", gpw_redo_cb, 7, "<StockItem>", GTK_STOCK_REDO },
+ { "/Edit/_Undo", "<control>Z", gpw_undo_cb, 7, "<StockItem>", GTK_STOCK_UNDO },
+ { "/Edit/_Redo", "<control>R", gpw_redo_cb, 8, "<StockItem>", GTK_STOCK_REDO },
{ "/Edit/sep1", NULL, NULL, 0, "<Separator>" },
- { "/Edit/C_ut", NULL, gpw_cut_cb, 8, "<StockItem>", GTK_STOCK_CUT },
- { "/Edit/_Copy", NULL, gpw_copy_cb, 9, "<StockItem>", GTK_STOCK_COPY },
- { "/Edit/_Paste", NULL, gpw_paste_cb, 10, "<StockItem>", GTK_STOCK_PASTE },
- { "/Edit/_Delete", "Delete", gpw_delete_cb, 11, "<StockItem>", GTK_STOCK_DELETE },
+ { "/Edit/C_ut", NULL, gpw_cut_cb, 9, "<StockItem>", GTK_STOCK_CUT },
+ { "/Edit/_Copy", NULL, gpw_copy_cb, 10, "<StockItem>", GTK_STOCK_COPY },
+ { "/Edit/_Paste", NULL, gpw_paste_cb, 11, "<StockItem>", GTK_STOCK_PASTE },
+ { "/Edit/_Delete", "Delete", gpw_delete_cb, 12, "<StockItem>", GTK_STOCK_DELETE },
/* ============ VIEW ============ */
{ "/View", NULL, 0, 0, "<Branch>" },
- { "/View/_Palette", NULL, gpw_toggle_palette_cb, 12, "<ToggleItem>" },
- { "/View/Property _Editor", NULL, gpw_toggle_editor_cb, 13, "<ToggleItem>" },
- { "/View/_Widget Tree", NULL, gpw_toggle_widget_tree_cb, 14, "<ToggleItem>" },
- { "/View/_Clipboard", NULL, gpw_toggle_clipboard_cb, 15, "<ToggleItem>" },
+ { "/View/_Palette", NULL, gpw_toggle_palette_cb, 13, "<ToggleItem>" },
+ { "/View/Property _Editor", NULL, gpw_toggle_editor_cb, 14, "<ToggleItem>" },
+ { "/View/_Widget Tree", NULL, gpw_toggle_widget_tree_cb, 15, "<ToggleItem>" },
+ { "/View/_Clipboard", NULL, gpw_toggle_clipboard_cb, 16, "<ToggleItem>" },
/* =========== PROJECT ========== */
{ "/Project", NULL, 0, 0, "<Branch>" },
/* ============ HELP ============ */
{ "/_Help", NULL, NULL, 0, "<Branch>" },
- { "/Help/_About", NULL, gpw_about_cb, 16 },
+ { "/Help/_About", NULL, gpw_about_cb, 17 },
};
/*
@@ -378,22 +396,23 @@ static const gchar *menu_tips[] =
N_("Create a new project file"), /* action 1 (New) */
N_("Open a project file"), /* action 2 (Open) */
N_("Save the current project file"), /* action 3 (Save) */
- N_("Save the current project file with a different name"), /* action 4 (Save as) */
- N_("Quit the program"), /* action 5 (Quit) */
-
- N_("Undo the last action"), /* action 6 (Undo) */
- N_("Redo the last action"), /* action 7 (Redo) */
- N_("Cut the selection"), /* action 8 (Cut) */
- N_("Copy the selection"), /* action 9 (Copy) */
- N_("Paste the clipboard"), /* action 10 (Paste) */
- N_("Delete the selection"), /* action 11 (Delete) */
-
- N_("Change the visibility of the palette of widgets"), /* action 12 (Palette) */
- N_("Change the visibility of the property editor"), /* action 13 (Editor) */
- N_("Change the visibility of the project widget tree"), /* action 14 (Tree) */
- N_("Change the visibility of the clipboard"), /* action 15 (Clipboard) */
+ N_("Save the current project file with a different name"), /* action 4 (Save as) */
+ N_("Close the current project file"), /* action 5 (Close) */
+ N_("Quit the program"), /* action 6 (Quit) */
+
+ N_("Undo the last action"), /* action 7 (Undo) */
+ N_("Redo the last action"), /* action 8 (Redo) */
+ N_("Cut the selection"), /* action 9 (Cut) */
+ N_("Copy the selection"), /* action 10 (Copy) */
+ N_("Paste the clipboard"), /* action 11 (Paste) */
+ N_("Delete the selection"), /* action 12 (Delete) */
+
+ N_("Change the visibility of the palette of widgets"), /* action 13 (Palette) */
+ N_("Change the visibility of the property editor"), /* action 14 (Editor) */
+ N_("Change the visibility of the project widget tree"), /* action 15 (Tree) */
+ N_("Change the visibility of the clipboard"), /* action 16 (Clipboard) */
- N_("About this application"), /* action 16 (About) */
+ N_("About this application"), /* action 17 (About) */
};
@@ -997,11 +1016,7 @@ glade_project_window_set_project (GladeP
}
gpw->project = project;
- if (project) {
- glade_project_window_refresh_title (gpw);
- } else {
- gtk_window_set_title (GTK_WINDOW (gpw->window), "glade3");
- }
+ glade_project_window_refresh_title (gpw);
list = gpw->views;
for (; list != NULL; list = list->next) {
@@ -1013,7 +1028,7 @@ glade_project_window_set_project (GladeP
g_signal_connect (G_OBJECT (project), "selection_changed",
G_CALLBACK (glade_project_window_selection_changed_cb),
gpw);
-
+
glade_project_selection_changed (project);
}
@@ -1111,7 +1126,12 @@ void
glade_project_window_refresh_title (GladeProjectWindow *gpw)
{
gchar *title;
- title = g_strdup_printf ("glade3 - %s", gpw->project->name);
+
+ if (!gpw->project)
+ title = g_strdup_printf ("glade3");
+ else
+ title = g_strdup_printf ("glade3 - %s", gpw->project->name);
+
gtk_window_set_title (GTK_WINDOW (gpw->window), title);
g_free (title);
}
--=-Hd1ycMZ0e1CLV6To4anU--
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]