[gtranslator] Native File Chooser for the translation memory



commit 728d07276b9fe85d9fbb01cf09529c0f2dcd88e2
Author: Daniel GarcĂ­a Moreno <danigm wadobo com>
Date:   Wed Nov 14 12:03:14 2018 +0100

    Native File Chooser for the translation memory
    
    See #37

 .../gtr-translation-memory-dialog.c                | 43 ++++++++--------------
 1 file changed, 16 insertions(+), 27 deletions(-)
---
diff --git a/src/translation-memory/gtr-translation-memory-dialog.c 
b/src/translation-memory/gtr-translation-memory-dialog.c
index 607d6338..846417e8 100644
--- a/src/translation-memory/gtr-translation-memory-dialog.c
+++ b/src/translation-memory/gtr-translation-memory-dialog.c
@@ -67,17 +67,26 @@ gtr_translation_memory_dialog_class_init (GtrTranslationMemoryDialogClass *klass
 
 /***************Translation Memory pages****************/
 static void
-response_filechooser_cb (GtkDialog                  *dialog,
-                         gint                        response_id,
-                         GtrTranslationMemoryDialog *dlg)
+on_search_button_clicked (GtkButton                  *button,
+                          GtrTranslationMemoryDialog *dlg)
 {
+  GtkFileChooserNative *native;
+  gint res;
   GtrTranslationMemoryDialogPrivate *priv = gtr_translation_memory_dialog_get_instance_private (dlg);
 
-  if (response_id == GTK_RESPONSE_YES)
+  native = gtk_file_chooser_native_new (_("Select PO directory"),
+                                        GTK_WINDOW (dlg),
+                                        GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
+                                        _("_OK"),
+                                        _("_Cancel"));
+
+  res = gtk_native_dialog_run (GTK_NATIVE_DIALOG (native));
+  if (res == GTK_RESPONSE_ACCEPT)
     {
-      gchar *filename;
+      char *filename;
+      GtkFileChooser *chooser = GTK_FILE_CHOOSER (native);
 
-      filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
+      filename = gtk_file_chooser_get_filename (chooser);
       gtk_entry_set_text (GTK_ENTRY (priv->directory_entry),
                           filename);
       g_settings_set_string (priv->tm_settings,
@@ -86,27 +95,7 @@ response_filechooser_cb (GtkDialog                  *dialog,
       g_free (filename);
     }
 
-  gtk_widget_destroy (GTK_WIDGET (dialog));
-}
-
-static void
-on_search_button_clicked (GtkButton                  *button,
-                          GtrTranslationMemoryDialog *dlg)
-{
-  GtkWidget *filechooser;
-
-  filechooser = gtk_file_chooser_dialog_new ("Select PO directory",
-                                             GTK_WINDOW (dlg),
-                                             GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
-                                             _("_Cancel"),
-                                             GTK_RESPONSE_CANCEL,
-                                             _("_OK"),
-                                             GTK_RESPONSE_YES, NULL);
-
-  g_signal_connect (GTK_DIALOG (filechooser), "response",
-                    G_CALLBACK (response_filechooser_cb), dlg);
-
-  gtk_widget_show (filechooser);
+  g_object_unref (native);
 }
 
 typedef struct _IdleData


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]