Commit a7ce4605007565ae717aa20117278e14b40c9a16

Authored by Perry Werneck
1 parent f2ab533a

Removing windows native dialog.

Showing 2 changed files with 4 additions and 189 deletions   Show diff stats
src/include/pw3270.h
@@ -84,8 +84,6 @@ @@ -84,8 +84,6 @@
84 84
85 LIB3270_EXPORT gchar * pw3270_get_datadir(const gchar *first_element, ...); 85 LIB3270_EXPORT gchar * pw3270_get_datadir(const gchar *first_element, ...);
86 86
87 - LIB3270_EXPORT gchar * pw3270_file_chooser(GtkFileChooserAction action, const gchar *name, const gchar *title, const gchar *file);  
88 -  
89 LIB3270_EXPORT void pw3270_set_host_charset(GtkWidget *widget, const gchar *name); 87 LIB3270_EXPORT void pw3270_set_host_charset(GtkWidget *widget, const gchar *name);
90 LIB3270_EXPORT void pw3270_remap_from_xml(GtkWidget *widget, const gchar *name); 88 LIB3270_EXPORT void pw3270_remap_from_xml(GtkWidget *widget, const gchar *name);
91 89
src/pw3270/dialog.c
@@ -275,14 +275,6 @@ @@ -275,14 +275,6 @@
275 } 275 }
276 else 276 else
277 { 277 {
278 -#ifdef _WIN32  
279 - gchar *name = pw3270_file_chooser(GTK_FILE_CHOOSER_ACTION_SAVE, "save_contents", gettext(user_title ? user_title : title), filename);  
280 - if(name)  
281 - {  
282 - save_text(toplevel,name,text,NULL,errmsg);  
283 - g_free(name);  
284 - }  
285 -#else  
286 GtkWidget * dialog; 278 GtkWidget * dialog;
287 gchar * ptr; 279 gchar * ptr;
288 gchar * encattr = NULL; 280 gchar * encattr = NULL;
@@ -323,7 +315,6 @@ @@ -323,7 +315,6 @@
323 315
324 trace("Removing dialog %p",dialog); 316 trace("Removing dialog %p",dialog);
325 gtk_widget_destroy(dialog); 317 gtk_widget_destroy(dialog);
326 -#endif // _WIN32  
327 } 318 }
328 319
329 return 0; 320 return 0;
@@ -423,37 +414,14 @@ @@ -423,37 +414,14 @@
423 414
424 void paste_file_action(GtkAction *action, GtkWidget *widget) 415 void paste_file_action(GtkAction *action, GtkWidget *widget)
425 { 416 {
426 - const gchar * name = g_object_get_data(G_OBJECT(action),"filename");  
427 - const gchar * charset = g_object_get_data(G_OBJECT(action),"charset");  
428 -  
429 - trace("Action %s activated on widget %p",gtk_action_get_name(action),widget);  
430 -  
431 - if(name) {  
432 -  
433 - // Tem nome pre-definido, colca direto  
434 - paste_filename(widget,name,charset);  
435 - return;  
436 -  
437 - }  
438 -  
439 -  
440 - gchar * filename = pw3270_file_chooser( GTK_FILE_CHOOSER_ACTION_OPEN,  
441 - "paste",  
442 - g_object_get_data(G_OBJECT(action),"title"),  
443 - name  
444 - );  
445 -  
446 - if(filename) {  
447 - paste_filename(widget,filename,charset);  
448 - g_free(filename);  
449 - }  
450 -  
451 - /*  
452 const gchar * user_title = g_object_get_data(G_OBJECT(action),"title"); 417 const gchar * user_title = g_object_get_data(G_OBJECT(action),"title");
453 const gchar * filename = g_object_get_data(G_OBJECT(action),"filename"); 418 const gchar * filename = g_object_get_data(G_OBJECT(action),"filename");
454 - gchar * encattr = NULL;g_get_charset(&encoding) 419 + gchar * encattr = NULL;
455 GtkWidget * dialog; 420 GtkWidget * dialog;
456 gchar * ptr; 421 gchar * ptr;
  422 + const gchar * encoding = NULL;
  423 +
  424 + g_get_charset(&encoding);
457 425
458 trace("Action %s activated on widget %p",gtk_action_get_name(action),widget); 426 trace("Action %s activated on widget %p",gtk_action_get_name(action),widget);
459 427
@@ -497,7 +465,6 @@ @@ -497,7 +465,6 @@
497 465
498 if(encattr) 466 if(encattr)
499 g_free(encattr); 467 g_free(encattr);
500 - */  
501 } 468 }
502 469
503 G_GNUC_INTERNAL void about_dialog_action(GtkAction *action, GtkWidget *widget) 470 G_GNUC_INTERNAL void about_dialog_action(GtkAction *action, GtkWidget *widget)
@@ -579,153 +546,3 @@ @@ -579,153 +546,3 @@
579 g_free(info); 546 g_free(info);
580 } 547 }
581 548
582 -#ifdef _WIN32  
583 -static gpointer select_file(struct file *fl) {  
584 -  
585 -  
586 - switch(fl->action) {  
587 - case GTK_FILE_CHOOSER_ACTION_SAVE: // Receber arquivo  
588 - // https://msdn.microsoft.com/en-us/library/windows/desktop/ms646839(v=vs.85).aspx  
589 - // https://msdn.microsoft.com/en-us/library/windows/desktop/ms646829(v=vs.85).aspx#open_file  
590 - fl->ofn.Flags = OFN_OVERWRITEPROMPT | OFN_CREATEPROMPT | OFN_HIDEREADONLY;  
591 - fl->ok = GetSaveFileName(&fl->ofn);  
592 - break;  
593 -  
594 - case GTK_FILE_CHOOSER_ACTION_OPEN: // Enviar arquivo  
595 - // https://msdn.microsoft.com/en-us/library/windows/desktop/ms646928(v=vs.85).aspx  
596 - fl->ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;  
597 - fl->ok = GetOpenFileName(&fl->ofn);  
598 - break;  
599 - }  
600 -  
601 - fl->enabled = FALSE;  
602 -  
603 - return 0;  
604 -}  
605 -#endif // _WIN32  
606 -  
607 - LIB3270_EXPORT gchar * pw3270_file_chooser(GtkFileChooserAction action, const gchar *name, const gchar *title, const gchar *file)  
608 - {  
609 - gchar * filename = NULL;  
610 -  
611 -#if defined(_WIN32)  
612 -  
613 - GThread * thd;  
614 - struct file fl;  
615 - GtkWidget * dialog = pw3270_get_toplevel();  
616 - GdkWindow * win = gtk_widget_get_window(GTK_WIDGET(dialog));  
617 -  
618 - gtk_widget_set_sensitive(GTK_WIDGET(dialog),FALSE);  
619 -  
620 - memset(&fl,0,sizeof(fl));  
621 - fl.ofn.lStructSize = sizeof(fl.ofn);  
622 - fl.action = action;  
623 - fl.ofn.hwndOwner = GDK_WINDOW_HWND(win);  
624 - fl.ofn.lpstrFile = fl.szName;  
625 - fl.ofn.lpstrTitle = title;  
626 -  
627 - // Set lpstrFile[0] to '\0' so that GetOpenFileName does not  
628 - // use the contents of szFile to initialize itself.  
629 - fl.ofn.lpstrFile[0] = '\0';  
630 - fl.ofn.nMaxFile = sizeof(fl.szName);  
631 -  
632 - fl.ofn.lpstrInitialDir = NULL;  
633 - fl.ofn.nMaxFileTitle = 0;  
634 -  
635 - // Guarda o valor atual  
636 - if(file && *file)  
637 - {  
638 - strncpy(fl.szName,file,fl.ofn.nMaxFile);  
639 - }  
640 - else  
641 - {  
642 - gchar *ptr = get_string_from_config("files",name,"");  
643 - if(*ptr)  
644 - strncpy(fl.szName,ptr,fl.ofn.nMaxFile);  
645 - else  
646 - fl.ofn.lpstrInitialDir = g_get_user_special_dir(G_USER_DIRECTORY_DOCUMENTS);  
647 - g_free(ptr);  
648 - }  
649 -  
650 - thd = g_thread_new("GetFileName",(GThreadFunc) select_file, &fl);  
651 -  
652 - fl.enabled = TRUE;  
653 - while(fl.enabled) {  
654 - g_main_context_iteration(NULL,TRUE);  
655 - }  
656 -  
657 - g_thread_unref(thd);  
658 -  
659 - if(fl.ok) {  
660 - filename = g_strdup(fl.szName);  
661 - }  
662 -  
663 - gtk_widget_set_sensitive(GTK_WIDGET(dialog),TRUE);  
664 -  
665 -#else  
666 - static const struct _btn  
667 - {  
668 - const gchar * button;  
669 - GtkFileChooserAction action;  
670 - } btn[] =  
671 - {  
672 - { GTK_STOCK_OPEN, GTK_FILE_CHOOSER_ACTION_OPEN },  
673 - { GTK_STOCK_SAVE, GTK_FILE_CHOOSER_ACTION_SAVE },  
674 - { GTK_STOCK_OK, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER },  
675 - { GTK_STOCK_OK, GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER }  
676 - };  
677 -  
678 - GtkWidget * dialog;  
679 - gchar * ptr;  
680 - const gchar * button = GTK_STOCK_OK;  
681 - int f;  
682 -  
683 - for(f=0;f<G_N_ELEMENTS(btn);f++)  
684 - {  
685 - if(action == btn[f].action)  
686 - {  
687 - button = btn[f].button;  
688 - break;  
689 - }  
690 - }  
691 -  
692 - dialog = gtk_file_chooser_dialog_new( title,  
693 - GTK_WINDOW(pw3270_get_toplevel()),  
694 - action,  
695 - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,  
696 - button, GTK_RESPONSE_ACCEPT,  
697 - NULL );  
698 -  
699 - if(action == GTK_FILE_CHOOSER_ACTION_SAVE)  
700 - {  
701 - gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), TRUE);  
702 - g_signal_connect(GTK_FILE_CHOOSER(dialog), "confirm-overwrite", G_CALLBACK(confirm_overwrite), G_OBJECT(dialog));  
703 - }  
704 -  
705 - if(file && *file)  
706 - {  
707 - gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog),file);  
708 - }  
709 - else  
710 - {  
711 - ptr = get_string_from_config("files",name,"");  
712 - if(*ptr)  
713 - gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog),ptr);  
714 - else  
715 - gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog),g_get_user_special_dir(G_USER_DIRECTORY_DOCUMENTS));  
716 - g_free(ptr);  
717 - }  
718 -  
719 - if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)  
720 - {  
721 - filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));  
722 - }  
723 -  
724 - gtk_widget_destroy(dialog);  
725 -#endif // _WIN32  
726 -  
727 - if(filename && *filename)  
728 - set_string_to_config("files",name,"%s",filename);  
729 -  
730 - return filename;  
731 - }