summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dlg-add-files.c6
-rw-r--r--src/dlg-add-folder.c35
-rw-r--r--src/dlg-ask-password.c18
-rw-r--r--src/dlg-batch-add.c48
-rw-r--r--src/dlg-delete.c24
-rw-r--r--src/dlg-extract.c2
-rw-r--r--src/dlg-new.c15
-rw-r--r--src/dlg-password.c14
-rw-r--r--src/dlg-prop.c43
-rw-r--r--src/dlg-update.c37
-rw-r--r--src/gtk-utils.c7
-rw-r--r--src/gtk-utils.h3
12 files changed, 119 insertions, 133 deletions
diff --git a/src/dlg-add-files.c b/src/dlg-add-files.c
index 6842811..c8430b3 100644
--- a/src/dlg-add-files.c
+++ b/src/dlg-add-files.c
@@ -31,6 +31,8 @@
#include "preferences.h"
#include "dlg-add-files.h"
+#define GET_WIDGET(x) (GTK_WIDGET (gtk_builder_get_object (builder, (x))))
+
typedef struct {
FrWindow *window;
GSettings *settings;
@@ -145,8 +147,8 @@ add_files_cb (GtkWidget *widget,
data = g_new0 (DialogData, 1);
data->window = callback_data;
data->settings = g_settings_new (ENGRAMPA_SCHEMA_ADD);
- data->dialog = _gtk_builder_get_widget (builder, "dialog_add_files");
- data->add_if_newer_checkbutton = _gtk_builder_get_widget (builder, "add_if_newer_checkbutton");
+ data->dialog = GET_WIDGET ("dialog_add_files");
+ data->add_if_newer_checkbutton = GET_WIDGET ("add_if_newer_checkbutton");
/* set data */
folder = g_settings_get_string (data->settings, PREF_ADD_CURRENT_FOLDER);
diff --git a/src/dlg-add-folder.c b/src/dlg-add-folder.c
index 3bc5db6..926da11 100644
--- a/src/dlg-add-folder.c
+++ b/src/dlg-add-folder.c
@@ -39,6 +39,8 @@
#define UNUSED_VARIABLE
#endif
+#define GET_WIDGET(x) (GTK_WIDGET (gtk_builder_get_object (builder, (x))))
+
typedef struct {
FrWindow *window;
GSettings *settings;
@@ -209,13 +211,13 @@ add_folder_cb (GtkWidget *widget,
data = g_new0 (DialogData, 1);
data->window = callback_data;
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");
+ data->dialog = GET_WIDGET ("dialog_add_folder");
+ data->add_if_newer_checkbutton = GET_WIDGET ("add_if_newer_checkbutton");
+ data->exclude_symlinks = GET_WIDGET ("exclude_symlinks");
+ data->include_subfold_checkbutton = GET_WIDGET ("include_subfold_checkbutton");
+ data->include_files_entry = GET_WIDGET ("include_files_entry");
+ data->exclude_files_entry = GET_WIDGET ("exclude_files_entry");
+ data->exclude_folders_entry = GET_WIDGET ("exclude_folders_entry");
/* set data */
dlg_add_folder_load_last_options (data);
@@ -516,7 +518,6 @@ dlg_add_folder_save_last_options (DialogData *data)
typedef struct {
DialogData *data;
- GtkBuilder *builder;
GtkWidget *dialog;
GtkWidget *aod_treeview;
GtkTreeModel *aod_model;
@@ -527,7 +528,6 @@ static void
aod_destroy_cb (GtkWidget *widget,
LoadOptionsDialogData *aod_data)
{
- g_object_unref (aod_data->builder);
g_free (aod_data);
}
@@ -656,8 +656,8 @@ load_options_cb (GtkWidget *w,
DialogData *data)
{
LoadOptionsDialogData *aod_data;
+ GtkBuilder *builder;
GtkWidget *ok_button;
- GtkWidget *cancel_button;
GtkWidget *remove_button;
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
@@ -665,16 +665,15 @@ load_options_cb (GtkWidget *w,
aod_data = g_new0 (LoadOptionsDialogData, 1);
aod_data->data = data;
- aod_data->builder = gtk_builder_new_from_resource (ENGRAMPA_RESOURCE_UI_PATH G_DIR_SEPARATOR_S "add-options.ui");
+ builder = gtk_builder_new_from_resource (ENGRAMPA_RESOURCE_UI_PATH G_DIR_SEPARATOR_S "add-options.ui");
/* Get the widgets. */
- aod_data->dialog = _gtk_builder_get_widget (aod_data->builder, "add_options_dialog");
- aod_data->aod_treeview = _gtk_builder_get_widget (aod_data->builder, "aod_treeview");
+ aod_data->dialog = GET_WIDGET ("add_options_dialog");
+ aod_data->aod_treeview = GET_WIDGET ("aod_treeview");
- ok_button = _gtk_builder_get_widget (aod_data->builder, "aod_okbutton");
- cancel_button = _gtk_builder_get_widget (aod_data->builder, "aod_cancelbutton");
- remove_button = _gtk_builder_get_widget (aod_data->builder, "aod_remove_button");
+ ok_button = GET_WIDGET ("aod_okbutton");
+ remove_button = GET_WIDGET ("aod_remove_button");
/* Set the signals handlers. */
@@ -686,7 +685,7 @@ load_options_cb (GtkWidget *w,
"row_activated",
G_CALLBACK (aod_activated_cb),
aod_data);
- g_signal_connect_swapped (G_OBJECT (cancel_button),
+ g_signal_connect_swapped (gtk_builder_get_object (builder, "aod_cancelbutton"),
"clicked",
G_CALLBACK (gtk_widget_destroy),
G_OBJECT (aod_data->dialog));
@@ -699,6 +698,8 @@ load_options_cb (GtkWidget *w,
G_CALLBACK (aod_remove_cb),
aod_data);
+ g_object_unref (builder);
+
/* Set data. */
aod_data->aod_model = GTK_TREE_MODEL (gtk_list_store_new (2,
diff --git a/src/dlg-ask-password.c b/src/dlg-ask-password.c
index 292e465..9453376 100644
--- a/src/dlg-ask-password.c
+++ b/src/dlg-ask-password.c
@@ -29,6 +29,8 @@
#include "glib-utils.h"
#include "gtk-utils.h"
+#define GET_LABEL(x) (GTK_LABEL (gtk_builder_get_object (builder, (x))))
+#define GET_WIDGET(x) (GTK_WIDGET (gtk_builder_get_object (builder, (x))))
typedef enum {
FR_PASSWORD_TYPE_MAIN,
@@ -36,7 +38,6 @@ typedef enum {
} FrPasswordType;
typedef struct {
- GtkBuilder *builder;
FrWindow *window;
FrPasswordType pwd_type;
GtkWidget *dialog;
@@ -49,7 +50,6 @@ static void
destroy_cb (GtkWidget *widget,
DialogData *data)
{
- g_object_unref (data->builder);
g_free (data);
}
@@ -91,22 +91,20 @@ static void
dlg_ask_password__common (FrWindow *window,
FrPasswordType pwd_type)
{
+ GtkBuilder *builder;
DialogData *data;
- GtkWidget *label;
char *text;
char *name = NULL;
data = g_new0 (DialogData, 1);
- data->builder = gtk_builder_new_from_resource (ENGRAMPA_RESOURCE_UI_PATH G_DIR_SEPARATOR_S "batch-password.ui");
+ builder = gtk_builder_new_from_resource (ENGRAMPA_RESOURCE_UI_PATH G_DIR_SEPARATOR_S "batch-password.ui");
data->window = window;
data->pwd_type = pwd_type;
/* Get the widgets. */
- data->dialog = _gtk_builder_get_widget (data->builder, "password_dialog");
- data->pw_password_entry = _gtk_builder_get_widget (data->builder, "pw_password_entry");
-
- label = _gtk_builder_get_widget (data->builder, "pw_password_label");
+ data->dialog = GET_WIDGET ("password_dialog");
+ data->pw_password_entry = GET_WIDGET ("pw_password_entry");
/* Set widgets data. */
@@ -116,7 +114,7 @@ dlg_ask_password__common (FrWindow *window,
name = g_uri_display_basename (fr_window_get_paste_archive_uri (window));
g_assert (name != NULL);
text = g_strdup_printf (_("Enter the password for the archive '%s'."), name);
- gtk_label_set_label (GTK_LABEL (label), text);
+ gtk_label_set_label (GET_LABEL ("pw_password_label"), text);
g_free (text);
if (fr_window_get_password (window) != NULL)
@@ -135,6 +133,8 @@ dlg_ask_password__common (FrWindow *window,
G_CALLBACK (ask_password__response_cb),
data);
+ g_object_unref (builder);
+
/* Run dialog. */
gtk_widget_grab_focus (data->pw_password_entry);
diff --git a/src/dlg-batch-add.c b/src/dlg-batch-add.c
index 4d7a3ca..71f6060 100644
--- a/src/dlg-batch-add.c
+++ b/src/dlg-batch-add.c
@@ -37,7 +37,11 @@
#define BAD_CHARS "/\\*"
-#define GET_WIDGET(x) (_gtk_builder_get_widget (data->builder, (x)))
+#define GET_ENTRY(x) (GTK_ENTRY (gtk_builder_get_object (data->builder, (x))))
+#define GET_FILE_CHOOSER(x) (GTK_FILE_CHOOSER (gtk_builder_get_object (data->builder, (x))))
+#define GET_TOGGLE_BUTTON(x) (GTK_TOGGLE_BUTTON (gtk_builder_get_object (data->builder, (x))))
+#define GET_WIDGET(x) (GTK_WIDGET (gtk_builder_get_object (data->builder, (x))))
+#define GET_WINDOW(x) (GTK_WINDOW (gtk_builder_get_object (data->builder, (x))))
static gboolean has_password = FALSE;
static gboolean can_encrypt_header = FALSE;
@@ -75,7 +79,7 @@ destroy_cb (GtkWidget *widget,
{
g_settings_set_string (data->settings, PREF_BATCH_ADD_DEFAULT_EXTENSION, get_ext (data));
/*g_settings_set_boolean (data->settings, PREF_BATCH_ADD_OTHER_OPTIONS, data->add_clicked ? FALSE : gtk_expander_get_expanded (GTK_EXPANDER (GET_WIDGET ("a_other_options_expander"))));*/
- g_settings_set_boolean (data->settings_general, PREF_GENERAL_ENCRYPT_HEADER, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("a_encrypt_header_checkbutton"))));
+ g_settings_set_boolean (data->settings_general, PREF_GENERAL_ENCRYPT_HEADER, gtk_toggle_button_get_active (GET_TOGGLE_BUTTON ("a_encrypt_header_checkbutton")));
if (! data->add_clicked) {
@@ -99,18 +103,18 @@ set_archive_options (DialogData *data)
if (mime_type_desc[data->supported_types[idx]].capabilities & FR_COMMAND_CAN_ENCRYPT) {
const char *pwd;
- pwd = gtk_entry_get_text (GTK_ENTRY (GET_WIDGET ("a_password_entry")));
+ pwd = gtk_entry_get_text (GET_ENTRY ("a_password_entry"));
if (pwd != NULL) {
if (strcmp (pwd, "") != 0) {
fr_window_set_password (data->window, pwd);
if (mime_type_desc[data->supported_types[idx]].capabilities & FR_COMMAND_CAN_ENCRYPT_HEADER)
- fr_window_set_encrypt_header (data->window, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("a_encrypt_header_checkbutton"))));
+ fr_window_set_encrypt_header (data->window, gtk_toggle_button_get_active (GET_TOGGLE_BUTTON ("a_encrypt_header_checkbutton")));
}
}
}
if ((mime_type_desc[data->supported_types[idx]].capabilities & FR_COMMAND_CAN_CREATE_VOLUMES)
- && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("a_volume_checkbutton"))))
+ && gtk_toggle_button_get_active (GET_TOGGLE_BUTTON ("a_volume_checkbutton")))
{
double value;
int size;
@@ -127,7 +131,7 @@ static void
help_clicked_cb (GtkWidget *widget,
DialogData *data)
{
- show_help_dialog (GTK_WINDOW (GET_WIDGET ("dialog")), "engrampa-fmgr-add");
+ show_help_dialog (GET_WINDOW ("dialog"), "engrampa-fmgr-add");
}
@@ -148,7 +152,7 @@ add_clicked_cb (GtkWidget *widget,
/* Collect data */
- archive_name = g_uri_escape_string (gtk_entry_get_text (GTK_ENTRY (GET_WIDGET ("a_add_to_entry"))), NULL, FALSE);
+ archive_name = g_uri_escape_string (gtk_entry_get_text (GET_ENTRY ("a_add_to_entry")), NULL, FALSE);
/* Check whether the user entered a valid archive name. */
@@ -190,7 +194,7 @@ add_clicked_cb (GtkWidget *widget,
/* Check directory existence. */
- archive_dir = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (GET_WIDGET ("a_location_filechooserbutton")));
+ archive_dir = gtk_file_chooser_get_uri (GET_FILE_CHOOSER ("a_location_filechooserbutton"));
if (archive_dir == NULL) {
g_free (archive_dir);
g_free (archive_name);
@@ -224,7 +228,7 @@ add_clicked_cb (GtkWidget *widget,
msg = g_strdup_printf (_("Destination folder \"%s\" does not exist.\n\nDo you want to create it?"), folder_name);
g_free (folder_name);
- d = _gtk_message_dialog_new (GTK_WINDOW (GET_WIDGET ("dialog")),
+ d = _gtk_message_dialog_new (GET_WINDOW ("dialog"),
GTK_DIALOG_MODAL,
"dialog-question",
msg,
@@ -311,7 +315,7 @@ add_clicked_cb (GtkWidget *widget,
GtkWidget *d;
int r;
- d = _gtk_message_dialog_new (GTK_WINDOW (GET_WIDGET ("dialog")),
+ d = _gtk_message_dialog_new (GET_WINDOW ("dialog"),
GTK_DIALOG_MODAL,
"dialog-question",
_("The archive is already present. Do you want to overwrite it?"),
@@ -366,7 +370,7 @@ update_sensitivity_for_mime_type (DialogData *data,
gtk_widget_set_sensitive (GET_WIDGET ("a_password_entry"), FALSE);
gtk_widget_set_sensitive (GET_WIDGET ("a_password_label"), FALSE);
gtk_widget_set_sensitive (GET_WIDGET ("a_encrypt_header_checkbutton"), FALSE);
- gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (GET_WIDGET ("a_encrypt_header_checkbutton")), TRUE);
+ gtk_toggle_button_set_inconsistent (GET_TOGGLE_BUTTON ("a_encrypt_header_checkbutton"), TRUE);
gtk_widget_set_sensitive (GET_WIDGET ("a_volume_box"), FALSE);
return;
}
@@ -382,7 +386,7 @@ update_sensitivity_for_mime_type (DialogData *data,
sensitive = mime_type_desc[i].capabilities & FR_COMMAND_CAN_ENCRYPT_HEADER;
can_encrypt_header = sensitive;
gtk_widget_set_sensitive (GET_WIDGET ("a_encrypt_header_checkbutton"), sensitive ? has_password : FALSE);
- gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (GET_WIDGET ("a_encrypt_header_checkbutton")), sensitive ? (!has_password) : TRUE);
+ gtk_toggle_button_set_inconsistent (GET_TOGGLE_BUTTON ("a_encrypt_header_checkbutton"), sensitive ? (!has_password) : TRUE);
sensitive = mime_type_desc[i].capabilities & FR_COMMAND_CAN_CREATE_VOLUMES;
gtk_widget_set_sensitive (GET_WIDGET ("a_volume_box"), sensitive);
@@ -439,11 +443,11 @@ update_sensitivity (DialogData *data)
const char *password;
gtk_widget_set_sensitive (GET_WIDGET ("a_volume_spinbutton"),
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("a_volume_checkbutton"))));
+ gtk_toggle_button_get_active (GET_TOGGLE_BUTTON ("a_volume_checkbutton")));
- password = gtk_entry_get_text (GTK_ENTRY (GET_WIDGET ("a_password_entry")));
+ password = gtk_entry_get_text (GET_ENTRY ("a_password_entry"));
has_password = (password != NULL) && (*password != '\0');
- gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (GET_WIDGET ("a_encrypt_header_checkbutton")), can_encrypt_header ? (!has_password) : TRUE);
+ gtk_toggle_button_set_inconsistent (GET_TOGGLE_BUTTON ("a_encrypt_header_checkbutton"), can_encrypt_header ? (!has_password) : TRUE);
gtk_widget_set_sensitive (GET_WIDGET ("a_encrypt_header_checkbutton"), can_encrypt_header ? has_password : FALSE);
}
@@ -497,7 +501,7 @@ dlg_batch_add_files (FrWindow *window,
gtk_size_group_add_widget (size_group, GET_WIDGET ("a_password_label"));
gtk_expander_set_expanded (GTK_EXPANDER (GET_WIDGET ("a_other_options_expander")), FALSE /*g_settings_get_boolean (data->settings, PREF_BATCH_ADD_OTHER_OPTIONS)*/);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("a_encrypt_header_checkbutton")), g_settings_get_boolean (data->settings_general, PREF_GENERAL_ENCRYPT_HEADER));
+ gtk_toggle_button_set_active (GET_TOGGLE_BUTTON ("a_encrypt_header_checkbutton"), g_settings_get_boolean (data->settings_general, PREF_GENERAL_ENCRYPT_HEADER));
gtk_spin_button_set_value (GTK_SPIN_BUTTON (GET_WIDGET ("a_volume_spinbutton")), g_settings_get_int (data->settings, PREF_BATCH_ADD_VOLUME_SIZE) / MEGABYTE);
@@ -514,13 +518,13 @@ dlg_batch_add_files (FrWindow *window,
}
}
- _gtk_entry_set_filename_text (GTK_ENTRY (GET_WIDGET ("a_add_to_entry")), automatic_name);
+ _gtk_entry_set_filename_text (GET_ENTRY ("a_add_to_entry"), automatic_name);
g_free (automatic_name);
if (check_permissions (parent, R_OK | W_OK))
- gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (GET_WIDGET ("a_location_filechooserbutton")), parent);
+ gtk_file_chooser_set_current_folder_uri (GET_FILE_CHOOSER ("a_location_filechooserbutton"), parent);
else
- gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (GET_WIDGET ("a_location_filechooserbutton")), get_home_uri ());
+ gtk_file_chooser_set_current_folder_uri (GET_FILE_CHOOSER ("a_location_filechooserbutton"), get_home_uri ());
g_free (parent);
/* archive type combobox */
@@ -561,7 +565,7 @@ dlg_batch_add_files (FrWindow *window,
"changed",
G_CALLBACK (archive_type_combo_box_changed_cb),
data);
- g_signal_connect (GET_WIDGET ("a_password_entry"),
+ g_signal_connect (gtk_builder_get_object (data->builder, "a_password_entry"),
"notify::text",
G_CALLBACK (password_entry_notify_text_cb),
data);
@@ -582,6 +586,6 @@ dlg_batch_add_files (FrWindow *window,
update_sensitivity (data);
- gtk_window_set_modal (GTK_WINDOW (GET_WIDGET ("dialog")), FALSE);
- gtk_window_present (GTK_WINDOW (GET_WIDGET ("dialog")));
+ gtk_window_set_modal (GET_WINDOW ("dialog"), FALSE);
+ gtk_window_present (GET_WINDOW ("dialog"));
}
diff --git a/src/dlg-delete.c b/src/dlg-delete.c
index 824e2ec..803c9b2 100644
--- a/src/dlg-delete.c
+++ b/src/dlg-delete.c
@@ -27,11 +27,11 @@
#include "file-utils.h"
#include "dlg-delete.h"
+#define GET_WIDGET(x) (GTK_WIDGET (gtk_builder_get_object (builder, (x))))
typedef struct {
FrWindow *window;
GList *selected_files;
- GtkBuilder *builder;
GtkWidget *dialog;
GtkWidget *d_all_files_radio;
@@ -47,7 +47,6 @@ destroy_cb (GtkWidget *widget,
DialogData *data)
{
path_list_free (data->selected_files);
- g_object_unref (G_OBJECT (data->builder));
g_free (data);
}
@@ -107,25 +106,24 @@ static void
dlg_delete__common (FrWindow *window,
GList *selected_files)
{
+ GtkBuilder *builder;
DialogData *data;
- GtkWidget *cancel_button;
GtkWidget *ok_button;
data = g_new (DialogData, 1);
data->window = window;
data->selected_files = selected_files;
- data->builder = gtk_builder_new_from_resource (ENGRAMPA_RESOURCE_UI_PATH G_DIR_SEPARATOR_S "delete.ui");
+ builder = gtk_builder_new_from_resource (ENGRAMPA_RESOURCE_UI_PATH G_DIR_SEPARATOR_S "delete.ui");
/* Get the widgets. */
- data->dialog = _gtk_builder_get_widget (data->builder, "delete_dialog");
- data->d_all_files_radio = _gtk_builder_get_widget (data->builder, "d_all_files_radio");
- data->d_selected_files_radio = _gtk_builder_get_widget (data->builder, "d_selected_files_radio");
- data->d_files_radio = _gtk_builder_get_widget (data->builder, "d_files_radio");
- data->d_files_entry = _gtk_builder_get_widget (data->builder, "d_files_entry");
+ data->dialog = GET_WIDGET ("delete_dialog");
+ data->d_all_files_radio = GET_WIDGET ("d_all_files_radio");
+ data->d_selected_files_radio = GET_WIDGET ("d_selected_files_radio");
+ data->d_files_radio = GET_WIDGET ("d_files_radio");
+ data->d_files_entry = GET_WIDGET ("d_files_entry");
- ok_button = _gtk_builder_get_widget (data->builder, "d_ok_button");
- cancel_button = _gtk_builder_get_widget (data->builder, "d_cancel_button");
+ ok_button = GET_WIDGET ("d_ok_button");
/* Set widgets data. */
@@ -142,7 +140,7 @@ dlg_delete__common (FrWindow *window,
"destroy",
G_CALLBACK (destroy_cb),
data);
- g_signal_connect_swapped (G_OBJECT (cancel_button),
+ g_signal_connect_swapped (gtk_builder_get_object (builder, "d_cancel_button"),
"clicked",
G_CALLBACK (gtk_widget_destroy),
G_OBJECT (data->dialog));
@@ -155,6 +153,8 @@ dlg_delete__common (FrWindow *window,
G_CALLBACK (entry_changed_cb),
data);
+ g_object_unref (builder);
+
/* Run dialog. */
gtk_window_set_transient_for (GTK_WINDOW (data->dialog),
diff --git a/src/dlg-extract.c b/src/dlg-extract.c
index 836cc09..1621c3e 100644
--- a/src/dlg-extract.c
+++ b/src/dlg-extract.c
@@ -31,7 +31,7 @@
#include "typedefs.h"
#include "dlg-extract.h"
-#define GET_WIDGET(x) (_gtk_builder_get_widget (data->builder, (x)))
+#define GET_WIDGET(x) (GTK_WIDGET (gtk_builder_get_object (data->builder, (x))))
typedef struct {
FrWindow *window;
diff --git a/src/dlg-new.c b/src/dlg-new.c
index fbc1e8d..940d079 100644
--- a/src/dlg-new.c
+++ b/src/dlg-new.c
@@ -32,7 +32,7 @@
#include "preferences.h"
-#define GET_WIDGET(x) (_gtk_builder_get_widget (data->builder, (x)))
+#define GET_WIDGET(x) (GTK_WIDGET (gtk_builder_get_object (builder, (x))))
#define DEFAULT_EXTENSION ".tar.gz"
#define BAD_CHARS "/\\*"
#define MEGABYTE (1024.0 * 1024.0)
@@ -43,7 +43,6 @@ static void
destroy_cb (GtkWidget *widget,
DlgNewData *data)
{
- g_object_unref (data->builder);
g_free (data);
}
@@ -266,13 +265,13 @@ dlg_new_archive (FrWindow *window,
int *supported_types,
const char *default_name)
{
+ GtkBuilder *builder;
DlgNewData *data;
- GSettings *settings;
- /*char *default_ext;*/
+ GSettings *settings;
int i;
data = g_new0 (DlgNewData, 1);
- data->builder = gtk_builder_new_from_resource (ENGRAMPA_RESOURCE_UI_PATH G_DIR_SEPARATOR_S "new.ui");
+ builder = gtk_builder_new_from_resource (ENGRAMPA_RESOURCE_UI_PATH G_DIR_SEPARATOR_S "new.ui");
data->window = window;
data->supported_types = supported_types;
sort_mime_types_by_description (data->supported_types);
@@ -352,12 +351,12 @@ dlg_new_archive (FrWindow *window,
/* Set the signals handlers. */
- gtk_builder_add_callback_symbols (data->builder,
+ gtk_builder_add_callback_symbols (builder,
"on_dialog_destroy", G_CALLBACK (destroy_cb),
"on_n_password_entry_changed", G_CALLBACK (password_entry_changed_cb),
"on_n_volume_checkbutton_toggled", G_CALLBACK (volume_toggled_cb),
NULL);
- gtk_builder_connect_signals (data->builder, data);
+ gtk_builder_connect_signals (builder, data);
g_signal_connect (G_OBJECT (data->format_chooser),
"selection-changed",
@@ -369,6 +368,8 @@ dlg_new_archive (FrWindow *window,
G_CALLBACK (options_expander_unmap_cb),
data->format_chooser);
+ g_object_unref (builder);
+
/* Run dialog. */
update_sensitivity (data);
diff --git a/src/dlg-password.c b/src/dlg-password.c
index 4d7a52e..7f237e6 100644
--- a/src/dlg-password.c
+++ b/src/dlg-password.c
@@ -28,9 +28,9 @@
#include "preferences.h"
#include "dlg-password.h"
+#define GET_WIDGET(x) (GTK_WIDGET (gtk_builder_get_object (builder, (x))))
typedef struct {
- GtkBuilder *builder;
FrWindow *window;
GtkWidget *dialog;
GtkWidget *pw_password_entry;
@@ -43,7 +43,6 @@ static void
destroy_cb (GtkWidget *widget,
DialogData *data)
{
- g_object_unref (data->builder);
g_free (data);
}
@@ -84,18 +83,19 @@ void
dlg_password (GtkWidget *widget,
gpointer callback_data)
{
+ GtkBuilder *builder;
FrWindow *window = callback_data;
DialogData *data;
data = g_new0 (DialogData, 1);
- data->builder = gtk_builder_new_from_resource (ENGRAMPA_RESOURCE_UI_PATH G_DIR_SEPARATOR_S "password.ui");
+ builder = gtk_builder_new_from_resource (ENGRAMPA_RESOURCE_UI_PATH G_DIR_SEPARATOR_S "password.ui");
data->window = window;
/* Get the widgets. */
- data->dialog = _gtk_builder_get_widget (data->builder, "password_dialog");
- data->pw_password_entry = _gtk_builder_get_widget (data->builder, "pw_password_entry");
- data->pw_encrypt_header_checkbutton = _gtk_builder_get_widget (data->builder, "pw_encrypt_header_checkbutton");
+ data->dialog = GET_WIDGET ("password_dialog");
+ data->pw_password_entry = GET_WIDGET ("pw_password_entry");
+ data->pw_encrypt_header_checkbutton = GET_WIDGET ("pw_encrypt_header_checkbutton");
/* Set widgets data. */
@@ -114,6 +114,8 @@ dlg_password (GtkWidget *widget,
G_CALLBACK (response_cb),
data);
+ g_object_unref (builder);
+
/* Run dialog. */
gtk_widget_grab_focus (data->pw_password_entry);
diff --git a/src/dlg-prop.c b/src/dlg-prop.c
index 59cfca2..e604f5c 100644
--- a/src/dlg-prop.c
+++ b/src/dlg-prop.c
@@ -29,9 +29,10 @@
#include "fr-window.h"
#include "dlg-prop.h"
+#define GET_LABEL(x) (GTK_LABEL (gtk_builder_get_object (builder, (x))))
+#define GET_WIDGET(x) (GTK_WIDGET (gtk_builder_get_object (builder, (x))))
typedef struct {
- GtkBuilder *builder;
GtkWidget *dialog;
} DialogData;
@@ -41,7 +42,6 @@ static void
destroy_cb (GtkWidget *widget,
DialogData *data)
{
- g_object_unref (G_OBJECT (data->builder));
g_free (data);
}
@@ -58,10 +58,9 @@ help_cb (GtkWidget *w,
void
dlg_prop (FrWindow *window)
{
+ GtkBuilder *builder;
DialogData *data;
- GtkWidget *ok_button;
GtkWidget *help_button;
- GtkWidget *label;
GFile *parent;
char *uri;
char *markup;
@@ -72,22 +71,20 @@ dlg_prop (FrWindow *window)
double ratio;
data = g_new (DialogData, 1);
- data->builder = gtk_builder_new_from_resource (ENGRAMPA_RESOURCE_UI_PATH G_DIR_SEPARATOR_S "properties.ui");
+ builder = gtk_builder_new_from_resource (ENGRAMPA_RESOURCE_UI_PATH G_DIR_SEPARATOR_S "properties.ui");
/* Get the widgets. */
- data->dialog = _gtk_builder_get_widget (data->builder, "prop_dialog");
- ok_button = _gtk_builder_get_widget (data->builder, "p_ok_button");
- help_button = _gtk_builder_get_widget (data->builder, "p_help_button");
+ help_button = GET_WIDGET ("p_help_button");
+ data->dialog = GET_WIDGET ("prop_dialog");
/* Set widgets data. */
- label = _gtk_builder_get_widget (data->builder, "p_path_label");
uri = remove_level_from_path (fr_window_get_archive_uri (window));
parent = g_file_new_for_uri (uri);
utf8_name = g_file_get_parse_name (parent);
markup = g_strdup_printf ("<a href=\"%s\">%s</a>", uri, utf8_name);
- gtk_label_set_markup (GTK_LABEL (label), markup);
+ gtk_label_set_markup (GET_LABEL ("p_path_label"), markup);
g_free (markup);
g_free (utf8_name);
@@ -96,9 +93,8 @@ dlg_prop (FrWindow *window)
/**/
- label = _gtk_builder_get_widget (data->builder, "p_name_label");
utf8_name = g_uri_display_basename (fr_window_get_archive_uri (window));
- gtk_label_set_text (GTK_LABEL (label), utf8_name);
+ gtk_label_set_text (GET_LABEL ("p_name_label"), utf8_name);
title_txt = g_strdup_printf (_("%s Properties"), utf8_name);
gtk_window_set_title (GTK_WINDOW (data->dialog), title_txt);
@@ -108,20 +104,18 @@ dlg_prop (FrWindow *window)
/**/
- label = _gtk_builder_get_widget (data->builder, "p_date_label");
GDateTime *date_time;
date_time = g_date_time_new_from_unix_local (get_file_mtime (fr_window_get_archive_uri (window)));
s = g_date_time_format (date_time, _("%d %B %Y, %H:%M"));
g_date_time_unref (date_time);
- gtk_label_set_text (GTK_LABEL (label), s);
+ gtk_label_set_text (GET_LABEL ("p_date_label"), s);
g_free (s);
/**/
- label = _gtk_builder_get_widget (data->builder, "p_size_label");
size = get_file_size (fr_window_get_archive_uri (window));
s = g_format_size_full (size, G_FORMAT_SIZE_LONG_FORMAT);
- gtk_label_set_text (GTK_LABEL (label), s);
+ gtk_label_set_text (GET_LABEL ("p_size_label"), s);
g_free (s);
/**/
@@ -136,34 +130,29 @@ dlg_prop (FrWindow *window)
}
}
- label = _gtk_builder_get_widget (data->builder, "p_uncomp_size_label");
s = g_format_size_full (uncompressed_size, G_FORMAT_SIZE_LONG_FORMAT);
- gtk_label_set_text (GTK_LABEL (label), s);
+ gtk_label_set_text (GET_LABEL ("p_uncomp_size_label"), s);
g_free (s);
/**/
- label = _gtk_builder_get_widget (data->builder, "p_cratio_label");
-
if (uncompressed_size != 0)
ratio = (double) uncompressed_size / size;
else
ratio = 0.0;
s = g_strdup_printf ("%0.2f", ratio);
- gtk_label_set_text (GTK_LABEL (label), s);
+ gtk_label_set_text (GET_LABEL ("p_cratio_label"), s);
g_free (s);
/**/
- label = _gtk_builder_get_widget (data->builder, "p_files_label");
s = g_strdup_printf ("%d", window->archive->command->n_regular_files);
- gtk_label_set_text (GTK_LABEL (label), s);
+ gtk_label_set_text (GET_LABEL ("p_files_label"), s);
g_free (s);
/**/
- label = _gtk_builder_get_widget (data->builder, "p_mime_type_label");
- gtk_label_set_text (GTK_LABEL (label), window->archive->command->mime_type);
+ gtk_label_set_text (GET_LABEL ("p_mime_type_label"), window->archive->command->mime_type);
/* Set the signals handlers. */
@@ -171,7 +160,7 @@ dlg_prop (FrWindow *window)
"destroy",
G_CALLBACK (destroy_cb),
data);
- g_signal_connect_swapped (G_OBJECT (ok_button),
+ g_signal_connect_swapped (gtk_builder_get_object (builder, "p_ok_button"),
"clicked",
G_CALLBACK (gtk_widget_destroy),
G_OBJECT (data->dialog));
@@ -180,6 +169,8 @@ dlg_prop (FrWindow *window)
G_CALLBACK (help_cb),
data);
+ g_object_unref (builder);
+
/* Run dialog. */
gtk_window_set_transient_for (GTK_WINDOW (data->dialog),
diff --git a/src/dlg-update.c b/src/dlg-update.c
index 80bee40..41d3115 100644
--- a/src/dlg-update.c
+++ b/src/dlg-update.c
@@ -30,6 +30,7 @@
#include "fr-init.h"
#include "fr-window.h"
+#define GET_WIDGET(x) (GTK_WIDGET (gtk_builder_get_object (builder, (x))))
enum {
IS_SELECTED_COLUMN,
@@ -40,7 +41,6 @@ enum {
typedef struct {
FrWindow *window;
- GtkBuilder *builder;
GtkWidget *update_file_dialog;
GtkWidget *update_file_primary_text_label;
@@ -63,7 +63,6 @@ dlg_update__destroy_cb (GtkWidget *widget,
DialogData *data)
{
fr_window_update_dialog_closed (data->window);
- g_object_unref (G_OBJECT (data->builder));
if (data->file_list != NULL)
g_list_free (data->file_list);
g_free (data);
@@ -276,33 +275,27 @@ is_selected_toggled (GtkCellRendererToggle *cell,
gpointer
dlg_update (FrWindow *window)
{
+ GtkBuilder *builder;
DialogData *data;
- GtkWidget *update_file_ok_button;
- GtkWidget *update_file_cancel_button;
- GtkWidget *update_files_cancel_button;
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
data = g_new0 (DialogData, 1);
- data->builder = gtk_builder_new_from_resource (ENGRAMPA_RESOURCE_UI_PATH G_DIR_SEPARATOR_S "update.ui");
+ builder = gtk_builder_new_from_resource (ENGRAMPA_RESOURCE_UI_PATH G_DIR_SEPARATOR_S "update.ui");
data->file_list = NULL;
data->window = window;
/* Get the widgets. */
- data->update_file_dialog = _gtk_builder_get_widget (data->builder, "update_file_dialog");
- data->update_file_primary_text_label = _gtk_builder_get_widget (data->builder, "update_file_primary_text_label");
- data->update_file_secondary_text_label = _gtk_builder_get_widget (data->builder, "update_file_secondary_text_label");
+ data->update_file_dialog = GET_WIDGET ("update_file_dialog");
+ data->update_file_primary_text_label = GET_WIDGET ("update_file_primary_text_label");
+ data->update_file_secondary_text_label = GET_WIDGET ("update_file_secondary_text_label");
- update_file_ok_button = _gtk_builder_get_widget (data->builder, "update_file_ok_button");
- update_file_cancel_button = _gtk_builder_get_widget (data->builder, "update_file_cancel_button");
-
- data->update_files_dialog = _gtk_builder_get_widget (data->builder, "update_files_dialog");
- data->update_files_primary_text_label = _gtk_builder_get_widget (data->builder, "update_files_primary_text_label");
- data->update_files_secondary_text_label = _gtk_builder_get_widget (data->builder, "update_files_secondary_text_label");
- data->update_files_treeview = _gtk_builder_get_widget (data->builder, "update_files_treeview");
- data->update_files_ok_button = _gtk_builder_get_widget (data->builder, "update_files_ok_button");
- update_files_cancel_button = _gtk_builder_get_widget (data->builder, "update_files_cancel_button");
+ data->update_files_dialog = GET_WIDGET ("update_files_dialog");
+ data->update_files_primary_text_label = GET_WIDGET ("update_files_primary_text_label");
+ data->update_files_secondary_text_label = GET_WIDGET ("update_files_secondary_text_label");
+ data->update_files_treeview = GET_WIDGET ("update_files_treeview");
+ data->update_files_ok_button = GET_WIDGET ("update_files_ok_button");
/* Set the signals handlers. */
@@ -310,11 +303,11 @@ dlg_update (FrWindow *window)
"destroy",
G_CALLBACK (dlg_update__destroy_cb),
data);
- g_signal_connect (G_OBJECT (update_file_ok_button),
+ g_signal_connect (gtk_builder_get_object (builder, "update_file_ok_button"),
"clicked",
G_CALLBACK (update_cb),
data);
- g_signal_connect_swapped (G_OBJECT (update_file_cancel_button),
+ g_signal_connect_swapped (gtk_builder_get_object (builder, "update_file_cancel_button"),
"clicked",
G_CALLBACK (gtk_widget_destroy),
G_OBJECT (data->update_file_dialog));
@@ -326,11 +319,13 @@ dlg_update (FrWindow *window)
"clicked",
G_CALLBACK (update_cb),
data);
- g_signal_connect_swapped (G_OBJECT (update_files_cancel_button),
+ g_signal_connect_swapped (gtk_builder_get_object (builder, "update_files_cancel_button"),
"clicked",
G_CALLBACK (gtk_widget_destroy),
G_OBJECT (data->update_files_dialog));
+ g_object_unref (builder);
+
/* Set dialog data. */
data->list_model = GTK_TREE_MODEL (gtk_list_store_new (N_COLUMNS,
diff --git a/src/gtk-utils.c b/src/gtk-utils.c
index 1e45ef8..c0e94db 100644
--- a/src/gtk-utils.c
+++ b/src/gtk-utils.c
@@ -573,13 +573,6 @@ show_help_dialog (GtkWindow *parent,
}
-GtkWidget *
-_gtk_builder_get_widget (GtkBuilder *builder,
- const char *name)
-{
- return (GtkWidget *) gtk_builder_get_object (builder, name);
-}
-
int
_gtk_widget_lookup_for_size (GtkWidget *widget,
GtkIconSize icon_size)
diff --git a/src/gtk-utils.h b/src/gtk-utils.h
index a3c9ff4..86fc797 100644
--- a/src/gtk-utils.h
+++ b/src/gtk-utils.h
@@ -65,9 +65,6 @@ GdkPixbuf * get_mime_type_pixbuf (const char *mime_type,
GtkIconTheme *icon_theme);
void show_help_dialog (GtkWindow *parent,
const char *section);
-GtkWidget *
- _gtk_builder_get_widget (GtkBuilder *builder,
- const char *name);
int _gtk_widget_lookup_for_size (GtkWidget *widget,
GtkIconSize icon_size);