[gedit] Add a new GeditNotebookPopupMenu class.
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] Add a new GeditNotebookPopupMenu class.
- Date: Wed, 14 Dec 2011 17:48:06 +0000 (UTC)
commit 5952572b4b18177dfad1eb0df8eac4c3b269d201
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Wed Dec 14 08:44:43 2011 +0100
Add a new GeditNotebookPopupMenu class.
This class will take care of creating the menu that is popup with right
click in a notebook tab.
gedit/Makefile.am | 2 +
gedit/gedit-commands-file.c | 38 +++---
gedit/gedit-commands.h | 8 +-
gedit/gedit-marshal.list | 1 +
gedit/gedit-multi-notebook.c | 10 +-
gedit/gedit-multi-notebook.h | 3 +-
gedit/gedit-notebook-popup-menu.c | 232 +++++++++++++++++++++++++++++++++++++
gedit/gedit-notebook-popup-menu.h | 62 ++++++++++
gedit/gedit-notebook.c | 15 ++-
gedit/gedit-notebook.h | 3 +-
gedit/gedit-ui.xml | 13 --
gedit/gedit-window.c | 10 +-
12 files changed, 346 insertions(+), 51 deletions(-)
---
diff --git a/gedit/Makefile.am b/gedit/Makefile.am
index b5d730c..ce12ac7 100644
--- a/gedit/Makefile.am
+++ b/gedit/Makefile.am
@@ -120,6 +120,7 @@ NOINST_H_FILES = \
gedit-language-manager.h \
gedit-multi-notebook.h \
gedit-notebook.h \
+ gedit-notebook-popup-menu.h \
gedit-plugins-engine.h \
gedit-print-job.h \
gedit-print-preview.h \
@@ -201,6 +202,7 @@ libgedit_c_files = \
gedit-message.c \
gedit-multi-notebook.c \
gedit-notebook.c \
+ gedit-notebook-popup-menu.c \
gedit-panel.c \
gedit-plugins-engine.c \
gedit-print-job.c \
diff --git a/gedit/gedit-commands-file.c b/gedit/gedit-commands-file.c
index f554db1..4206519 100644
--- a/gedit/gedit-commands-file.c
+++ b/gedit/gedit-commands-file.c
@@ -498,8 +498,6 @@ _gedit_cmd_file_open (GtkAction *action,
}
/* File saving */
-static void file_save_as (GeditTab *tab,
- GeditWindow *window);
static gboolean
is_read_only (GFile *location)
@@ -791,7 +789,7 @@ save_next_tab:
}
gedit_window_set_active_tab (window, tab);
- file_save_as (tab, window);
+ _gedit_cmd_file_save_as_tab (tab, window);
}
}
@@ -827,9 +825,9 @@ confirm_overwrite_callback (GtkFileChooser *dialog,
return res;
}
-static void
-file_save_as (GeditTab *tab,
- GeditWindow *window)
+void
+_gedit_cmd_file_save_as_tab (GeditTab *tab,
+ GeditWindow *window)
{
GtkWidget *save_dialog;
GtkWindowGroup *wg;
@@ -928,9 +926,9 @@ file_save_as (GeditTab *tab,
gtk_widget_show (save_dialog);
}
-static void
-file_save (GeditTab *tab,
- GeditWindow *window)
+void
+_gedit_cmd_file_save_tab (GeditTab *tab,
+ GeditWindow *window)
{
GeditDocument *doc;
gchar *uri_for_display;
@@ -948,8 +946,8 @@ file_save (GeditTab *tab,
{
gedit_debug_message (DEBUG_COMMANDS, "Untitled or Readonly");
- file_save_as (tab, window);
-
+ _gedit_cmd_file_save_as_tab (tab, window);
+
return;
}
@@ -966,7 +964,7 @@ file_save (GeditTab *tab,
void
_gedit_cmd_file_save (GtkAction *action,
- GeditWindow *window)
+ GeditWindow *window)
{
GeditTab *tab;
@@ -976,12 +974,12 @@ _gedit_cmd_file_save (GtkAction *action,
if (tab == NULL)
return;
- file_save (tab, window);
+ _gedit_cmd_file_save_tab (tab, window);
}
void
_gedit_cmd_file_save_as (GtkAction *action,
- GeditWindow *window)
+ GeditWindow *window)
{
GeditTab *tab;
@@ -991,7 +989,7 @@ _gedit_cmd_file_save_as (GtkAction *action,
if (tab == NULL)
return;
- file_save_as (tab, window);
+ _gedit_cmd_file_save_as_tab (tab, window);
}
static gboolean
@@ -1058,7 +1056,7 @@ _gedit_cmd_file_save_documents_list (GeditWindow *window,
}
else
{
- file_save (t, window);
+ _gedit_cmd_file_save_tab (t, window);
}
}
else
@@ -1113,7 +1111,7 @@ _gedit_cmd_file_save_documents_list (GeditWindow *window,
tab = GEDIT_TAB (tabs_to_save_as->data);
gedit_window_set_active_tab (window, tab);
- file_save_as (tab, window);
+ _gedit_cmd_file_save_as_tab (tab, window);
}
}
@@ -1152,7 +1150,7 @@ gedit_commands_save_document (GeditWindow *window,
gedit_debug (DEBUG_COMMANDS);
tab = gedit_tab_get_from_document (document);
- file_save (tab, window);
+ _gedit_cmd_file_save_tab (tab, window);
}
/* File revert */
@@ -1452,7 +1450,7 @@ save_and_close (GeditTab *tab,
G_CALLBACK (tab_state_changed_while_saving),
window);
- file_save (tab, window);
+ _gedit_cmd_file_save_tab (tab, window);
}
static void
@@ -1472,7 +1470,7 @@ save_as_and_close (GeditTab *tab,
window);
gedit_window_set_active_tab (window, tab);
- file_save_as (tab, window);
+ _gedit_cmd_file_save_as_tab (tab, window);
}
static void
diff --git a/gedit/gedit-commands.h b/gedit/gedit-commands.h
index 2c820d4..6cf92a7 100644
--- a/gedit/gedit-commands.h
+++ b/gedit/gedit-commands.h
@@ -73,6 +73,10 @@ void _gedit_cmd_file_new (GtkAction *action,
GeditWindow *window);
void _gedit_cmd_file_open (GtkAction *action,
GeditWindow *window);
+void _gedit_cmd_file_save_tab (GeditTab *tab,
+ GeditWindow *window);
+void _gedit_cmd_file_save_as_tab (GeditTab *tab,
+ GeditWindow *window);
void _gedit_cmd_file_save (GtkAction *action,
GeditWindow *window);
void _gedit_cmd_file_save_as (GtkAction *action,
@@ -137,8 +141,8 @@ void _gedit_cmd_search_clear_highlight (GtkAction *action,
void _gedit_cmd_search_goto_line (GtkAction *action,
GeditWindow *window);
void _gedit_cmd_search_incremental_search (GtkAction *action,
- GeditWindow *window);
-
+ GeditWindow *window);
+
void _gedit_cmd_documents_previous_document (GtkAction *action,
GeditWindow *window);
void _gedit_cmd_documents_next_document (GtkAction *action,
diff --git a/gedit/gedit-marshal.list b/gedit/gedit-marshal.list
index 8ed0c94..d646838 100644
--- a/gedit/gedit-marshal.list
+++ b/gedit/gedit-marshal.list
@@ -3,6 +3,7 @@ BOOLEAN:OBJECT
VOID:BOOLEAN
VOID:BOOLEAN,POINTER
VOID:BOXED,BOXED
+VOID:BOXED,OBJECT
VOID:OBJECT
VOID:OBJECT,OBJECT
VOID:OBJECT,OBJECT,OBJECT,OBJECT
diff --git a/gedit/gedit-multi-notebook.c b/gedit/gedit-multi-notebook.c
index 63c0c6c..af18848 100644
--- a/gedit/gedit-multi-notebook.c
+++ b/gedit/gedit-multi-notebook.c
@@ -205,10 +205,11 @@ gedit_multi_notebook_class_init (GeditMultiNotebookClass *klass)
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GeditMultiNotebookClass, show_popup_menu),
NULL, NULL,
- g_cclosure_marshal_VOID__BOXED,
+ gedit_marshal_VOID__BOXED_OBJECT,
G_TYPE_NONE,
- 1,
- GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+ 2,
+ GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE,
+ GEDIT_TYPE_TAB);
g_object_class_install_property (object_class,
PROP_ACTIVE_NOTEBOOK,
@@ -231,9 +232,10 @@ gedit_multi_notebook_class_init (GeditMultiNotebookClass *klass)
static void
notebook_show_popup_menu (GtkNotebook *notebook,
GdkEvent *event,
+ GeditTab *tab,
GeditMultiNotebook *mnb)
{
- g_signal_emit (G_OBJECT (mnb), signals[SHOW_POPUP_MENU], 0, event);
+ g_signal_emit (G_OBJECT (mnb), signals[SHOW_POPUP_MENU], 0, event, tab);
}
static void
diff --git a/gedit/gedit-multi-notebook.h b/gedit/gedit-multi-notebook.h
index 255ff4a..d954aad 100644
--- a/gedit/gedit-multi-notebook.h
+++ b/gedit/gedit-multi-notebook.h
@@ -80,7 +80,8 @@ struct _GeditMultiNotebookClass
gint y);
void (* page_reordered) (GeditMultiNotebook *mnb);
void (* show_popup_menu) (GeditMultiNotebook *mnb,
- GdkEvent *event);
+ GdkEvent *event,
+ GeditTab *tab);
};
GType gedit_multi_notebook_get_type (void) G_GNUC_CONST;
diff --git a/gedit/gedit-notebook-popup-menu.c b/gedit/gedit-notebook-popup-menu.c
new file mode 100644
index 0000000..fd6356e
--- /dev/null
+++ b/gedit/gedit-notebook-popup-menu.c
@@ -0,0 +1,232 @@
+/*
+ * gedit-notebook-popup-menu.c
+ * This file is part of gedit
+ *
+ * Copyright (C) 2011 - Ignacio Casal Quinteiro
+ *
+ * gedit is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * gedit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with gedit. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "gedit-notebook-popup-menu.h"
+#include "gedit-commands.h"
+#include <glib/gi18n.h>
+
+struct _GeditNotebookPopupMenuPrivate
+{
+ GeditWindow *window;
+ GeditTab *tab;
+};
+
+enum
+{
+ PROP_0,
+ PROP_WINDOW,
+ PROP_TAB
+};
+
+G_DEFINE_TYPE (GeditNotebookPopupMenu, gedit_notebook_popup_menu, GTK_TYPE_MENU)
+
+static void
+gedit_notebook_popup_menu_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GeditNotebookPopupMenu *menu = GEDIT_NOTEBOOK_POPUP_MENU (object);
+
+ switch (prop_id)
+ {
+ case PROP_WINDOW:
+ menu->priv->window = GEDIT_WINDOW (g_value_get_object (value));
+ break;
+
+ case PROP_TAB:
+ menu->priv->tab = GEDIT_TAB (g_value_get_object (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gedit_notebook_popup_menu_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GeditNotebookPopupMenu *menu = GEDIT_NOTEBOOK_POPUP_MENU (object);
+
+ switch (prop_id)
+ {
+ case PROP_WINDOW:
+ g_value_set_object (value, menu->priv->window);
+ break;
+
+ case PROP_TAB:
+ g_value_set_object (value, menu->priv->tab);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gedit_notebook_popup_menu_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (gedit_notebook_popup_menu_parent_class)->finalize (object);
+}
+
+static void
+gedit_notebook_popup_menu_class_init (GeditNotebookPopupMenuClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->get_property = gedit_notebook_popup_menu_get_property;
+ object_class->set_property = gedit_notebook_popup_menu_set_property;
+ object_class->finalize = gedit_notebook_popup_menu_finalize;
+
+ g_object_class_install_property (object_class,
+ PROP_WINDOW,
+ g_param_spec_object ("window",
+ "Window",
+ "The GeditWindow",
+ GEDIT_TYPE_WINDOW,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property (object_class,
+ PROP_TAB,
+ g_param_spec_object ("tab",
+ "Tab",
+ "The GeditTab",
+ GEDIT_TYPE_TAB,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+
+ g_type_class_add_private (object_class, sizeof (GeditNotebookPopupMenuPrivate));
+}
+
+static void
+on_move_to_new_window_menuitem_activate (GtkMenuItem *menuitem,
+ GeditNotebookPopupMenu *menu)
+{
+ _gedit_window_move_tab_to_new_window (menu->priv->window,
+ menu->priv->tab);
+}
+
+static void
+on_file_save_menuitem_activate (GtkMenuItem *menuitem,
+ GeditNotebookPopupMenu *menu)
+{
+ _gedit_cmd_file_save (menu->priv->tab, menu->priv->window);
+}
+
+static void
+on_file_save_as_menuitem_activate (GtkMenuItem *menuitem,
+ GeditNotebookPopupMenu *menu)
+{
+ _gedit_cmd_file_save_as (menu->priv->tab, menu->priv->window);
+}
+
+static void
+on_file_print_menuitem_activate (GtkMenuItem *menuitem,
+ GeditNotebookPopupMenu *menu)
+{
+ _gedit_tab_print (menu->priv->tab);
+}
+
+static void
+on_file_close_menuitem_activate (GtkMenuItem *menuitem,
+ GeditNotebookPopupMenu *menu)
+{
+ _gedit_cmd_file_close_tab (menu->priv->tab, menu->priv->window);
+}
+
+static void
+gedit_notebook_popup_menu_init (GeditNotebookPopupMenu *menu)
+{
+ GtkWidget *menu_item;
+ GtkWidget *image;
+
+ menu->priv = G_TYPE_INSTANCE_GET_PRIVATE (menu,
+ GEDIT_TYPE_NOTEBOOK_POPUP_MENU,
+ GeditNotebookPopupMenuPrivate);
+
+ /* Keep in sync with the respective GtkActions */
+ menu_item = gtk_menu_item_new_with_mnemonic (_("_Move to New Window"));
+ g_signal_connect (menu_item, "activate",
+ G_CALLBACK (on_move_to_new_window_menuitem_activate),
+ menu);
+ gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menu_item);
+ gtk_widget_show (menu_item);
+
+ menu_item = gtk_separator_menu_item_new ();
+ gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menu_item);
+ gtk_widget_show (menu_item);
+
+ menu_item = gtk_image_menu_item_new_from_stock (GTK_STOCK_SAVE, NULL);
+ g_signal_connect (menu_item, "activate",
+ G_CALLBACK (on_file_save_menuitem_activate),
+ menu);
+ gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menu_item);
+ gtk_widget_show (menu_item);
+
+ menu_item = gtk_image_menu_item_new_with_mnemonic (_("Save _As..."));
+ image = gtk_image_new_from_stock (GTK_STOCK_SAVE_AS, GTK_ICON_SIZE_MENU);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), image);
+ g_signal_connect (menu_item, "activate",
+ G_CALLBACK (on_file_save_as_menuitem_activate),
+ menu);
+ gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menu_item);
+ gtk_widget_show (menu_item);
+
+ menu_item = gtk_separator_menu_item_new ();
+ gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menu_item);
+ gtk_widget_show (menu_item);
+
+ menu_item = gtk_image_menu_item_new_with_mnemonic (_("_Print..."));
+ image = gtk_image_new_from_stock (GTK_STOCK_PRINT, GTK_ICON_SIZE_MENU);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), image);
+ g_signal_connect (menu_item, "activate",
+ G_CALLBACK (on_file_print_menuitem_activate),
+ menu);
+ gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menu_item);
+ gtk_widget_show (menu_item);
+
+ menu_item = gtk_separator_menu_item_new ();
+ gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menu_item);
+ gtk_widget_show (menu_item);
+
+ menu_item = gtk_image_menu_item_new_from_stock (GTK_STOCK_CLOSE, NULL);
+ g_signal_connect (menu_item, "activate",
+ G_CALLBACK (on_file_close_menuitem_activate),
+ menu);
+ gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menu_item);
+ gtk_widget_show (menu_item);
+}
+
+GtkWidget *
+gedit_notebook_popup_menu_new (GeditWindow *window,
+ GeditTab *tab)
+{
+ return g_object_new (GEDIT_TYPE_NOTEBOOK_POPUP_MENU,
+ "window", window,
+ "tab", tab,
+ NULL);
+}
diff --git a/gedit/gedit-notebook-popup-menu.h b/gedit/gedit-notebook-popup-menu.h
new file mode 100644
index 0000000..0e46f99
--- /dev/null
+++ b/gedit/gedit-notebook-popup-menu.h
@@ -0,0 +1,62 @@
+/*
+ * gedit-notebook-popup-menu.h
+ * This file is part of gedit
+ *
+ * Copyright (C) 2011 - Ignacio Casal Quinteiro
+ *
+ * gedit is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * gedit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with gedit. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef __GEDIT_NOTEBOOK_POPUP_MENU_H__
+#define __GEDIT_NOTEBOOK_POPUP_MENU_H__
+
+#include <gtk/gtk.h>
+#include "gedit-window.h"
+#include "gedit-tab.h"
+
+G_BEGIN_DECLS
+
+#define GEDIT_TYPE_NOTEBOOK_POPUP_MENU (gedit_notebook_popup_menu_get_type ())
+#define GEDIT_NOTEBOOK_POPUP_MENU(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_NOTEBOOK_POPUP_MENU, GeditNotebookPopupMenu))
+#define GEDIT_NOTEBOOK_POPUP_MENU_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_NOTEBOOK_POPUP_MENU, GeditNotebookPopupMenu const))
+#define GEDIT_NOTEBOOK_POPUP_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEDIT_TYPE_NOTEBOOK_POPUP_MENU, GeditNotebookPopupMenuClass))
+#define GEDIT_IS_NOTEBOOK_POPUP_MENU(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEDIT_TYPE_NOTEBOOK_POPUP_MENU))
+#define GEDIT_IS_NOTEBOOK_POPUP_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_NOTEBOOK_POPUP_MENU))
+#define GEDIT_NOTEBOOK_POPUP_MENU_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEDIT_TYPE_NOTEBOOK_POPUP_MENU, GeditNotebookPopupMenuClass))
+
+typedef struct _GeditNotebookPopupMenu GeditNotebookPopupMenu;
+typedef struct _GeditNotebookPopupMenuClass GeditNotebookPopupMenuClass;
+typedef struct _GeditNotebookPopupMenuPrivate GeditNotebookPopupMenuPrivate;
+
+struct _GeditNotebookPopupMenu
+{
+ GtkMenu parent;
+
+ GeditNotebookPopupMenuPrivate *priv;
+};
+
+struct _GeditNotebookPopupMenuClass
+{
+ GtkMenuClass parent_class;
+};
+
+GType gedit_notebook_popup_menu_get_type (void) G_GNUC_CONST;
+
+GtkWidget *gedit_notebook_popup_menu_new (GeditWindow *window,
+ GeditTab *tab);
+
+G_END_DECLS
+
+#endif /* __GEDIT_NOTEBOOK_POPUP_MENU_H__ */
diff --git a/gedit/gedit-notebook.c b/gedit/gedit-notebook.c
index 031627a..ec924b2 100644
--- a/gedit/gedit-notebook.c
+++ b/gedit/gedit-notebook.c
@@ -49,6 +49,7 @@
#include "gedit-window.h"
#include "gedit-enum-types.h"
#include "gedit-settings.h"
+#include "gedit-marshal.h"
#define GEDIT_NOTEBOOK_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), GEDIT_TYPE_NOTEBOOK, GeditNotebookPrivate))
@@ -266,10 +267,11 @@ gedit_notebook_button_press (GtkWidget *widget,
tab_clicked = find_tab_num_at_pos (nb, event->x_root, event->y_root);
if (tab_clicked >= 0)
{
- /* switch to the page the mouse is over */
- gtk_notebook_set_current_page (nb, tab_clicked);
+ GtkWidget *tab;
- g_signal_emit (G_OBJECT (widget), signals[SHOW_POPUP_MENU], 0, event);
+ tab = gtk_notebook_get_nth_page (nb, tab_clicked);
+
+ g_signal_emit (G_OBJECT (widget), signals[SHOW_POPUP_MENU], 0, event, tab);
return TRUE;
}
@@ -535,10 +537,11 @@ gedit_notebook_class_init (GeditNotebookClass *klass)
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GeditNotebookClass, show_popup_menu),
NULL, NULL,
- g_cclosure_marshal_VOID__BOXED,
+ gedit_marshal_VOID__BOXED_OBJECT,
G_TYPE_NONE,
- 1,
- GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+ 2,
+ GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE,
+ GEDIT_TYPE_TAB);
g_type_class_add_private (object_class, sizeof (GeditNotebookPrivate));
}
diff --git a/gedit/gedit-notebook.h b/gedit/gedit-notebook.h
index 9be2e4f..e2765e7 100644
--- a/gedit/gedit-notebook.h
+++ b/gedit/gedit-notebook.h
@@ -90,7 +90,8 @@ struct _GeditNotebookClass
void (* tab_close_request) (GeditNotebook *notebook,
GeditTab *tab);
void (* show_popup_menu) (GeditNotebook *notebook,
- GdkEvent *event);
+ GdkEvent *event,
+ GeditTab *tab);
};
/*
diff --git a/gedit/gedit-ui.xml b/gedit/gedit-ui.xml
index e8ff81c..2569172 100644
--- a/gedit/gedit-ui.xml
+++ b/gedit/gedit-ui.xml
@@ -191,17 +191,4 @@
<toolitem action="LeaveFullscreen"/>
</toolbar>
- <popup name="NotebookPopup" action="NotebookPopupAction">
- <menuitem action="DocumentsMoveToNewWindow"/>
- <separator/>
- <menuitem action="FileSave"/>
- <menuitem action="FileSaveAs"/>
- <separator/>
- <menuitem action="FilePrint"/>
- <separator/>
- <placeholder name="NotebookPupupOps_1"/>
- <separator/>
- <menuitem name="FileCloseMenu" action="FileClose"/>
- </popup>
-
</ui>
diff --git a/gedit/gedit-window.c b/gedit/gedit-window.c
index 53c70b6..23def6b 100644
--- a/gedit/gedit-window.c
+++ b/gedit/gedit-window.c
@@ -45,6 +45,7 @@
#include "gedit-window-private.h"
#include "gedit-app.h"
#include "gedit-notebook.h"
+#include "gedit-notebook-popup-menu.h"
#include "gedit-multi-notebook.h"
#include "gedit-statusbar.h"
#include "gedit-utils.h"
@@ -3782,16 +3783,17 @@ on_tab_close_request (GeditMultiNotebook *multi,
static void
on_show_popup_menu (GeditMultiNotebook *multi,
- GdkEventButton *event,
- GeditWindow *window)
+ GdkEventButton *event,
+ GeditTab *tab,
+ GeditWindow *window)
{
GtkWidget *menu;
if (event == NULL)
return;
- menu = gtk_ui_manager_get_widget (window->priv->manager, "/NotebookPopup");
- g_return_if_fail (menu != NULL);
+ menu = gedit_notebook_popup_menu_new (window, tab);
+ gtk_widget_show (menu);
gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
NULL, NULL,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]