1 // GTK_P2DVIEW_WND.CPP
2
3 // Copyright (C) 2005 Tommi Hassinen.
4
5 // This package is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9
10 // This package is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14
15 // You should have received a copy of the GNU General Public License
16 // along with this package; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19 /*################################################################################################*/
20
21 #include "gtk_p2dview_wnd.h"
22
23 #include "p2dview_wcl.h"
24 #include "gtk_app.h"
25
26 #include "local_i18n.h"
27
28 /*################################################################################################*/
29
30 GtkActionEntry gtk_p2dview_wnd::entries[] =
31 {
32 { "AttachDetachPlot2D", NULL, N_("Attach/Detach This View"), NULL, N_("Select whether this view is attached or in an independent window"), (GCallback) gtk_p2dview_wnd::popup_AttachDetach },
33 { "DeleteViewPlot2D", NULL, N_("Delete View"), NULL, N_("Delete this view"), (GCallback) gtk_p2dview_wnd::popup_DeleteView }
34 };
35
36 const char * gtk_p2dview_wnd::ui_description =
37 "<ui>"
38 " <popup name='gp2dvMenu'>"
39 " <menuitem action='AttachDetachPlot2D'/>"
40 " <separator/>"
41 " <menuitem action='DeleteViewPlot2D'/>"
42 " </popup>"
43 "</ui>";
44
gtk_p2dview_wnd(bool det_flag)45 gtk_p2dview_wnd::gtk_p2dview_wnd(bool det_flag) :
46 gtk_wnd(det_flag)
47 {
48 GtkActionGroup * action_group = gtk_action_group_new("gp2dvActions");
49 gtk_action_group_set_translation_domain(action_group, GETTEXT_PACKAGE);
50 gtk_action_group_add_actions(action_group, entries, G_N_ELEMENTS(entries), GTK_WIDGET(view_widget));
51
52 gtk_ui_manager_insert_action_group(gtk_app::GetUIManager(), action_group, 0);
53
54 GError * error = NULL;
55 if (!gtk_ui_manager_add_ui_from_string(gtk_app::GetUIManager(), ui_description, -1, & error))
56 {
57 g_message(_("ERROR : Building popup-menu for gtk_p2dview_wnd failed : %s"), error->message);
58 g_error_free(error); exit(EXIT_FAILURE);
59 }
60
61 // set gtk_view::popupmenu so that gtk_ogl_view::ButtonHandler() will display it...
62 // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
63
64 popupmenu = gtk_ui_manager_get_widget(gtk_app::GetUIManager(), "/gp2dvMenu");
65 }
66
~gtk_p2dview_wnd(void)67 gtk_p2dview_wnd::~gtk_p2dview_wnd(void)
68 {
69 }
70
71 // here are the popup menu callbacks:
72 // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
73
popup_AttachDetach(GtkWidget *,gpointer data)74 void gtk_p2dview_wnd::popup_AttachDetach(GtkWidget *, gpointer data)
75 {
76 gtk_wnd * wnd = iv_Find((GtkWidget *) data);
77 p2dview_wcl * wcl = dynamic_cast<p2dview_wcl *>(wnd->GetClient());
78
79 gtk_app::GetAppX()->AttachDetachView(wcl);
80 }
81
popup_DeleteView(GtkWidget *,gpointer data)82 void gtk_p2dview_wnd::popup_DeleteView(GtkWidget *, gpointer data)
83 {
84 gtk_wnd * wnd = iv_Find((GtkWidget *) data);
85 p2dview_wcl * wcl = dynamic_cast<p2dview_wcl *>(wnd->GetClient());
86
87 gtk_app::GetPrjX()->RemovePlottingClient(wcl);
88 }
89
90 /*################################################################################################*/
91
92 // eof
93