[gnome-todo] todo.txt: improve preferences panel



commit 828276de2a69aa474259f1ed0257c1ec1742bde1
Author: Rohit Kaushik <kaushikrohit325 gmail com>
Date:   Thu Apr 6 23:23:03 2017 +0530

    todo.txt: improve preferences panel
    
    Currently todo.txt uses GtkFileChooser Widget as preference panel
    which allows user to select the todo.txt file.
    
    The problem is GtkFileChooser has no option to show what todo.txt
    file user has currently choosen, creating confusion and ambiguity.
    
    The fix is to use a GtkFileChooserButton in a box as the preferences
    panel, where the button displays the file user has already chosen
    and hence preventing user from choosing the same todo.txt file again
    and also it is lot more clear and meaningul than just a FileChooser
    Dialog.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=780985

 plugins/todo-txt/gtd-plugin-todo-txt.c |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)
---
diff --git a/plugins/todo-txt/gtd-plugin-todo-txt.c b/plugins/todo-txt/gtd-plugin-todo-txt.c
index b4d0dc9..edaa9d6 100644
--- a/plugins/todo-txt/gtd-plugin-todo-txt.c
+++ b/plugins/todo-txt/gtd-plugin-todo-txt.c
@@ -405,7 +405,7 @@ gtd_plugin_todo_txt_class_init (GtdPluginTodoTxtClass *klass)
 static void
 gtd_plugin_todo_txt_init (GtdPluginTodoTxt *self)
 {
-  GtkWidget *label, *frame;
+  GtkWidget *label;
 
   self->settings = g_settings_new ("org.gnome.todo.plugins.todo-txt");
   self->providers = NULL;
@@ -418,17 +418,24 @@ gtd_plugin_todo_txt_init (GtdPluginTodoTxt *self)
                                         "orientation", GTK_ORIENTATION_VERTICAL,
                                         NULL);
   label = gtk_label_new (_("Select a Todo.txt-formatted file:"));
-  frame = gtk_frame_new (NULL);
-  self->preferences = gtk_file_chooser_widget_new (GTK_FILE_CHOOSER_ACTION_SAVE);
+  self->preferences = gtk_file_chooser_button_new (_("Select a file"),
+                                                   GTK_FILE_CHOOSER_ACTION_OPEN);
 
+  gtk_widget_set_size_request (GTK_WIDGET (self->preferences_box),
+                               300,
+                               0);
   gtk_container_add (GTK_CONTAINER (self->preferences_box), label);
-  gtk_container_add (GTK_CONTAINER (self->preferences_box), frame);
-  gtk_container_add (GTK_CONTAINER (frame), self->preferences);
+  gtk_container_add (GTK_CONTAINER (self->preferences_box), self->preferences);
+
+  gtk_widget_set_halign (GTK_WIDGET (self->preferences_box),
+                         GTK_ALIGN_CENTER);
+  gtk_widget_set_valign (GTK_WIDGET (self->preferences_box),
+                         GTK_ALIGN_CENTER);
 
   gtk_widget_show_all (self->preferences_box);
 
   g_signal_connect (self->preferences,
-                    "file-activated",
+                    "file-set",
                     G_CALLBACK (gtd_plugin_todo_txt_source_changed_cb),
                     self);
 }


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