mirror of
https://github.com/leozide/leocad
synced 2024-11-17 07:47:55 +01:00
Linux dialog cleanup.
This commit is contained in:
parent
13b48e77a8
commit
cd7376e0e4
3 changed files with 82 additions and 163 deletions
|
@ -148,19 +148,6 @@ int msgbox_execute(const char* text, const char *caption, int flags)
|
|||
// =============================================================================
|
||||
// TODO: deprecated, delete
|
||||
|
||||
void dialog_button_callback (GtkWidget *widget, gpointer data)
|
||||
{
|
||||
GtkWidget *parent;
|
||||
int *loop, *ret;
|
||||
|
||||
parent = gtk_widget_get_toplevel (widget);
|
||||
loop = (int*)gtk_object_get_data (GTK_OBJECT (parent), "loop");
|
||||
ret = (int*)gtk_object_get_data (GTK_OBJECT (parent), "ret");
|
||||
|
||||
*loop = 0;
|
||||
*ret = GPOINTER_TO_INT (data);
|
||||
}
|
||||
|
||||
gint dialog_delete_callback (GtkWidget *widget, GdkEvent* event, gpointer data)
|
||||
{
|
||||
int *loop;
|
||||
|
@ -172,47 +159,10 @@ gint dialog_delete_callback (GtkWidget *widget, GdkEvent* event, gpointer data)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static int def_ret = 0;
|
||||
static int* cur_ret = NULL;
|
||||
|
||||
void dlg_end (int ret)
|
||||
{
|
||||
*cur_ret = ret;
|
||||
}
|
||||
|
||||
int dlg_domodal(GtkWidget* dlg, int def)
|
||||
{
|
||||
int ret = -1, old_def = def_ret, *old_ret = cur_ret;
|
||||
def_ret = def;
|
||||
cur_ret = &ret;
|
||||
|
||||
gtk_widget_show(dlg);
|
||||
gtk_grab_add(dlg);
|
||||
while (ret == -1)
|
||||
gtk_main_iteration ();
|
||||
gtk_grab_remove(dlg);
|
||||
gtk_widget_destroy(dlg);
|
||||
|
||||
cur_ret = old_ret;
|
||||
def_ret = old_def;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void dlg_default_callback(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
*cur_ret = GPOINTER_TO_INT(data);
|
||||
}
|
||||
|
||||
gint dlg_delete_callback(GtkWidget *widget, GdkEvent* event, gpointer data)
|
||||
{
|
||||
*cur_ret = def_ret;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// Array Dialog
|
||||
|
||||
typedef struct
|
||||
struct LC_ARRAYDLG_STRUCT
|
||||
{
|
||||
void* data;
|
||||
GtkWidget *move_x, *move_y, *move_z;
|
||||
|
@ -222,7 +172,7 @@ typedef struct
|
|||
GtkWidget *count1, *count2, *count3;
|
||||
GtkWidget *offset_x2, *offset_y2, *offset_z2;
|
||||
GtkWidget *offset_x3, *offset_y3, *offset_z3;
|
||||
} LC_ARRAYDLG_STRUCT;
|
||||
};
|
||||
|
||||
static void arraydlg_adjtotal(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
|
@ -342,7 +292,7 @@ int arraydlg_execute(void* param)
|
|||
gtk_widget_show(s.move_x);
|
||||
gtk_table_attach_defaults(GTK_TABLE(table), s.move_x, 1, 2, 1, 2);
|
||||
gtk_entry_set_width_chars(GTK_ENTRY(s.move_x), 4);
|
||||
|
||||
|
||||
adj = gtk_adjustment_new(0, -1000, 1000, 10, 10, 0);
|
||||
s.move_y = gtk_spin_button_new(GTK_ADJUSTMENT(adj), 1, 0);
|
||||
gtk_widget_show(s.move_y);
|
||||
|
@ -1457,7 +1407,7 @@ bool preferencesdlg_getopts(LC_PREFERENCESDLG_STRUCT* s, LC_PREFERENCESDLG_OPTS*
|
|||
memcpy(opts->fAmbient, gtk_object_get_data(GTK_OBJECT(s->scn_clrambient), "color_flt"), 3 * sizeof(float));
|
||||
memcpy(opts->fGrad1, gtk_object_get_data(GTK_OBJECT(s->scn_clrgrad1), "color_flt"), 3 * sizeof(float));
|
||||
memcpy(opts->fGrad2, gtk_object_get_data(GTK_OBJECT(s->scn_clrgrad2), "color_flt"), 3 * sizeof(float));
|
||||
|
||||
|
||||
// int nSaveInterval;
|
||||
// char strPath[LC_MAXPATH];
|
||||
|
||||
|
@ -1615,7 +1565,7 @@ int preferencesdlg_execute(void* param)
|
|||
Samples = g_list_append(Samples, (void*)"8x");
|
||||
gtk_combo_set_popdown_strings(GTK_COMBO(s.det_antialias), Samples);
|
||||
g_list_free(Samples);
|
||||
|
||||
|
||||
s.det_lighting = gtk_check_button_new_with_label("Lighting");
|
||||
gtk_widget_show(s.det_lighting);
|
||||
gtk_table_attach_defaults(GTK_TABLE(table), s.det_lighting, 0, 1, 3, 4);
|
||||
|
@ -2161,7 +2111,7 @@ int propertiesdlg_execute(void* param)
|
|||
gtk_text_buffer_set_text(buffer, opts->strComments, -1);
|
||||
|
||||
scroll_win = gtk_scrolled_window_new(NULL, NULL);
|
||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_win),
|
||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_win),
|
||||
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
||||
gtk_widget_show(scroll_win);
|
||||
gtk_container_add(GTK_CONTAINER(notebook), scroll_win);
|
||||
|
@ -2310,7 +2260,7 @@ static void groupeditdlg_addchildren(GtkCTree *ctree, GtkCTreeNode *parent, Grou
|
|||
{
|
||||
text = opts->groups[i]->m_strName;
|
||||
newparent = gtk_ctree_insert_node(ctree, parent, NULL, (gchar**)&text, 0, NULL, NULL, NULL, NULL, FALSE, TRUE);
|
||||
|
||||
|
||||
groupeditdlg_addchildren(ctree, newparent, opts->groups[i], opts);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,12 +2,7 @@
|
|||
#define _DIALOGS_H_
|
||||
|
||||
// TODO: obsolete, delete
|
||||
void dialog_button_callback(GtkWidget *widget, gpointer data);
|
||||
gint dialog_delete_callback(GtkWidget *widget, GdkEvent* event, gpointer data);
|
||||
int dlg_domodal(GtkWidget* dlg, int def);
|
||||
void dlg_end(int ret);
|
||||
gint dlg_delete_callback(GtkWidget *widget, GdkEvent* event, gpointer data);
|
||||
void dlg_default_callback(GtkWidget *widget, gpointer data);
|
||||
|
||||
void modifydlg_toggle();
|
||||
|
||||
|
|
|
@ -212,109 +212,83 @@ int saveprojectdlg_execute(char* filename)
|
|||
// =============================================================================
|
||||
// Save Picture Dialog
|
||||
|
||||
static void savefiledlg_ok (GtkWidget *widget, gpointer data)
|
||||
static void savepicturedlg_options(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
GtkWidget *parent;
|
||||
int *loop, *ret;
|
||||
|
||||
parent = gtk_widget_get_toplevel (widget);
|
||||
loop = (int*)gtk_object_get_data (GTK_OBJECT (parent), "loop");
|
||||
ret = (int*)gtk_object_get_data (GTK_OBJECT (parent), "ret");
|
||||
|
||||
if ((GPOINTER_TO_INT (data) == LC_OK) &&
|
||||
(access (gtk_file_selection_get_filename (GTK_FILE_SELECTION (parent)), R_OK) == 0))
|
||||
if (Sys_MessageBox ("File already exists, overwrite ?", "LeoCAD", LC_MB_YESNO) == LC_NO)
|
||||
return;
|
||||
|
||||
*loop = 0;
|
||||
*ret = GPOINTER_TO_INT (data);
|
||||
imageoptsdlg_execute(gtk_widget_get_toplevel(widget), data, false);
|
||||
}
|
||||
|
||||
static void savepicturedlg_options (GtkWidget *widget, gpointer data)
|
||||
int savepicturedlg_execute(void* param)
|
||||
{
|
||||
imageoptsdlg_execute (gtk_widget_get_toplevel(widget), data, false);
|
||||
}
|
||||
|
||||
int savepicturedlg_execute (void* param)
|
||||
{
|
||||
GtkWidget *dlg, *button;
|
||||
int ret = LC_CANCEL, loop = 1;
|
||||
|
||||
unsigned long image = Sys_ProfileLoadInt ("Default", "Image Options", 1|LC_IMAGE_TRANSPARENT);
|
||||
LC_IMAGEDLG_OPTS* opts = (LC_IMAGEDLG_OPTS*)param;
|
||||
opts->width = Sys_ProfileLoadInt ("Default", "Image Width", gdk_screen_width ());
|
||||
opts->height = Sys_ProfileLoadInt ("Default", "Image Height", gdk_screen_height ());
|
||||
opts->imopts.quality = Sys_ProfileLoadInt ("Default", "JPEG Quality", 70);
|
||||
opts->imopts.interlaced = (image & LC_IMAGE_PROGRESSIVE) != 0;
|
||||
opts->imopts.transparent = (image & LC_IMAGE_TRANSPARENT) != 0;
|
||||
opts->imopts.truecolor = (image & LC_IMAGE_HIGHCOLOR) != 0;
|
||||
opts->imopts.pause = (float)Sys_ProfileLoadInt ("Default", "AVI Pause", 100)/100;
|
||||
opts->imopts.format = (unsigned char)(image & ~(LC_IMAGE_MASK));
|
||||
|
||||
dlg = gtk_file_selection_new ("Save Picture"); // FIXME: use GtkFileChooserDialog
|
||||
gtk_window_set_transient_for (GTK_WINDOW (dlg), GTK_WINDOW (((GtkWidget*)(*main_window))));
|
||||
gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",
|
||||
GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
|
||||
gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
|
||||
GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
|
||||
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (dlg)->ok_button), "clicked",
|
||||
GTK_SIGNAL_FUNC (savefiledlg_ok), GINT_TO_POINTER (LC_OK));
|
||||
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (dlg)->cancel_button), "clicked",
|
||||
GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (LC_CANCEL));
|
||||
gtk_object_set_data (GTK_OBJECT (dlg), "loop", &loop);
|
||||
gtk_object_set_data (GTK_OBJECT (dlg), "ret", &ret);
|
||||
|
||||
// add the options button
|
||||
button = gtk_button_new_with_label ("Options");
|
||||
gtk_widget_show (button);
|
||||
gtk_box_pack_end (GTK_BOX (GTK_FILE_SELECTION (dlg)->ok_button->parent), button, TRUE, TRUE, 0);
|
||||
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (savepicturedlg_options), param);
|
||||
|
||||
/*
|
||||
gtk_file_selection_set_filename (GTK_FILE_SELECTION (dlg), filename);
|
||||
*/
|
||||
gtk_widget_show (dlg);
|
||||
gtk_grab_add (dlg);
|
||||
|
||||
while (loop)
|
||||
gtk_main_iteration ();
|
||||
|
||||
if (ret == LC_OK)
|
||||
{
|
||||
char ext[5], *p;
|
||||
|
||||
strcpy (opts->filename, gtk_file_selection_get_filename (GTK_FILE_SELECTION (dlg)));
|
||||
|
||||
if (strlen (opts->filename) == 0)
|
||||
ret = LC_CANCEL;
|
||||
|
||||
p = strrchr (opts->filename, '.');
|
||||
if (p != NULL)
|
||||
{
|
||||
strcpy (ext, p+1);
|
||||
strlwr (ext);
|
||||
}
|
||||
else
|
||||
ext[0] = '\0';
|
||||
|
||||
if ((strcmp (ext, "jpg") != 0) && (strcmp (ext, "jpeg") != 0) &&
|
||||
(strcmp (ext, "bmp") != 0) && (strcmp (ext, "gif") != 0) &&
|
||||
(strcmp (ext, "png") != 0) && (strcmp (ext, "avi") != 0))
|
||||
{
|
||||
switch (opts->imopts.format)
|
||||
{
|
||||
case LC_IMAGE_BMP: strcat(opts->filename, ".bmp"); break;
|
||||
case LC_IMAGE_GIF: strcat(opts->filename, ".gif"); break;
|
||||
case LC_IMAGE_JPG: strcat(opts->filename, ".jpg"); break;
|
||||
case LC_IMAGE_PNG: strcat(opts->filename, ".png"); break;
|
||||
case LC_IMAGE_AVI: strcat(opts->filename, ".avi"); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gtk_grab_remove (dlg);
|
||||
gtk_widget_destroy (dlg);
|
||||
|
||||
return ret;
|
||||
GtkWidget* dlg;
|
||||
int ret;
|
||||
|
||||
dlg = gtk_file_chooser_dialog_new("Save Picture", GTK_WINDOW(((GtkWidget*)*main_window)), GTK_FILE_CHOOSER_ACTION_SAVE,
|
||||
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, GTK_RESPONSE_OK, NULL);
|
||||
|
||||
gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dlg), TRUE);
|
||||
// gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dlg), filename);
|
||||
|
||||
GtkWidget* hbox = gtk_hbox_new(FALSE, 10);
|
||||
gtk_widget_show(hbox);
|
||||
gtk_file_chooser_set_extra_widget(GTK_FILE_CHOOSER(dlg), hbox);
|
||||
|
||||
GtkWidget* button = gtk_button_new_with_label ("Image Options");
|
||||
gtk_widget_show(button);
|
||||
// GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
||||
gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(savepicturedlg_options), param);
|
||||
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
|
||||
|
||||
unsigned long image = Sys_ProfileLoadInt ("Default", "Image Options", 1|LC_IMAGE_TRANSPARENT);
|
||||
LC_IMAGEDLG_OPTS* opts = (LC_IMAGEDLG_OPTS*)param;
|
||||
opts->width = Sys_ProfileLoadInt ("Default", "Image Width", gdk_screen_width ());
|
||||
opts->height = Sys_ProfileLoadInt ("Default", "Image Height", gdk_screen_height ());
|
||||
opts->imopts.quality = Sys_ProfileLoadInt ("Default", "JPEG Quality", 70);
|
||||
opts->imopts.interlaced = (image & LC_IMAGE_PROGRESSIVE) != 0;
|
||||
opts->imopts.transparent = (image & LC_IMAGE_TRANSPARENT) != 0;
|
||||
opts->imopts.truecolor = (image & LC_IMAGE_HIGHCOLOR) != 0;
|
||||
opts->imopts.pause = (float)Sys_ProfileLoadInt ("Default", "AVI Pause", 100)/100;
|
||||
opts->imopts.format = (unsigned char)(image & ~(LC_IMAGE_MASK));
|
||||
|
||||
if (gtk_dialog_run(GTK_DIALOG(dlg)) == GTK_RESPONSE_OK)
|
||||
{
|
||||
char* dlgfilename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dlg));
|
||||
strcpy(opts->filename, dlgfilename);
|
||||
g_free(dlgfilename);
|
||||
|
||||
char ext[5], *p;
|
||||
|
||||
if (strlen (opts->filename) == 0)
|
||||
ret = LC_CANCEL;
|
||||
|
||||
p = strrchr(opts->filename, '.');
|
||||
if (p != NULL)
|
||||
{
|
||||
strcpy (ext, p+1);
|
||||
strlwr (ext);
|
||||
}
|
||||
else
|
||||
ext[0] = '\0';
|
||||
|
||||
if ((strcmp (ext, "jpg") != 0) && (strcmp (ext, "jpeg") != 0) &&
|
||||
(strcmp (ext, "bmp") != 0) && (strcmp (ext, "gif") != 0) &&
|
||||
(strcmp (ext, "png") != 0) && (strcmp (ext, "avi") != 0))
|
||||
{
|
||||
switch (opts->imopts.format)
|
||||
{
|
||||
case LC_IMAGE_BMP: strcat(opts->filename, ".bmp"); break;
|
||||
case LC_IMAGE_GIF: strcat(opts->filename, ".gif"); break;
|
||||
case LC_IMAGE_JPG: strcat(opts->filename, ".jpg"); break;
|
||||
case LC_IMAGE_PNG: strcat(opts->filename, ".png"); break;
|
||||
case LC_IMAGE_AVI: strcat(opts->filename, ".avi"); break;
|
||||
}
|
||||
}
|
||||
|
||||
ret = LC_OK;
|
||||
}
|
||||
else
|
||||
ret = LC_CANCEL;
|
||||
|
||||
gtk_widget_destroy(dlg);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue