Commit 29ee8ed4616306a434cb902fe4c3e2ba5f257b74

Authored by Perry Werneck
1 parent 1615ec90

Adding plugin methods for application & session preference dialogs.

src/include/pw3270/application.h
... ... @@ -73,6 +73,10 @@
73 73  
74 74 // Plugins
75 75 void pw3270_application_plugin_foreach(GApplication *app, GFunc func, gpointer user_data);
  76 +
  77 + /// @brief Call plugin method.
  78 + void pw3270_application_plugin_call(GApplication *app, const gchar *method, gpointer user_data);
  79 +
76 80 GSList * pw3270_application_get_plugins(GApplication *app);
77 81  
78 82 // Tools
... ...
src/objects/application/actions/about.c
... ... @@ -33,22 +33,6 @@
33 33  
34 34 static GtkWidget * factory(PW3270Action G_GNUC_UNUSED(*action), GtkApplication G_GNUC_UNUSED(*application)) {
35 35  
36   - /*
37   - static const gchar *license =
38   - N_( "This program is free software; you can redistribute it and/or "
39   - "modify it under the terms of the GNU General Public License as "
40   - "published by the Free Software Foundation; either version 2 of the "
41   - "License, or (at your option) any later version.\n\n"
42   - "This program is distributed in the hope that it will be useful, "
43   - "but WITHOUT ANY WARRANTY; without even the implied warranty of "
44   - "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "
45   - "GNU General Public License for more details.\n\n"
46   - "You should have received a copy of the GNU General Public License "
47   - "along with this program; if not, write to the Free Software "
48   - "Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 "
49   - "USA" );
50   - */
51   -
52 36 GtkAboutDialog * dialog = GTK_ABOUT_DIALOG(gtk_about_dialog_new());
53 37  
54 38 // Get application logo
... ... @@ -126,7 +110,6 @@
126 110 gtk_about_dialog_add_credit_section(dialog, _("Apple version"), apple);
127 111 gtk_about_dialog_add_credit_section (dialog, _("Contributors"), contributors);
128 112  
129   -
130 113 gtk_about_dialog_add_credit_section(dialog, _("Based on X3270 from"), references);
131 114  
132 115 }
... ... @@ -141,7 +124,6 @@
141 124 gtk_about_dialog_set_website(dialog,"https://portal.softwarepublico.gov.br/social/pw3270/");
142 125 gtk_about_dialog_set_website_label(dialog,_( "Brazilian Public Software Portal" ));
143 126  
144   -// gtk_about_dialog_set_authors(dialog,authors);
145 127 gtk_about_dialog_set_translator_credits(dialog,_("translator-credits"));
146 128  
147 129 gtk_window_set_modal(GTK_WINDOW(dialog),TRUE);
... ... @@ -149,6 +131,13 @@
149 131 g_signal_connect(dialog,"response",G_CALLBACK(gtk_widget_destroy),NULL);
150 132 gtk_widget_show_all(GTK_WIDGET(dialog));
151 133  
  134 + // Call plugins
  135 + pw3270_application_plugin_call(
  136 + g_application_get_default(),
  137 + "pw3270_plugin_set_about_dialog",
  138 + dialog
  139 + );
  140 +
152 141 return GTK_WIDGET(dialog);
153 142  
154 143 }
... ...
src/objects/application/actions/preferences.c
... ... @@ -55,6 +55,12 @@
55 55 gtk_container_add(GTK_CONTAINER(dialog),pages[ix]);
56 56 }
57 57  
  58 + pw3270_application_plugin_call(
  59 + G_APPLICATION(application),
  60 + "pw3270_plugin_set_application_preferences",
  61 + dialog
  62 + );
  63 +
58 64 gtk_widget_show_all(dialog);
59 65  
60 66 return dialog;
... ...
src/objects/application/actions/window.c
... ... @@ -69,7 +69,7 @@
69 69 return G_ACTION(action);
70 70 }
71 71  
72   - static void new_tab_activated(GAction *action, GVariant *parameter, GtkApplication *application) {
  72 + static void new_tab_activated(GAction G_GNUC_UNUSED(*action), GVariant G_GNUC_UNUSED(*parameter), GtkApplication *application) {
73 73  
74 74 debug("%s",__FUNCTION__);
75 75 pw3270_application_window_new_tab(GTK_WIDGET(gtk_application_get_active_window(GTK_APPLICATION(application))), NULL);
... ...
src/objects/application/application.c
... ... @@ -466,6 +466,33 @@
466 466  
467 467 }
468 468  
  469 + void pw3270_application_plugin_foreach(GApplication *app, GFunc func, gpointer user_data) {
  470 +
  471 + g_return_if_fail(PW3270_IS_APPLICATION(app));
  472 +
  473 + GSList * item;
  474 + for(item = PW3270_APPLICATION(app)->plugins; item; item = g_slist_next(item)) {
  475 + func(item->data,user_data);
  476 + }
  477 +
  478 + }
  479 +
  480 + void pw3270_application_plugin_call(GApplication *app, const gchar *method, gpointer user_data) {
  481 +
  482 + g_return_if_fail(PW3270_IS_APPLICATION(app));
  483 +
  484 + int (*call)(GtkWidget *);
  485 +
  486 + GSList * item;
  487 + for(item = PW3270_APPLICATION(app)->plugins; item; item = g_slist_next(item)) {
  488 + if(g_module_symbol((GModule *) item->data, method, (gpointer *) &call)) {
  489 + call(user_data);
  490 + }
  491 + }
  492 +
  493 + }
  494 +
  495 +
469 496 GSettings * pw3270_application_settings_new() {
470 497  
471 498 GSettings *settings = NULL;
... ... @@ -510,3 +537,4 @@
510 537 g_return_val_if_fail(PW3270_IS_APPLICATION(app),NULL);
511 538 return PW3270_APPLICATION(app)->keypads;
512 539 }
  540 +
... ...
src/objects/settings/dialog.c
... ... @@ -71,11 +71,6 @@ static void PW3270SettingsDialog_init(PW3270SettingsDialog *dialog)
71 71 // Get use of header bar.
72 72 g_object_get(gtk_settings_get_default(), "gtk-dialogs-use-header", &dialog->has_subtitle, NULL);
73 73  
74   - // https://developer.gnome.org/hig/stable/visual-layout.html.en
75   - //gtk_box_set_spacing(GTK_BOX(content_area),18);
76   - //gtk_container_set_border_width(GTK_CONTAINER(content_area),18);
77   -
78   -// gtk_window_set_deletable(GTK_WINDOW(dialog),FALSE);
79 74 gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
80 75  
81 76 gtk_dialog_add_buttons(
... ...
src/objects/window/actions/sessionproperties.c
... ... @@ -33,6 +33,7 @@
33 33 #include <v3270/settings.h>
34 34 #include <v3270/dialogs.h>
35 35 #include <v3270/colorscheme.h>
  36 + #include <pw3270/application.h>
36 37  
37 38 static GtkWidget * factory(V3270SimpleAction *action, GtkWidget *terminal);
38 39  
... ... @@ -68,6 +69,12 @@
68 69 gtk_container_add(GTK_CONTAINER(dialog), elements[ix]);
69 70 }
70 71  
  72 + pw3270_application_plugin_call(
  73 + g_application_get_default(),
  74 + "pw3270_plugin_set_session_properties",
  75 + dialog
  76 + );
  77 +
71 78 // Setup dialog box
72 79 gtk_window_set_transient_for(GTK_WINDOW(dialog),GTK_WINDOW(gtk_widget_get_toplevel(terminal)));
73 80 gtk_window_set_modal(GTK_WINDOW(dialog),TRUE);
... ...