From 0c6eb7a40110b1933777686c67e8e36db3286e32 Mon Sep 17 00:00:00 2001 From: rbuj Date: Sat, 1 Feb 2020 18:58:35 +0100 Subject: Add dlg-add-files.ui and dlg-add-folder.ui --- src/dlg-add-files.c | 59 ++------ src/dlg-add-folder.c | 180 ++++------------------ src/engrampa.gresource.xml | 2 + src/ui/Makefile.am | 2 + src/ui/dlg-add-files.ui | 134 +++++++++++++++++ src/ui/dlg-add-folder.ui | 365 +++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 549 insertions(+), 193 deletions(-) create mode 100644 src/ui/dlg-add-files.ui create mode 100644 src/ui/dlg-add-folder.ui (limited to 'src') diff --git a/src/dlg-add-files.c b/src/dlg-add-files.c index add0a71..bdce319 100644 --- a/src/dlg-add-files.c +++ b/src/dlg-add-files.c @@ -26,7 +26,6 @@ #include #include #include "file-utils.h" -#include "fr-stock.h" #include "fr-window.h" #include "gtk-utils.h" #include "preferences.h" @@ -137,62 +136,36 @@ void add_files_cb (GtkWidget *widget, void *callback_data) { - GtkWidget *file_sel; + GtkBuilder *builder; DialogData *data; - GtkWidget *main_box; char *folder; + builder = _gtk_builder_new_from_resource ("dlg-add-files.ui"); + if (builder == NULL) + return; + data = g_new0 (DialogData, 1); data->window = callback_data; data->settings = g_settings_new (ENGRAMPA_SCHEMA_ADD); - data->dialog = file_sel = - gtk_file_chooser_dialog_new (_("Add Files"), - GTK_WINDOW (data->window), - GTK_FILE_CHOOSER_ACTION_OPEN, - "gtk-cancel", GTK_RESPONSE_CANCEL, - FR_STOCK_ADD_FILES, GTK_RESPONSE_OK, - "gtk-help", GTK_RESPONSE_HELP, - NULL); - - gtk_window_set_default_size (GTK_WINDOW (data->dialog), 530, 450); - - gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (file_sel), TRUE); - gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (file_sel), FALSE); - gtk_dialog_set_default_response (GTK_DIALOG (file_sel), GTK_RESPONSE_OK); - - /* Translators: add a file to the archive only if the disk version is - * newer than the archive version. */ - data->add_if_newer_checkbutton = gtk_check_button_new_with_mnemonic (_("Add only if _newer")); - - main_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 20); - gtk_container_set_border_width (GTK_CONTAINER (main_box), 0); - gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (file_sel), main_box); - - gtk_box_pack_start (GTK_BOX (main_box), data->add_if_newer_checkbutton, - TRUE, TRUE, 0); - - gtk_widget_show_all (main_box); + data->dialog = _gtk_builder_get_widget (builder, "dialog_add_files"); + data->add_if_newer_checkbutton = _gtk_builder_get_widget (builder, "add_if_newer_checkbutton"); /* set data */ - folder = g_settings_get_string (data->settings, PREF_ADD_CURRENT_FOLDER); if ((folder == NULL) || (strcmp (folder, "") == 0)) folder = g_strdup (fr_window_get_add_default_dir (data->window)); - gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (file_sel), folder); + gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (GTK_WIDGET (data->dialog)), folder); g_free (folder); /* signals */ + gtk_builder_add_callback_symbols (builder, + "on_dlg_add_files_destroy", G_CALLBACK (open_file_destroy_cb), + "on_dlg_add_files_response", G_CALLBACK (file_sel_response_cb), + NULL); + gtk_builder_connect_signals (builder, data); - g_signal_connect (G_OBJECT (file_sel), - "destroy", - G_CALLBACK (open_file_destroy_cb), - data); - - g_signal_connect (G_OBJECT (file_sel), - "response", - G_CALLBACK (file_sel_response_cb), - data); + g_object_unref (builder); - gtk_window_set_modal (GTK_WINDOW (file_sel), TRUE); - gtk_widget_show (file_sel); + gtk_window_set_modal (GTK_WINDOW (data->dialog), TRUE); + gtk_widget_show (data->dialog); } diff --git a/src/dlg-add-folder.c b/src/dlg-add-folder.c index a52bf75..56d619a 100644 --- a/src/dlg-add-folder.c +++ b/src/dlg-add-folder.c @@ -29,7 +29,6 @@ #include #include "dlg-add-folder.h" #include "file-utils.h" -#include "fr-stock.h" #include "fr-window.h" #include "gtk-utils.h" #include "preferences.h" @@ -45,18 +44,11 @@ typedef struct { GSettings *settings; GtkWidget *dialog; GtkWidget *include_subfold_checkbutton; - GtkWidget *add_if_newer_checkbutton; GtkWidget *exclude_symlinks; - GtkWidget *include_files_checkbutton; + GtkWidget *add_if_newer_checkbutton; GtkWidget *include_files_entry; - GtkWidget *include_files_label; GtkWidget *exclude_files_entry; - GtkWidget *exclude_files_label; GtkWidget *exclude_folders_entry; - GtkWidget *exclude_folders_label; - GtkWidget *load_button; - GtkWidget *save_button; - GtkWidget *clear_button; char *last_options; } DialogData; @@ -192,7 +184,7 @@ include_subfold_toggled_cb (GtkWidget *widget, DialogData *data = callback_data; gtk_widget_set_sensitive (data->exclude_symlinks, - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))); + gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))); return FALSE; } @@ -209,155 +201,43 @@ void add_folder_cb (GtkWidget *widget, void *callback_data) { - GtkWidget *file_sel; + GtkBuilder *builder; DialogData *data; - GtkWidget *main_box; - GtkWidget *vbox; - GtkWidget *grid; + + builder = _gtk_builder_new_from_resource ("dlg-add-folder.ui"); + if (builder == NULL) { + return; + } data = g_new0 (DialogData, 1); - data->settings = g_settings_new (ENGRAMPA_SCHEMA_ADD); data->window = callback_data; - - data->dialog = file_sel = - gtk_file_chooser_dialog_new (_("Add a Folder"), - GTK_WINDOW (data->window), - GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, - "gtk-cancel", GTK_RESPONSE_CANCEL, - FR_STOCK_ADD_FOLDER, GTK_RESPONSE_OK, - "gtk-help", GTK_RESPONSE_HELP, - NULL); - - gtk_window_set_default_size (GTK_WINDOW (data->dialog), 530, 510); - - gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (file_sel), FALSE); - gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (file_sel), FALSE); - gtk_dialog_set_default_response (GTK_DIALOG (file_sel), GTK_RESPONSE_OK); - - data->add_if_newer_checkbutton = gtk_check_button_new_with_mnemonic (_("Add only if _newer")); - data->include_subfold_checkbutton = gtk_check_button_new_with_mnemonic (_("_Include subfolders")); - data->exclude_symlinks = gtk_check_button_new_with_mnemonic (_("Exclude folders that are symbolic lin_ks")); - gtk_widget_set_halign (data->exclude_symlinks, GTK_ALIGN_START); - gtk_widget_set_valign (data->exclude_symlinks, GTK_ALIGN_START); - gtk_widget_set_margin_start (data->exclude_symlinks, 12); - - data->include_files_entry = gtk_entry_new (); - gtk_widget_set_tooltip_text (data->include_files_entry, _("example: *.o; *.bak")); - data->include_files_label = gtk_label_new_with_mnemonic (_("Include _files:")); - gtk_label_set_xalign (GTK_LABEL (data->include_files_label), 0.0); - gtk_label_set_mnemonic_widget (GTK_LABEL (data->include_files_label), data->include_files_entry); - - data->exclude_files_entry = gtk_entry_new (); - gtk_widget_set_tooltip_text (data->exclude_files_entry, _("example: *.o; *.bak")); - data->exclude_files_label = gtk_label_new_with_mnemonic (_("E_xclude files:")); - gtk_label_set_xalign (GTK_LABEL (data->exclude_files_label), 0.0); - gtk_label_set_mnemonic_widget (GTK_LABEL (data->exclude_files_label), data->exclude_files_entry); - - data->exclude_folders_entry = gtk_entry_new (); - gtk_widget_set_tooltip_text (data->exclude_folders_entry, _("example: *.o; *.bak")); - data->exclude_folders_label = gtk_label_new_with_mnemonic (_("_Exclude folders:")); - gtk_label_set_xalign (GTK_LABEL (data->exclude_folders_label), 0.0); - gtk_label_set_mnemonic_widget (GTK_LABEL (data->exclude_folders_label), data->exclude_folders_entry); - - data->load_button = gtk_button_new_with_mnemonic (_("_Load Options")); - data->save_button = gtk_button_new_with_mnemonic (_("Sa_ve Options")); - data->clear_button = gtk_button_new_with_mnemonic (_("_Reset Options")); - - main_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 20); - gtk_container_set_border_width (GTK_CONTAINER (main_box), 0); - gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (file_sel), main_box); - - vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 0); - gtk_box_pack_start (GTK_BOX (main_box), vbox, TRUE, TRUE, 0); - - gtk_box_pack_start (GTK_BOX (vbox), data->include_subfold_checkbutton, - TRUE, TRUE, 0); - - gtk_box_pack_start (GTK_BOX (vbox), data->exclude_symlinks, TRUE, TRUE, 0); - - gtk_box_pack_start (GTK_BOX (vbox), data->add_if_newer_checkbutton, - TRUE, TRUE, 0); - - grid = gtk_grid_new (); - gtk_grid_set_row_spacing (GTK_GRID (grid), 6); - gtk_grid_set_column_spacing (GTK_GRID (grid), 6); - gtk_box_pack_start (GTK_BOX (vbox), grid, - TRUE, TRUE, 0); - - gtk_grid_attach (GTK_GRID (grid), - data->include_files_label, - 0, 0, - 1, 1); - gtk_grid_attach (GTK_GRID (grid), - data->include_files_entry, - 1, 0, - 3, 1); - gtk_grid_attach (GTK_GRID (grid), - data->exclude_files_label, - 0, 1, - 1, 1); - gtk_grid_attach (GTK_GRID (grid), - data->exclude_files_entry, - 1, 1, - 1, 1); - gtk_grid_attach (GTK_GRID (grid), - data->exclude_folders_label, - 2, 1, - 1, 1); - gtk_grid_attach (GTK_GRID (grid), - data->exclude_folders_entry, - 3, 1, - 1, 1); - - /**/ - - vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 0); - gtk_box_pack_start (GTK_BOX (main_box), vbox, FALSE, FALSE, 0); - - gtk_box_pack_start (GTK_BOX (vbox), data->load_button, - FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), data->save_button, - FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), data->clear_button, - FALSE, FALSE, 0); - - gtk_widget_show_all (main_box); + data->settings = g_settings_new (ENGRAMPA_SCHEMA_ADD); + data->dialog = _gtk_builder_get_widget (builder, "dialog_add_folder"); + data->add_if_newer_checkbutton = _gtk_builder_get_widget (builder, "add_if_newer_checkbutton"); + data->exclude_symlinks = _gtk_builder_get_widget (builder, "exclude_symlinks"); + data->include_subfold_checkbutton = _gtk_builder_get_widget (builder, "include_subfold_checkbutton"); + data->include_files_entry = _gtk_builder_get_widget (builder, "include_files_entry"); + data->exclude_files_entry = _gtk_builder_get_widget (builder, "exclude_files_entry"); + data->exclude_folders_entry = _gtk_builder_get_widget (builder, "exclude_folders_entry"); /* set data */ - dlg_add_folder_load_last_options (data); /* signals */ - - g_signal_connect (G_OBJECT (file_sel), - "destroy", - G_CALLBACK (open_file_destroy_cb), - data); - g_signal_connect (G_OBJECT (file_sel), - "response", - G_CALLBACK (file_sel_response_cb), - data); - g_signal_connect (G_OBJECT (data->include_subfold_checkbutton), - "toggled", - G_CALLBACK (include_subfold_toggled_cb), - data); - g_signal_connect (G_OBJECT (data->load_button), - "clicked", - G_CALLBACK (load_options_cb), - data); - g_signal_connect (G_OBJECT (data->save_button), - "clicked", - G_CALLBACK (save_options_cb), - data); - g_signal_connect (G_OBJECT (data->clear_button), - "clicked", - G_CALLBACK (clear_options_cb), - data); - - gtk_window_set_modal (GTK_WINDOW (file_sel),TRUE); - gtk_widget_show (file_sel); + gtk_builder_add_callback_symbols (builder, + "on_dialog_add_folder_destroy", G_CALLBACK (open_file_destroy_cb), + "on_dialog_add_folder_response", G_CALLBACK (file_sel_response_cb), + "on_include_subfold_checkbutton_toggled", G_CALLBACK (include_subfold_toggled_cb), + "on_load_button_clicked", G_CALLBACK (load_options_cb), + "on_save_button_clicked", G_CALLBACK (save_options_cb), + "on_clear_button_clicked", G_CALLBACK (clear_options_cb), + NULL); + gtk_builder_connect_signals (builder, data); + + g_object_unref (builder); + + gtk_window_set_modal (GTK_WINDOW (data->dialog), TRUE); + gtk_widget_show (data->dialog); } diff --git a/src/engrampa.gresource.xml b/src/engrampa.gresource.xml index 1060005..deed6e3 100644 --- a/src/engrampa.gresource.xml +++ b/src/engrampa.gresource.xml @@ -6,6 +6,8 @@ ui/batch-add-files.ui ui/batch-password.ui ui/delete.ui + ui/dlg-add-files.ui + ui/dlg-add-folder.ui ui/dlg-extract.ui ui/engrampa.about ui/menus-toolbars.ui diff --git a/src/ui/Makefile.am b/src/ui/Makefile.am index a1efbc4..db123ae 100644 --- a/src/ui/Makefile.am +++ b/src/ui/Makefile.am @@ -4,6 +4,8 @@ EXTRA_DIST = \ batch-add-files.ui \ batch-password.ui \ delete.ui \ + dlg-add-files.ui \ + dlg-add-folder.ui \ dlg-extract.ui \ engrampa.about \ menus-toolbars.ui \ diff --git a/src/ui/dlg-add-files.ui b/src/ui/dlg-add-files.ui new file mode 100644 index 0000000..0e3881d --- /dev/null +++ b/src/ui/dlg-add-files.ui @@ -0,0 +1,134 @@ + + + + + + True + False + help-browser + + + True + False + process-stop + + + True + False + add-files-to-archive + + + False + dialog + False + False + True + + + + + + + + False + vertical + + + False + end + + + _Help + True + True + True + image1 + True + + + True + True + 0 + + + + + _Cancel + True + True + True + image2 + True + + + True + True + 1 + + + + + _Add + True + True + True + True + True + image3 + True + + + True + True + 2 + + + + + False + False + 0 + + + + + True + False + 6 + 6 + 6 + 6 + vertical + 12 + + + Add only if _newer + True + True + False + start + True + True + + + False + True + 0 + + + + + False + True + 2 + + + + + + button1 + button2 + button3 + + + diff --git a/src/ui/dlg-add-folder.ui b/src/ui/dlg-add-folder.ui new file mode 100644 index 0000000..14aedc1 --- /dev/null +++ b/src/ui/dlg-add-folder.ui @@ -0,0 +1,365 @@ + + + + + + True + False + help-browser + + + True + False + process-stop + + + True + False + add-folder-to-archive + + + False + Add a Folder + dialog + select-folder + False + False + + + + + + + + False + vertical + + + False + end + + + _Help + True + True + True + image1 + True + + + True + True + 0 + + + + + _Cancel + True + True + True + image2 + True + + + True + True + 1 + + + + + _Add + True + True + True + True + True + image3 + True + + + True + True + 2 + + + + + False + False + 0 + + + + + True + False + 6 + 6 + 6 + 6 + 12 + + + True + False + vertical + 6 + + + _Include subfolders + True + True + False + start + True + True + + + + False + True + 0 + + + + + Exclude folders that are symbolic lin_ks + True + True + False + start + 12 + True + True + + + False + True + 1 + + + + + Add only if _newer + True + True + False + start + True + True + + + False + True + 2 + + + + + True + False + 8 + + + True + False + start + Include _files: + True + include_files_entry + + + + + + False + True + 0 + + + + + True + True + example: *.o; *.bak + + + + + + True + True + 1 + + + + + False + True + 3 + + + + + True + False + 8 + + + True + False + start + E_xclude files: + True + exclude_files_entry + + + + + + False + True + 0 + + + + + True + True + example: *.o; *.bak + + + + + + True + True + 1 + + + + + True + False + start + _Exclude folders: + True + + + + + + False + True + 2 + + + + + True + True + example: *.o; *.bak + + + + + + True + True + 3 + + + + + False + True + 4 + + + + + False + True + 0 + + + + + True + False + start + start + 12 + vertical + 2 + start + + + _Load Options + True + True + True + True + + + + True + True + 0 + + + + + Sa_ve Options + True + True + True + True + + + + True + True + 1 + + + + + _Reset Options + True + True + True + True + + + + True + True + 2 + + + + + False + True + 1 + + + + + False + True + 2 + + + + + + button1 + button3 + button2 + + + -- cgit v1.2.1