summaryrefslogtreecommitdiff
path: root/src/dlg-add-folder.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/dlg-add-folder.c')
-rw-r--r--src/dlg-add-folder.c180
1 files changed, 30 insertions, 150 deletions
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 <gio/gio.h>
#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);
}