Commit a2973972ef7ccdab3e438350cb85507d11e8d695
1 parent
ac8313da
Exists in
master
and in
1 other branch
Implementing save dialog.
Showing
1 changed file
with
42 additions
and
13 deletions
Show diff stats
src/dialogs/save/save.c
| ... | ... | @@ -27,6 +27,7 @@ |
| 27 | 27 | * |
| 28 | 28 | */ |
| 29 | 29 | |
| 30 | + | |
| 30 | 31 | #include "private.h" |
| 31 | 32 | #include <limits.h> |
| 32 | 33 | |
| ... | ... | @@ -51,13 +52,26 @@ |
| 51 | 52 | |
| 52 | 53 | } |
| 53 | 54 | |
| 55 | + static void cancel_operation(GtkButton G_GNUC_UNUSED(*button), GtkDialog *dialog) | |
| 56 | + { | |
| 57 | + gtk_dialog_response(dialog,GTK_RESPONSE_CANCEL); | |
| 58 | + } | |
| 59 | + | |
| 60 | + static void apply_operation(GtkButton G_GNUC_UNUSED(*button), GtkDialog *dialog) | |
| 61 | + { | |
| 62 | + gtk_dialog_response(dialog,GTK_RESPONSE_APPLY); | |
| 63 | + } | |
| 64 | + | |
| 54 | 65 | static void V3270SaveDialog_init(V3270SaveDialog *dialog) |
| 55 | 66 | { |
| 56 | 67 | dialog->mode = LIB3270_CONTENT_ALL; |
| 57 | 68 | |
| 69 | + gtk_window_set_deletable(GTK_WINDOW(dialog),FALSE); | |
| 70 | + | |
| 58 | 71 | // Setup visual elements |
| 59 | 72 | // https://developer.gnome.org/hig/stable/visual-layout.html.en |
| 60 | 73 | GtkWidget *widget; |
| 74 | + GtkWidget *button; | |
| 61 | 75 | |
| 62 | 76 | GtkBox * box = GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))); |
| 63 | 77 | gtk_window_set_resizable(GTK_WINDOW(dialog),FALSE); |
| ... | ... | @@ -68,7 +82,7 @@ |
| 68 | 82 | gtk_grid_set_column_spacing(GTK_GRID(grid),12); |
| 69 | 83 | gtk_box_pack_start(box,GTK_WIDGET(grid),TRUE,TRUE,2); |
| 70 | 84 | |
| 71 | - dialog->filename = GTK_ENTRY(gtk_entry_new()); | |
| 85 | + dialog->filename = gtk_entry_new(); | |
| 72 | 86 | gtk_widget_set_hexpand(GTK_WIDGET(dialog->filename),TRUE); |
| 73 | 87 | |
| 74 | 88 | widget = gtk_label_new_with_mnemonic("_Filename:"); |
| ... | ... | @@ -82,22 +96,43 @@ |
| 82 | 96 | //g_signal_connect(G_OBJECT(widget),"clicked",G_CALLBACK(select_local_file),dialog); |
| 83 | 97 | gtk_grid_attach(grid,widget,2,0,1,1); |
| 84 | 98 | #else |
| 85 | - gtk_entry_set_icon_from_icon_name(dialog->filename,GTK_ENTRY_ICON_SECONDARY,"document-open"); | |
| 86 | - gtk_entry_set_icon_activatable(dialog->filename,GTK_ENTRY_ICON_SECONDARY,TRUE); | |
| 87 | - gtk_entry_set_icon_tooltip_text(dialog->filename,GTK_ENTRY_ICON_SECONDARY,_("Select file")); | |
| 99 | + gtk_entry_set_icon_from_icon_name(GTK_ENTRY(dialog->filename),GTK_ENTRY_ICON_SECONDARY,"document-open"); | |
| 100 | + gtk_entry_set_icon_activatable(GTK_ENTRY(dialog->filename),GTK_ENTRY_ICON_SECONDARY,TRUE); | |
| 101 | + gtk_entry_set_icon_tooltip_text(GTK_ENTRY(dialog->filename),GTK_ENTRY_ICON_SECONDARY,_("Select file")); | |
| 88 | 102 | // g_signal_connect(G_OBJECT(dialog->filename),"icon-press",G_CALLBACK(icon_press),dialog); |
| 89 | 103 | #endif // WIN32 |
| 90 | 104 | |
| 91 | - gtk_entry_set_width_chars(dialog->filename,60); | |
| 92 | - gtk_entry_set_max_length(dialog->filename,PATH_MAX); | |
| 105 | + gtk_entry_set_width_chars(GTK_ENTRY(dialog->filename),60); | |
| 106 | + gtk_entry_set_max_length(GTK_ENTRY(dialog->filename),PATH_MAX); | |
| 93 | 107 | gtk_grid_attach(grid,GTK_WIDGET(dialog->filename),1,0,1,1); |
| 94 | 108 | |
| 109 | + // Buttons | |
| 110 | + // https://developer.gnome.org/icon-naming-spec/ | |
| 111 | +#if GTK_CHECK_VERSION(3,14,0) | |
| 112 | + | |
| 113 | + widget = gtk_dialog_get_header_bar(GTK_DIALOG(dialog)); | |
| 114 | + | |
| 115 | + button = gtk_button_new_with_mnemonic(_("_Cancel")); | |
| 116 | + gtk_widget_set_tooltip_markup(button,_("Click to cancel operation")); | |
| 117 | + gtk_header_bar_pack_start(GTK_HEADER_BAR(widget),button); | |
| 118 | + g_signal_connect(G_OBJECT(button),"clicked",G_CALLBACK(cancel_operation),dialog); | |
| 119 | + | |
| 120 | + button = gtk_button_new_with_mnemonic(_("_Save")); | |
| 121 | + gtk_widget_set_tooltip_markup(button,_("Click to save file")); | |
| 122 | + gtk_header_bar_pack_end(GTK_HEADER_BAR(widget),button); | |
| 123 | + g_signal_connect(G_OBJECT(button),"clicked",G_CALLBACK(apply_operation),dialog); | |
| 124 | + | |
| 125 | +#else | |
| 126 | + | |
| 127 | + #error TODO! | |
| 128 | + | |
| 129 | +#endif // GTK(3,14,0) | |
| 95 | 130 | |
| 96 | 131 | } |
| 97 | 132 | |
| 98 | 133 | GtkWidget * v3270_save_dialog_new(GtkWidget *widget, LIB3270_CONTENT_OPTION mode, const gchar *filename) |
| 99 | 134 | { |
| 100 | - V3270SaveDialog * dialog = V3270_SAVE_DIALOG(g_object_new(GTK_TYPE_V3270SaveDialog, NULL)); | |
| 135 | + V3270SaveDialog * dialog = V3270_SAVE_DIALOG(g_object_new(GTK_TYPE_V3270SaveDialog,"use-header-bar", (gint) 1, NULL)); | |
| 101 | 136 | dialog->mode = mode; |
| 102 | 137 | |
| 103 | 138 | if(filename) |
| ... | ... | @@ -107,12 +142,6 @@ |
| 107 | 142 | gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); |
| 108 | 143 | gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE); |
| 109 | 144 | |
| 110 | - // https://developer.gnome.org/hig/stable/visual-layout.html.en | |
| 111 | - GtkGrid * grid = GTK_GRID(gtk_grid_new()); | |
| 112 | - gtk_grid_set_row_spacing(GTK_GRID(grid),6); | |
| 113 | - gtk_grid_set_column_spacing(GTK_GRID(grid),12); | |
| 114 | - | |
| 115 | - | |
| 116 | 145 | return GTK_WIDGET(dialog); |
| 117 | 146 | } |
| 118 | 147 | ... | ... |