Switch image and ecc file picker to GtkFileChooserDialog
This commit is contained in:
committed by
Stéphane Lesimple
parent
ad3285507b
commit
8469a933e4
@@ -328,78 +328,51 @@ static void drive_select_cb(GtkWidget *widget, gpointer data)
|
|||||||
|
|
||||||
static void file_select_cb(GtkWidget *widget, gpointer data)
|
static void file_select_cb(GtkWidget *widget, gpointer data)
|
||||||
{ int action = GPOINTER_TO_INT(data);
|
{ int action = GPOINTER_TO_INT(data);
|
||||||
|
GtkWidget *dialog;
|
||||||
|
|
||||||
switch(action)
|
switch(action)
|
||||||
{ /*** Image file selection */
|
{ /*** Image file selection */
|
||||||
|
|
||||||
case MENU_FILE_IMAGE:
|
case MENU_FILE_IMAGE:
|
||||||
if(!Closure->imageFileSel)
|
dialog = gtk_file_chooser_dialog_new("Image file selection",
|
||||||
{ Closure->imageFileSel = gtk_file_selection_new(_utf("windowtitle|Image file selection"));
|
Closure->window,
|
||||||
g_signal_connect(G_OBJECT(Closure->imageFileSel), "destroy",
|
GTK_FILE_CHOOSER_ACTION_SAVE,
|
||||||
G_CALLBACK(file_select_cb), GINT_TO_POINTER(MENU_FILE_IMAGE_DESTROY));
|
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
||||||
g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(Closure->imageFileSel)->ok_button),"clicked",
|
_("_Open"), GTK_RESPONSE_ACCEPT,
|
||||||
G_CALLBACK(file_select_cb), GINT_TO_POINTER(MENU_FILE_IMAGE_OK));
|
NULL);
|
||||||
|
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog),
|
||||||
g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(Closure->imageFileSel)->cancel_button),"clicked",
|
|
||||||
G_CALLBACK(file_select_cb), GINT_TO_POINTER(MENU_FILE_IMAGE_CANCEL));
|
|
||||||
}
|
|
||||||
gtk_file_selection_set_filename(GTK_FILE_SELECTION(Closure->imageFileSel),
|
|
||||||
gtk_entry_get_text(GTK_ENTRY(Closure->imageEntry)));
|
gtk_entry_get_text(GTK_ENTRY(Closure->imageEntry)));
|
||||||
gtk_widget_show(Closure->imageFileSel);
|
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
|
||||||
break;
|
{ g_free(Closure->imageName);
|
||||||
|
Closure->imageName = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
|
||||||
case MENU_FILE_IMAGE_DESTROY:
|
|
||||||
Closure->imageFileSel = NULL;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MENU_FILE_IMAGE_OK:
|
|
||||||
g_free(Closure->imageName);
|
|
||||||
Closure->imageName = g_strdup(gtk_file_selection_get_filename(GTK_FILE_SELECTION(Closure->imageFileSel)));
|
|
||||||
if(Closure->autoSuffix)
|
if(Closure->autoSuffix)
|
||||||
Closure->imageName = ApplyAutoSuffix(Closure->imageName, "iso");
|
Closure->imageName = ApplyAutoSuffix(Closure->imageName, "iso");
|
||||||
gtk_entry_set_text(GTK_ENTRY(Closure->imageEntry), Closure->imageName);
|
gtk_entry_set_text(GTK_ENTRY(Closure->imageEntry), Closure->imageName);
|
||||||
gtk_editable_set_position(GTK_EDITABLE(Closure->imageEntry), -1);
|
gtk_editable_set_position(GTK_EDITABLE(Closure->imageEntry), -1);
|
||||||
gtk_widget_hide(Closure->imageFileSel);
|
}
|
||||||
break;
|
gtk_widget_destroy (dialog);
|
||||||
|
|
||||||
case MENU_FILE_IMAGE_CANCEL:
|
|
||||||
gtk_widget_hide(Closure->imageFileSel);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/*** Same stuff again for ecc file selection */
|
/*** Same stuff again for ecc file selection */
|
||||||
|
|
||||||
case MENU_FILE_ECC:
|
case MENU_FILE_ECC:
|
||||||
if(!Closure->eccFileSel)
|
dialog = gtk_file_chooser_dialog_new("Error correction file selection",
|
||||||
{ Closure->eccFileSel = gtk_file_selection_new(_utf("windowtitle|Error correction file selection"));
|
Closure->window,
|
||||||
g_signal_connect(G_OBJECT(Closure->eccFileSel), "destroy",
|
GTK_FILE_CHOOSER_ACTION_SAVE,
|
||||||
G_CALLBACK(file_select_cb), GINT_TO_POINTER(MENU_FILE_ECC_DESTROY));
|
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
||||||
g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(Closure->eccFileSel)->ok_button),"clicked",
|
_("_Open"), GTK_RESPONSE_ACCEPT,
|
||||||
G_CALLBACK(file_select_cb), GINT_TO_POINTER(MENU_FILE_ECC_OK));
|
NULL);
|
||||||
|
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog),
|
||||||
g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(Closure->eccFileSel)->cancel_button),"clicked",
|
gtk_entry_get_text(GTK_ENTRY(Closure->imageEntry)));
|
||||||
G_CALLBACK(file_select_cb), GINT_TO_POINTER(MENU_FILE_ECC_CANCEL));
|
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
|
||||||
}
|
{ g_free(Closure->imageName);
|
||||||
gtk_file_selection_set_filename(GTK_FILE_SELECTION(Closure->eccFileSel),
|
Closure->eccName = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
|
||||||
gtk_entry_get_text(GTK_ENTRY(Closure->eccEntry)));
|
|
||||||
gtk_widget_show(Closure->eccFileSel);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MENU_FILE_ECC_DESTROY:
|
|
||||||
Closure->eccFileSel = NULL;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MENU_FILE_ECC_OK:
|
|
||||||
g_free(Closure->eccName);
|
|
||||||
Closure->eccName = g_strdup(gtk_file_selection_get_filename(GTK_FILE_SELECTION(Closure->eccFileSel)));
|
|
||||||
if(Closure->autoSuffix)
|
if(Closure->autoSuffix)
|
||||||
Closure->eccName = ApplyAutoSuffix(Closure->eccName, "ecc");
|
Closure->eccName = ApplyAutoSuffix(Closure->eccName, "ecc");
|
||||||
gtk_entry_set_text(GTK_ENTRY(Closure->eccEntry), Closure->eccName);
|
gtk_entry_set_text(GTK_ENTRY(Closure->eccName), Closure->eccName);
|
||||||
gtk_editable_set_position(GTK_EDITABLE(Closure->eccEntry), -1);
|
gtk_editable_set_position(GTK_EDITABLE(Closure->eccName), -1);
|
||||||
gtk_widget_hide(Closure->eccFileSel);
|
}
|
||||||
break;
|
gtk_widget_destroy (dialog);
|
||||||
|
|
||||||
case MENU_FILE_ECC_CANCEL:
|
|
||||||
gtk_widget_hide(Closure->eccFileSel);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user