Author: colossus
Date: 2007-08-26 19:26:50 +0000 (Sun, 26 Aug 2007)
New Revision: 26019
Modified:
xarchiver/trunk/src/extract_dialog.c
xarchiver/trunk/src/pref_dialog.c
xarchiver/trunk/src/pref_dialog.h
xarchiver/trunk/src/window.c
Log:
Made the prefs dialog to let the user choose the executables and restore them
at startup.
Changed the word 'folder' to 'directory' in extract_dialog.c
Modified: xarchiver/trunk/src/extract_dialog.c
===================================================================
--- xarchiver/trunk/src/extract_dialog.c 2007-08-25 19:31:08 UTC (rev
26018)
+++ xarchiver/trunk/src/extract_dialog.c 2007-08-26 19:26:50 UTC (rev
26019)
@@ -99,7 +99,7 @@
gtk_widget_set_size_request (dialog_data->image1, 30, 30);
gtk_container_add(GTK_CONTAINER(dialog_data->button1),
dialog_data->image1);
- gtk_tooltips_set_tip (dialog_data->option_tooltip,dialog_data->button1
, _("Choose a folder where to extract files"), NULL );
+ gtk_tooltips_set_tip (dialog_data->option_tooltip,dialog_data->button1
, _("Choose a directory where to extract files"), NULL );
g_signal_connect ( (gpointer) dialog_data->button1, "clicked",
G_CALLBACK (xa_choose_extraction_directory) , dialog_data );
dialog_data->hbox4 = gtk_hbox_new (TRUE, 7);
@@ -358,7 +358,7 @@
gchar *msg;
utf8_path = g_filename_to_utf8 (destination_path, -1, NULL,
NULL, NULL);
- msg = g_strdup_printf (_("You don't have the right permissions
to extract the files to the folder \"%s\"."), utf8_path);
+ msg = g_strdup_printf (_("You don't have the right permissions
to extract the files to the directory \"%s\"."), utf8_path);
response = xa_show_message_dialog (GTK_WINDOW
(MainWindow),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK, _("Can't
perform extraction!"),msg );
g_free (utf8_path);
g_free (msg);
@@ -450,7 +450,6 @@
}
else
{
- g_print ("ALL files\n");
xa_extract_tar_without_directories ( "tar -xvjf
",archive,archive->extraction_path,FALSE );
command = NULL;
}
@@ -825,7 +824,7 @@
/* *Here we have to fill a GSList with all the filenames in the
archive so that we can use mv on all of them */
XEntry *entry;
GSList *s = archive->entries;
-
+ g_print ("%s\n",gtk_entry_get_text(GTK_ENTRY(location_entry)));
for (; s; s = s->next)
{
entry = s->data;
@@ -898,7 +897,7 @@
int response;
gchar *path;
- File_Selector = gtk_file_chooser_dialog_new ( _("Choose the destination
folder where to extract the current archive"),
+ File_Selector = gtk_file_chooser_dialog_new ( _("Choose the destination
directory"),
GTK_WINDOW (MainWindow),
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
GTK_STOCK_CANCEL,
Modified: xarchiver/trunk/src/pref_dialog.c
===================================================================
--- xarchiver/trunk/src/pref_dialog.c 2007-08-25 19:31:08 UTC (rev 26018)
+++ xarchiver/trunk/src/pref_dialog.c 2007-08-26 19:26:50 UTC (rev 26019)
@@ -213,18 +213,22 @@
(GtkAttachOptions) (GTK_SHRINK), 0, 0);
gtk_misc_set_alignment (GTK_MISC (label6), 0, 0.5);
prefs_data->combo_prefered_web_browser = gtk_combo_box_new_text();
- gtk_combo_box_append_text (GTK_COMBO_BOX
(prefs_data->combo_prefered_web_browser), _("Firefox") );
+ gtk_combo_box_append_text (GTK_COMBO_BOX
(prefs_data->combo_prefered_web_browser), "" );
gtk_combo_box_append_text (GTK_COMBO_BOX
(prefs_data->combo_prefered_web_browser), _("choose...") );
+ g_signal_connect
(prefs_data->combo_prefered_web_browser,"changed",G_CALLBACK
(xa_prefs_combo_changed),NULL);
gtk_table_attach (GTK_TABLE (table2),
prefs_data->combo_prefered_web_browser, 1, 2, 0, 1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (GTK_SHRINK), 0, 0);
+
label7 = gtk_label_new (_("Open text files with:"));
gtk_table_attach (GTK_TABLE (table2), label7, 0, 1, 1, 2,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (GTK_SHRINK), 0, 0);
gtk_misc_set_alignment (GTK_MISC (label7), 0, 0.5);
prefs_data->combo_prefered_editor = gtk_combo_box_new_text();
+ gtk_combo_box_append_text (GTK_COMBO_BOX
(prefs_data->combo_prefered_editor), "" );
gtk_combo_box_append_text (GTK_COMBO_BOX
(prefs_data->combo_prefered_editor), _("choose...") );
+ g_signal_connect
(prefs_data->combo_prefered_editor,"changed",G_CALLBACK
(xa_prefs_combo_changed),NULL);
gtk_table_attach (GTK_TABLE (table2),
prefs_data->combo_prefered_editor, 1, 2, 1, 2,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (GTK_SHRINK), 0, 0);
@@ -235,7 +239,9 @@
(GtkAttachOptions) (GTK_SHRINK), 0, 0);
gtk_misc_set_alignment (GTK_MISC (label8), 0, 0.5);
prefs_data->combo_prefered_viewer = gtk_combo_box_new_text();
+ gtk_combo_box_append_text (GTK_COMBO_BOX
(prefs_data->combo_prefered_viewer), "" );
gtk_combo_box_append_text (GTK_COMBO_BOX
(prefs_data->combo_prefered_viewer), _("choose...") );
+ g_signal_connect
(prefs_data->combo_prefered_viewer,"changed",G_CALLBACK
(xa_prefs_combo_changed),NULL);
gtk_table_attach (GTK_TABLE (table2),
prefs_data->combo_prefered_viewer, 1, 2, 2, 3,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (GTK_SHRINK), 0, 0);
@@ -248,6 +254,7 @@
prefs_data->combo_prefered_temp_dir = gtk_combo_box_new_text();
gtk_combo_box_append_text (GTK_COMBO_BOX
(prefs_data->combo_prefered_temp_dir), _("/tmp") );
gtk_combo_box_append_text (GTK_COMBO_BOX
(prefs_data->combo_prefered_temp_dir), _("choose...") );
+ g_signal_connect
(prefs_data->combo_prefered_temp_dir,"changed",G_CALLBACK
(xa_prefs_combo_changed),(gpointer) 1);
gtk_table_attach (GTK_TABLE (table2),
prefs_data->combo_prefered_temp_dir, 1, 2, 3, 4,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (GTK_SHRINK), 0, 0);
@@ -302,6 +309,8 @@
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
(prefs_data->show_location_bar),TRUE);
gtk_combo_box_set_active
(GTK_COMBO_BOX(prefs_data->combo_prefered_web_browser),0);
+ gtk_combo_box_set_active
(GTK_COMBO_BOX(prefs_data->combo_prefered_editor),0);
+ gtk_combo_box_set_active
(GTK_COMBO_BOX(prefs_data->combo_prefered_viewer),0);
gtk_combo_box_set_active
(GTK_COMBO_BOX(prefs_data->combo_prefered_temp_dir),0);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
(prefs_data->check_save_geometry),FALSE);
}
@@ -309,6 +318,7 @@
void xa_prefs_save_options(Prefs_dialog_data *prefs_data, const char *filename)
{
gchar *conf;
+ gchar *value;
FILE *fp;
gint bytes_written, len;
GKeyFile *xa_key_file = g_key_file_new();
@@ -325,10 +335,30 @@
g_key_file_set_boolean
(xa_key_file,PACKAGE,"sort_filename_content",gtk_toggle_button_get_active
(GTK_TOGGLE_BUTTON (prefs_data->check_sort_filename_column)));
g_key_file_set_boolean
(xa_key_file,PACKAGE,"show_location_bar",gtk_toggle_button_get_active
(GTK_TOGGLE_BUTTON (prefs_data->show_location_bar)));
- g_key_file_set_integer
(xa_key_file,PACKAGE,"preferred_web_browser",gtk_combo_box_get_active
(GTK_COMBO_BOX(prefs_data->combo_prefered_web_browser)));
- g_key_file_set_integer
(xa_key_file,PACKAGE,"preferred_editor",gtk_combo_box_get_active
(GTK_COMBO_BOX(prefs_data->combo_prefered_editor)));
- g_key_file_set_integer
(xa_key_file,PACKAGE,"preferred_viewer",gtk_combo_box_get_active
(GTK_COMBO_BOX(prefs_data->combo_prefered_viewer)));
- g_key_file_set_integer
(xa_key_file,PACKAGE,"preferred_temp_dir",gtk_combo_box_get_active
(GTK_COMBO_BOX(prefs_data->combo_prefered_temp_dir)));
+ value = gtk_combo_box_get_active_text
(GTK_COMBO_BOX(prefs_data->combo_prefered_web_browser));
+ if (value != NULL)
+ {
+ g_key_file_set_string
(xa_key_file,PACKAGE,"preferred_web_browser",value);
+ g_free (value);
+ }
+ value = gtk_combo_box_get_active_text
(GTK_COMBO_BOX(prefs_data->combo_prefered_editor));
+ if (value != NULL)
+ {
+ g_key_file_set_string
(xa_key_file,PACKAGE,"preferred_editor",value);
+ g_free(value);
+ }
+ value = gtk_combo_box_get_active_text
(GTK_COMBO_BOX(prefs_data->combo_prefered_viewer));
+ if (value != NULL)
+ {
+ g_key_file_set_string
(xa_key_file,PACKAGE,"preferred_viewer",value);
+ g_free(value);
+ }
+ value = gtk_combo_box_get_active_text
(GTK_COMBO_BOX(prefs_data->combo_prefered_temp_dir));
+ if (value != NULL)
+ {
+ g_key_file_set_string
(xa_key_file,PACKAGE,"preferred_temp_dir",value);
+ g_free(value);
+ }
if
(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(prefs_data->check_save_geometry))
)
{
gtk_window_get_position
(GTK_WINDOW(MainWindow),&prefs_data->geometry[0],&prefs_data->geometry[1]);
@@ -351,6 +381,7 @@
void xa_prefs_load_options(Prefs_dialog_data *prefs_data)
{
gint *coords = NULL;
+ gchar *value;
guint coords_len = 0;
gchar *config_dir = NULL;
gchar *xarchiver_config_dir = NULL;
@@ -390,11 +421,40 @@
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON(prefs_data->check_show_comment),g_key_file_get_boolean(xa_key_file,PACKAGE,"show_archive_comment",NULL));
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON(prefs_data->check_sort_filename_column),g_key_file_get_boolean(xa_key_file,PACKAGE,"sort_filename_content",NULL));
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON(prefs_data->show_location_bar),g_key_file_get_boolean(xa_key_file,PACKAGE,"show_location_bar",NULL));
-
- gtk_combo_box_set_active
(GTK_COMBO_BOX(prefs_data->combo_prefered_web_browser),g_key_file_get_integer(xa_key_file,PACKAGE,"preferred_web_browser",NULL));
- gtk_combo_box_set_active
(GTK_COMBO_BOX(prefs_data->combo_prefered_editor),g_key_file_get_integer(xa_key_file,PACKAGE,"preferred_editor",NULL));
- gtk_combo_box_set_active
(GTK_COMBO_BOX(prefs_data->combo_prefered_viewer),g_key_file_get_integer(xa_key_file,PACKAGE,"preferred_viewer",NULL));
- gtk_combo_box_set_active
(GTK_COMBO_BOX(prefs_data->combo_prefered_temp_dir),g_key_file_get_integer(xa_key_file,PACKAGE,"preferred_temp_dir",NULL));
+
+ value =
g_key_file_get_string(xa_key_file,PACKAGE,"preferred_web_browser",NULL);
+ if (value != NULL)
+ {
+ gtk_combo_box_remove_text(GTK_COMBO_BOX
(prefs_data->combo_prefered_web_browser),0);
+
gtk_combo_box_prepend_text(GTK_COMBO_BOX(prefs_data->combo_prefered_web_browser),value);
+ gtk_combo_box_set_active
(GTK_COMBO_BOX(prefs_data->combo_prefered_web_browser),0);
+ g_free(value);
+ }
+ value =
g_key_file_get_string(xa_key_file,PACKAGE,"preferred_editor",NULL);
+ if (value != NULL)
+ {
+ gtk_combo_box_remove_text(GTK_COMBO_BOX
(prefs_data->combo_prefered_editor),0);
+ gtk_combo_box_insert_text
(GTK_COMBO_BOX(prefs_data->combo_prefered_editor),0,value);
+ gtk_combo_box_set_active
(GTK_COMBO_BOX(prefs_data->combo_prefered_editor),0);
+ g_free(value);
+ }
+ value =
g_key_file_get_string(xa_key_file,PACKAGE,"preferred_viewer",NULL);
+ if (value != NULL)
+ {
+ gtk_combo_box_remove_text(GTK_COMBO_BOX
(prefs_data->combo_prefered_viewer),0);
+ gtk_combo_box_insert_text
(GTK_COMBO_BOX(prefs_data->combo_prefered_viewer),0,value);
+ gtk_combo_box_set_active
(GTK_COMBO_BOX(prefs_data->combo_prefered_viewer),0);
+ g_free(value);
+ }
+ value =
g_key_file_get_string(xa_key_file,PACKAGE,"preferred_temp_dir",NULL);
+ if (value != NULL)
+ {
+ gtk_combo_box_remove_text(GTK_COMBO_BOX
(prefs_data->combo_prefered_temp_dir),0);
+ gtk_combo_box_insert_text
(GTK_COMBO_BOX(prefs_data->combo_prefered_temp_dir),0,value);
+ gtk_combo_box_set_active
(GTK_COMBO_BOX(prefs_data->combo_prefered_temp_dir),0);
+ g_free(value);
+ }
+ gtk_combo_box_set_active
(GTK_COMBO_BOX(prefs_data->combo_prefered_temp_dir),0);
coords = g_key_file_get_integer_list(xa_key_file, PACKAGE,
"geometry", &coords_len, &error);
if (error)
{
@@ -412,6 +472,52 @@
}
}
g_key_file_free (xa_key_file);
- /* config_file is freed in window.c:519 */
+ /* config_file is freed in window.c xa_quit_application */
}
+void xa_prefs_combo_changed (GtkComboBox *widget,gpointer user_data)
+{
+ gchar *filename = NULL;
+ unsigned short int flag = GPOINTER_TO_UINT(user_data);
+
+ if (gtk_combo_box_get_active(GTK_COMBO_BOX (widget)) == 1)
+ {
+ filename = xa_prefs_choose_program(flag);
+ if (filename != NULL)
+ {
+ gtk_combo_box_remove_text(GTK_COMBO_BOX (widget),0);
+ gtk_combo_box_insert_text(GTK_COMBO_BOX
(widget),0,filename);
+ g_free(filename);
+ }
+ gtk_combo_box_set_active (GTK_COMBO_BOX (widget),0);
+ }
+}
+
+gchar *xa_prefs_choose_program(gboolean flag)
+{
+ gchar *filename = NULL;
+ GtkWidget *dialog;
+
+ dialog = gtk_file_chooser_dialog_new (flag ? _("Choose the temp
directory to use") : _("Choose the application to use"),
+ GTK_WINDOW(MainWindow),
+ flag ?
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER : GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
+ NULL);
+
+ if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
+ filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER
(dialog));
+
+ gtk_widget_destroy (dialog);
+
+ return filename;
+}
+
+void xa_apply_prefs_option(Prefs_dialog_data *prefs_data)
+{
+ if (gtk_toggle_button_get_active
(GTK_TOGGLE_BUTTON(prefs_data->show_location_bar)))
+ gtk_widget_show_all (toolbar2);
+ else
+ gtk_widget_hide (toolbar2);
+
+}
Modified: xarchiver/trunk/src/pref_dialog.h
===================================================================
--- xarchiver/trunk/src/pref_dialog.h 2007-08-25 19:31:08 UTC (rev 26018)
+++ xarchiver/trunk/src/pref_dialog.h 2007-08-26 19:26:50 UTC (rev 26019)
@@ -37,5 +37,8 @@
void xa_prefs_dialog_set_default_options (Prefs_dialog_data *prefs_data);
void xa_prefs_save_options (Prefs_dialog_data *prefs_data,const char
*filename);
void xa_prefs_load_options (Prefs_dialog_data *prefs_data);
+void xa_prefs_combo_changed (GtkComboBox *widget,gpointer user_data);
+void xa_apply_prefs_option(Prefs_dialog_data *);
+gchar *xa_prefs_choose_program(gboolean flag);
#endif
Modified: xarchiver/trunk/src/window.c
===================================================================
--- xarchiver/trunk/src/window.c 2007-08-25 19:31:08 UTC (rev 26018)
+++ xarchiver/trunk/src/window.c 2007-08-26 19:26:50 UTC (rev 26019)
@@ -656,12 +656,17 @@
void xa_show_prefs_dialog ( GtkMenuItem *menuitem , gpointer user_data )
{
+ gboolean response;
+
if (prefs_window == NULL)
prefs_window = xa_create_prefs_dialog();
gtk_widget_show_all (prefs_window->dialog1);
- gtk_dialog_run (GTK_DIALOG(prefs_window->dialog1));
+ response = gtk_dialog_run (GTK_DIALOG(prefs_window->dialog1));
gtk_widget_hide (prefs_window->dialog1);
+
+ if (response == GTK_RESPONSE_OK)
+ xa_apply_prefs_option(prefs_window);
}
void xa_convert_sfx ( GtkMenuItem *menuitem , gpointer user_data )
_______________________________________________
Xfce4-commits mailing list
[email protected]
http://foo-projects.org/mailman/listinfo/xfce4-commits