Switch raw sector file picker to GtkFileChooserDialog
This commit is contained in:
committed by
Stéphane Lesimple
parent
ea92170fd1
commit
f8678eb3be
@@ -288,36 +288,24 @@ static void calculate_failures(raw_editor_context *rec)
|
|||||||
|
|
||||||
static void file_select_cb(GtkWidget *widget, gpointer data)
|
static void file_select_cb(GtkWidget *widget, gpointer data)
|
||||||
{ raw_editor_context *rec = Closure->rawEditorContext;
|
{ raw_editor_context *rec = Closure->rawEditorContext;
|
||||||
int action = GPOINTER_TO_INT(data);
|
GtkWidget *dialog;
|
||||||
|
|
||||||
switch(action)
|
|
||||||
{
|
|
||||||
case ACTION_BROWSE_LOAD: /* open the dialog */
|
|
||||||
if(!rec->fileSel)
|
if(!rec->fileSel)
|
||||||
{ char filename[strlen(Closure->dDumpDir)+10];
|
{ char filename[strlen(Closure->dDumpDir)+10];
|
||||||
|
|
||||||
rec->fileSel = gtk_file_selection_new(_utf("windowtitle|Raw sector dump selection"));
|
dialog = gtk_file_chooser_dialog_new("Raw sector dump selection",
|
||||||
g_signal_connect(G_OBJECT(rec->fileSel), "destroy",
|
Closure->window,
|
||||||
G_CALLBACK(file_select_cb), GINT_TO_POINTER(ACTION_FILESEL_DESTROY));
|
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||||
g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(rec->fileSel)->ok_button),"clicked",
|
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
||||||
G_CALLBACK(file_select_cb), GINT_TO_POINTER(ACTION_FILESEL_OK));
|
_("_Open"), GTK_RESPONSE_ACCEPT,
|
||||||
g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(rec->fileSel)->cancel_button),"clicked",
|
NULL);
|
||||||
G_CALLBACK(file_select_cb), GINT_TO_POINTER(ACTION_FILESEL_CANCEL));
|
|
||||||
sprintf(filename, "%s/", Closure->dDumpDir);
|
sprintf(filename, "%s/", Closure->dDumpDir);
|
||||||
gtk_file_selection_set_filename(GTK_FILE_SELECTION(rec->fileSel), filename);
|
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), filename);
|
||||||
}
|
|
||||||
gtk_widget_show(rec->fileSel);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ACTION_FILESEL_DESTROY:
|
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
|
||||||
rec->fileSel = NULL;
|
{ if(rec->filepath)
|
||||||
break;
|
|
||||||
|
|
||||||
case ACTION_FILESEL_OK:
|
|
||||||
if(rec->filepath)
|
|
||||||
g_free(rec->filepath);
|
g_free(rec->filepath);
|
||||||
rec->filepath = g_strdup(gtk_file_selection_get_filename(GTK_FILE_SELECTION(rec->fileSel)));
|
rec->filepath = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
|
||||||
gtk_widget_hide(rec->fileSel);
|
|
||||||
ResetRawBuffer(rec->rb);
|
ResetRawBuffer(rec->rb);
|
||||||
ReadDefectiveSectorFile(rec->dsh, rec->rb, rec->filepath);
|
ReadDefectiveSectorFile(rec->dsh, rec->rb, rec->filepath);
|
||||||
PrintPQStats(rec->rb);
|
PrintPQStats(rec->rb);
|
||||||
@@ -328,11 +316,8 @@ static void file_select_cb(GtkWidget *widget, gpointer data)
|
|||||||
render_sector(rec);
|
render_sector(rec);
|
||||||
GuiSetLabelText(rec->rightLabel, _("%s loaded, LBA %" PRId64 ", %d samples."),
|
GuiSetLabelText(rec->rightLabel, _("%s loaded, LBA %" PRId64 ", %d samples."),
|
||||||
rec->filepath, rec->rb->lba, rec->rb->samplesRead);
|
rec->filepath, rec->rb->lba, rec->rb->samplesRead);
|
||||||
break;
|
}
|
||||||
|
gtk_widget_destroy (dialog);
|
||||||
case ACTION_FILESEL_CANCEL:
|
|
||||||
gtk_widget_hide(rec->fileSel);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user