From a59301e90863983cdcff38d4da6f1d61c1c91f86 Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Mon, 29 Jul 2019 17:11:22 -0300 Subject: [PATCH] Fixing windows build. --- src/dialogs/save/save.c | 48 ++++++++++++++++-------------------------------- src/dialogs/tools.c | 6 ++++++ src/dialogs/windows/select.c | 4 ++++ src/include/internals.h | 3 +++ src/selection/windows/copy.c | 6 +++--- 5 files changed, 32 insertions(+), 35 deletions(-) diff --git a/src/dialogs/save/save.c b/src/dialogs/save/save.c index 5cda535..443b1e7 100644 --- a/src/dialogs/save/save.c +++ b/src/dialogs/save/save.c @@ -100,34 +100,7 @@ gtk_dialog_response(dialog,GTK_RESPONSE_APPLY); } - /* - static GtkFileChooserConfirmation confirm_overwrite(GtkFileChooser *chooser, V3270SaveDialog G_GNUC_UNUSED(*widget)) - { - GtkFileChooserConfirmation ret = GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME; - - GtkWidget * dialog = gtk_message_dialog_new_with_markup( - GTK_WINDOW(chooser), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_QUESTION,GTK_BUTTONS_OK_CANCEL, - "%s",_("The file already exists. Replace it?") - ); - - - if(gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_OK) - ret = GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN; - - gtk_widget_destroy(dialog); - - return ret; - - } - */ - -#ifdef WIN32 -static void select_local_file(GtkButton G_GNUC_UNUSED(*button), V3270SaveDialog *widget) { -#else -static void icon_press(G_GNUC_UNUSED GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconPosition icon_pos, G_GNUC_UNUSED GdkEvent *event, V3270SaveDialog *widget) { -#endif // WIN32 + static void icon_press(G_GNUC_UNUSED GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconPosition icon_pos, G_GNUC_UNUSED GdkEvent *event, V3270SaveDialog *widget) { //gint format = gtk_combo_box_get_active(GTK_COMBO_BOX(widget->format)); //g_autofree gchar * extension = g_strconcat("*",formats[format].extension,NULL); @@ -142,6 +115,9 @@ static void icon_press(G_GNUC_UNUSED GtkEntry *entry, G_GNUC_UNUSED GtkEntryIcon NULL ); + gtk_window_set_deletable(GTK_WINDOW(dialog),FALSE); + g_signal_connect(G_OBJECT(dialog),"close",G_CALLBACK(v3270_dialog_close),NULL); + const gchar *filename = gtk_entry_get_text(GTK_ENTRY(widget->filename)); if(filename && *filename) @@ -154,10 +130,8 @@ static void icon_press(G_GNUC_UNUSED GtkEntry *entry, G_GNUC_UNUSED GtkEntryIcon gtk_widget_destroy(dialog); - } - static void V3270SaveDialog_init(V3270SaveDialog *dialog) { // 0--------1---------------------2-------3--------------------4 @@ -194,16 +168,18 @@ static void icon_press(G_GNUC_UNUSED GtkEntry *entry, G_GNUC_UNUSED GtkEntryIcon gtk_grid_attach(grid,widget,0,0,1,1); gtk_label_set_mnemonic_widget(GTK_LABEL(widget),dialog->filename); +/* #ifdef WIN32 widget = gtk_button_new_from_icon_name("document-open",GTK_ICON_SIZE_BUTTON); g_signal_connect(G_OBJECT(widget),"clicked",G_CALLBACK(select_local_file),dialog); gtk_grid_attach(grid,widget,4,0,1,1); #else +*/ gtk_entry_set_icon_from_icon_name(GTK_ENTRY(dialog->filename),GTK_ENTRY_ICON_SECONDARY,"document-open"); gtk_entry_set_icon_activatable(GTK_ENTRY(dialog->filename),GTK_ENTRY_ICON_SECONDARY,TRUE); gtk_entry_set_icon_tooltip_text(GTK_ENTRY(dialog->filename),GTK_ENTRY_ICON_SECONDARY,_("Select file")); g_signal_connect(G_OBJECT(dialog->filename),"icon-press",G_CALLBACK(icon_press),dialog); -#endif // WIN32 +// #endif // WIN32 gtk_entry_set_width_chars(GTK_ENTRY(dialog->filename),60); gtk_entry_set_max_length(GTK_ENTRY(dialog->filename),PATH_MAX); @@ -261,6 +237,7 @@ static void icon_press(G_GNUC_UNUSED GtkEntry *entry, G_GNUC_UNUSED GtkEntryIcon gtk_grid_attach(grid,widget,2,1,1,1); dialog->format = gtk_combo_box_text_new(); + gtk_grid_attach(grid,dialog->format,3,1,1,1); for(ix=0;ix #include #include #include @@ -159,6 +160,9 @@ gchar * v3270_select_file(GtkWidget *widget, const gchar *title, const gchar *bu NULL ); + gtk_window_set_deletable(GTK_WINDOW(dialog),FALSE); + g_signal_connect(G_OBJECT(chooser),"close",G_CALLBACK(v3270_dialog_close),NULL); + if(filename && *filename) gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(chooser),filename); diff --git a/src/include/internals.h b/src/include/internals.h index 2f91781..7c4d70b 100644 --- a/src/include/internals.h +++ b/src/include/internals.h @@ -105,6 +105,9 @@ G_GNUC_INTERNAL GtkWidget * v3270_dialog_create_grid(GtkAlign align); G_GNUC_INTERNAL GtkWidget * v3270_dialog_create_frame(GtkWidget * child, const gchar *title); + G_GNUC_INTERNAL void v3270_dialog_close(GtkDialog *dialog, gpointer user_data); + + #if GTK_CHECK_VERSION(3,12,0) G_GNUC_INTERNAL GtkHeaderBar * v3270_dialog_get_header_bar(GtkWidget * widget); G_GNUC_INTERNAL void v3270_dialog_cancel(GtkButton G_GNUC_UNUSED(*button), GtkWidget *dialog); diff --git a/src/selection/windows/copy.c b/src/selection/windows/copy.c index 045ee10..c1ee344 100644 --- a/src/selection/windows/copy.c +++ b/src/selection/windows/copy.c @@ -57,14 +57,14 @@ static void clipboard_get(G_GNUC_UNUSED GtkClipboard *clipboard, GtkSelectionDa { case CLIPBOARD_TYPE_TEXT: // Get clipboard contents as text { - g_autofree gchar *text = v3270_get_copy_as_text(terminal); + g_autofree gchar *text = v3270_get_copy_as_text(terminal,"UTF-8"); gtk_selection_data_set_text(selection,text,-1); } break; case CLIPBOARD_TYPE_CSV: { - g_autofree gchar *text = v3270_get_copy_as_table(terminal,";"); + g_autofree gchar *text = v3270_get_copy_as_table(terminal,";","UTF-8"); debug("Selection:\n%s",text); gtk_selection_data_set( selection, @@ -78,7 +78,7 @@ static void clipboard_get(G_GNUC_UNUSED GtkClipboard *clipboard, GtkSelectionDa case CLIPBOARD_TYPE_HTML: { - g_autofree gchar *text = v3270_get_copy_as_html(terminal); + g_autofree gchar *text = v3270_get_copy_as_html(terminal,"UTF-8"); //debug("Selection:\n%s",text); gtk_selection_data_set( selection, -- libgit2 0.21.2