Commit 89d54a5f3ce6fb4a23b09f2a1f1d87765796e108
1 parent
3235719c
Exists in
master
and in
3 other branches
Implementing title bar personalization.
Showing
6 changed files
with
248 additions
and
10 deletions
Show diff stats
pw3270.cbp
| ... | ... | @@ -166,6 +166,9 @@ |
| 166 | 166 | <Unit filename="src/objects/window/actions/setcolors.c"> |
| 167 | 167 | <Option compilerVar="CC" /> |
| 168 | 168 | </Unit> |
| 169 | + <Unit filename="src/objects/window/header-settings.c"> | |
| 170 | + <Option compilerVar="CC" /> | |
| 171 | + </Unit> | |
| 169 | 172 | <Unit filename="src/objects/window/header.c"> |
| 170 | 173 | <Option compilerVar="CC" /> |
| 171 | 174 | </Unit> | ... | ... |
src/include/pw3270/application.h
| ... | ... | @@ -88,6 +88,10 @@ |
| 88 | 88 | void pw3270_application_print_copy_activated(GAction *action, GVariant *parameter, GtkWidget *terminal); |
| 89 | 89 | void pw3270_application_save_copy_activated(GAction *action, GVariant *parameter, GtkWidget *terminal); |
| 90 | 90 | |
| 91 | + // Settings | |
| 92 | + GtkWidget * pw3270_header_settings_new(); | |
| 93 | + | |
| 94 | + | |
| 91 | 95 | G_END_DECLS |
| 92 | 96 | |
| 93 | 97 | ... | ... |
src/objects/application/actions/preferences.c
| ... | ... | @@ -34,9 +34,6 @@ |
| 34 | 34 | #include <pw3270/settings.h> |
| 35 | 35 | #include <pw3270/toolbar.h> |
| 36 | 36 | |
| 37 | - | |
| 38 | -// gtk_window_set_title(GTK_WINDOW(dialog),action->label); | |
| 39 | - | |
| 40 | 37 | static GtkWidget * factory(PW3270Action * action, GtkApplication *application) { |
| 41 | 38 | |
| 42 | 39 | size_t ix; |
| ... | ... | @@ -48,7 +45,8 @@ |
| 48 | 45 | gtk_window_set_transient_for(GTK_WINDOW(dialog),window); |
| 49 | 46 | |
| 50 | 47 | GtkWidget * pages[] = { |
| 51 | - pw3270_toolbar_settings_new() | |
| 48 | + pw3270_toolbar_settings_new(), | |
| 49 | + pw3270_header_settings_new() | |
| 52 | 50 | }; |
| 53 | 51 | |
| 54 | 52 | for(ix = 0; ix < G_N_ELEMENTS(pages); ix++) { | ... | ... |
src/objects/settings/dialog.c
| ... | ... | @@ -219,12 +219,7 @@ void switch_page(GtkNotebook *notebook, PW3270Settings *page, guint G_GNUC_UNUSE |
| 219 | 219 | gtk_header_bar_set_subtitle(GTK_HEADER_BAR(header_bar),page->title); |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | - } else if(page->title) { | |
| 223 | - | |
| 224 | - gtk_window_set_title(GTK_WINDOW(dialog),page->title); | |
| 225 | - | |
| 226 | 222 | } |
| 227 | 223 | |
| 228 | - | |
| 229 | 224 | } |
| 230 | 225 | ... | ... |
src/objects/window/actions/sessionproperties.c
| ... | ... | @@ -0,0 +1,239 @@ |
| 1 | +/* | |
| 2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
| 3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
| 4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | |
| 5 | + * | |
| 6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
| 7 | + * | |
| 8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
| 9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
| 10 | + * Free Software Foundation. | |
| 11 | + * | |
| 12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
| 13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
| 14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
| 15 | + * obter mais detalhes. | |
| 16 | + * | |
| 17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
| 18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
| 19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
| 20 | + * | |
| 21 | + * Este programa está nomeado como - e possui - linhas de código. | |
| 22 | + * | |
| 23 | + * Contatos: | |
| 24 | + * | |
| 25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
| 26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
| 27 | + * | |
| 28 | + */ | |
| 29 | + | |
| 30 | + #include "private.h" | |
| 31 | + #include <pw3270.h> | |
| 32 | + #include <pw3270/actions.h> | |
| 33 | + #include <pw3270/settings.h> | |
| 34 | + #include <pw3270/application.h> | |
| 35 | + #include <v3270/dialogs.h> | |
| 36 | + | |
| 37 | + static void load(GtkWidget *widget, PW3270SettingsPrivate *settings); | |
| 38 | + static void apply(GtkWidget *widget, PW3270SettingsPrivate *settings); | |
| 39 | + | |
| 40 | +/*--[ Constants ]------------------------------------------------------------------------------------*/ | |
| 41 | + | |
| 42 | + struct _PW3270SettingsPrivate { | |
| 43 | + GtkWidget * views[3]; | |
| 44 | + GtkTreeModel * model; | |
| 45 | + }; | |
| 46 | + | |
| 47 | + static const struct _views { | |
| 48 | + const char * label; | |
| 49 | + gint left; | |
| 50 | + gint top; | |
| 51 | + gint height; | |
| 52 | + } views[] = { | |
| 53 | + { | |
| 54 | + .label = N_("Left"), | |
| 55 | + .left = 0, | |
| 56 | + .top = 0, | |
| 57 | + .height = 4 | |
| 58 | + }, | |
| 59 | + { | |
| 60 | + .label = N_("Right"), | |
| 61 | + .left = 0, | |
| 62 | + .top = 6, | |
| 63 | + .height = 4 | |
| 64 | + }, | |
| 65 | + { | |
| 66 | + .label = N_("Available"), | |
| 67 | + .left = 2, | |
| 68 | + .top = 0, | |
| 69 | + .height = 10 | |
| 70 | + } | |
| 71 | + }; | |
| 72 | + | |
| 73 | + /*--[ Implement ]------------------------------------------------------------------------------------*/ | |
| 74 | + | |
| 75 | + static void selection_changed(GtkTreeSelection *selection, GtkWidget *button) { | |
| 76 | + gtk_widget_set_sensitive(button,gtk_tree_selection_count_selected_rows(selection) > 0); | |
| 77 | + } | |
| 78 | + | |
| 79 | + GtkWidget * pw3270_header_settings_new() { | |
| 80 | + | |
| 81 | + size_t ix; | |
| 82 | + | |
| 83 | + // Create page widget. | |
| 84 | + PW3270Settings * settings = pw3270_settings_new(); | |
| 85 | + settings->label = _("Title bar"); | |
| 86 | + settings->title = _("Setup title bar icons"); | |
| 87 | + settings->apply = apply; | |
| 88 | + settings->load = load; | |
| 89 | + | |
| 90 | + // Create private data. | |
| 91 | + PW3270SettingsPrivate * page = settings->settings = g_new0(PW3270SettingsPrivate,1); | |
| 92 | + | |
| 93 | + // Create dialog grid | |
| 94 | + GtkGrid * grid = GTK_GRID(gtk_grid_new()); | |
| 95 | + gtk_grid_set_row_homogeneous(grid,FALSE); | |
| 96 | + | |
| 97 | + gtk_grid_attach( | |
| 98 | + GTK_GRID(settings), | |
| 99 | + v3270_dialog_section_new(_("Itens"), _("Select the title bar itens"), GTK_WIDGET(grid)), | |
| 100 | + 0,0,4,3 | |
| 101 | + ); | |
| 102 | + | |
| 103 | + // | |
| 104 | + // Create views | |
| 105 | + // | |
| 106 | + { | |
| 107 | + GtkTreeSelection * selection; | |
| 108 | + | |
| 109 | + for(ix = 0; ix < G_N_ELEMENTS(page->views); ix++) { | |
| 110 | + | |
| 111 | + GtkWidget * label = gtk_label_new(gettext(views[ix].label)); | |
| 112 | + gtk_label_set_xalign(GTK_LABEL(label),0); | |
| 113 | + | |
| 114 | + gtk_grid_attach( | |
| 115 | + grid, | |
| 116 | + label, | |
| 117 | + views[ix].left, | |
| 118 | + views[ix].top, | |
| 119 | + 1,1 | |
| 120 | + ); | |
| 121 | + | |
| 122 | + page->views[ix] = pw3270_action_view_new(); | |
| 123 | + | |
| 124 | + selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(page->views[ix])); | |
| 125 | + gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE); | |
| 126 | + | |
| 127 | + GtkWidget * box = gtk_scrolled_window_new(NULL,NULL); | |
| 128 | + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(box),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC); | |
| 129 | + gtk_container_add(GTK_CONTAINER(box),page->views[ix]); | |
| 130 | + | |
| 131 | + gtk_grid_attach( | |
| 132 | + grid, | |
| 133 | + box, | |
| 134 | + views[ix].left, | |
| 135 | + views[ix].top+1, | |
| 136 | + 1, | |
| 137 | + views[ix].height | |
| 138 | + ); | |
| 139 | + | |
| 140 | + } | |
| 141 | + | |
| 142 | + gtk_tree_view_set_reorderable(GTK_TREE_VIEW(page->views[0]),TRUE); | |
| 143 | + gtk_tree_view_set_reorderable(GTK_TREE_VIEW(page->views[1]),TRUE); | |
| 144 | + gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(gtk_tree_view_get_model(GTK_TREE_VIEW(page->views[1]))), GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, GTK_SORT_ASCENDING); | |
| 145 | + | |
| 146 | + } | |
| 147 | + | |
| 148 | + // Create buttons | |
| 149 | + { | |
| 150 | + static const gchar * icon_names[] = { | |
| 151 | + "go-next", | |
| 152 | + "go-previous", | |
| 153 | + "go-next", | |
| 154 | + "go-previous" | |
| 155 | + }; | |
| 156 | + | |
| 157 | + GtkWidget *buttons[G_N_ELEMENTS(icon_names)]; | |
| 158 | + | |
| 159 | + for(ix = 0; ix < G_N_ELEMENTS(icon_names); ix++) { | |
| 160 | + buttons[ix] = gtk_button_new_from_icon_name(icon_names[ix],GTK_ICON_SIZE_DND); | |
| 161 | + | |
| 162 | + gtk_widget_set_focus_on_click(buttons[ix],FALSE); | |
| 163 | + gtk_button_set_relief(GTK_BUTTON(buttons[ix]),GTK_RELIEF_NONE); | |
| 164 | + gtk_widget_set_sensitive(buttons[ix],FALSE); | |
| 165 | + | |
| 166 | + } | |
| 167 | + | |
| 168 | + g_signal_connect( | |
| 169 | + gtk_tree_view_get_selection(GTK_TREE_VIEW(page->views[0])), | |
| 170 | + "changed", | |
| 171 | + G_CALLBACK(selection_changed), | |
| 172 | + buttons[0] | |
| 173 | + ); | |
| 174 | + | |
| 175 | + g_signal_connect( | |
| 176 | + gtk_tree_view_get_selection(GTK_TREE_VIEW(page->views[1])), | |
| 177 | + "changed", | |
| 178 | + G_CALLBACK(selection_changed), | |
| 179 | + buttons[2] | |
| 180 | + ); | |
| 181 | + | |
| 182 | + g_signal_connect( | |
| 183 | + gtk_tree_view_get_selection(GTK_TREE_VIEW(page->views[2])), | |
| 184 | + "changed", | |
| 185 | + G_CALLBACK(selection_changed), | |
| 186 | + buttons[1] | |
| 187 | + ); | |
| 188 | + | |
| 189 | + g_signal_connect( | |
| 190 | + gtk_tree_view_get_selection(GTK_TREE_VIEW(page->views[2])), | |
| 191 | + "changed", | |
| 192 | + G_CALLBACK(selection_changed), | |
| 193 | + buttons[3] | |
| 194 | + ); | |
| 195 | + | |
| 196 | + | |
| 197 | + for(ix = 0; ix < 2; ix++) { | |
| 198 | + GtkWidget * box = gtk_button_box_new(GTK_ORIENTATION_VERTICAL); | |
| 199 | + gtk_widget_set_hexpand(box,FALSE); | |
| 200 | + gtk_widget_set_vexpand(box,FALSE); | |
| 201 | + | |
| 202 | + gtk_box_pack_start(GTK_BOX(box),buttons[ix*2],FALSE,FALSE,0); | |
| 203 | + gtk_box_pack_end(GTK_BOX(box),buttons[(ix*2)+1],FALSE,FALSE,0); | |
| 204 | + | |
| 205 | + gtk_grid_attach( | |
| 206 | + grid, | |
| 207 | + box, | |
| 208 | + views[ix].left+1, | |
| 209 | + views[ix].top+2, | |
| 210 | + 1, | |
| 211 | + 2 | |
| 212 | + ); | |
| 213 | + | |
| 214 | + | |
| 215 | + } | |
| 216 | + | |
| 217 | + } | |
| 218 | + | |
| 219 | + | |
| 220 | + gtk_widget_show_all(GTK_WIDGET(settings)); | |
| 221 | + return GTK_WIDGET(settings); | |
| 222 | + } | |
| 223 | + | |
| 224 | + void load(GtkWidget *widget, PW3270SettingsPrivate *page) { | |
| 225 | + | |
| 226 | + // Populate views | |
| 227 | + Pw3270ActionList * action_list = pw3270_action_list_new(GTK_APPLICATION(g_application_get_default())); | |
| 228 | + | |
| 229 | + pw3270_action_view_set_actions(page->views[0], action_list); | |
| 230 | + pw3270_action_view_set_actions(page->views[1], action_list); | |
| 231 | + pw3270_action_view_set_actions(page->views[2], action_list); | |
| 232 | + | |
| 233 | + pw3270_action_list_free(action_list); | |
| 234 | + | |
| 235 | + } | |
| 236 | + | |
| 237 | + void apply(GtkWidget *widget, PW3270SettingsPrivate *settings) { | |
| 238 | + } | |
| 239 | + | ... | ... |