Revision: 1876
http://geeqie.svn.sourceforge.net/geeqie/?rev=1876&view=rev
Author: zas_
Date: 2009-12-04 20:40:02 +0000 (Fri, 04 Dec 2009)
Log Message:
-----------
Editors: disable Delete button if a .desktop file is not writeable and disable
Edit button when no entry is selected.
Modified Paths:
--------------
trunk/src/desktop_file.c
Modified: trunk/src/desktop_file.c
===================================================================
--- trunk/src/desktop_file.c 2009-12-04 19:45:09 UTC (rev 1875)
+++ trunk/src/desktop_file.c 2009-12-04 20:40:02 UTC (rev 1876)
@@ -46,6 +46,8 @@
GtkWidget *window;
GtkWidget *view;
GenericDialog *gd; /* any open confirm dialogs ? */
+ GtkWidget *delete_button;
+ GtkWidget *edit_button;
};
typedef struct _EditorWindowDel_Data EditorWindowDel_Data;
@@ -372,7 +374,28 @@
editor_window_new(DESKTOP_FILE_TEMPLATE, _("new.desktop"));
}
+static void editor_list_window_selection_changed_cb(GtkWidget *widget,
gpointer data)
+{
+ EditorListWindow *ewl = data;
+ GtkTreeSelection *sel =
gtk_tree_view_get_selection(GTK_TREE_VIEW(ewl->view));
+ GtkTreeIter iter;
+ if (gtk_tree_selection_get_selected(sel, NULL, &iter))
+ {
+ GtkTreeModel *store =
gtk_tree_view_get_model(GTK_TREE_VIEW(ewl->view));
+ gchar *path;
+
+ gtk_tree_model_get(store, &iter,
+ DESKTOP_FILE_COLUMN_PATH,
&path,
+ -1);
+
+ gtk_widget_set_sensitive(ewl->delete_button, access_file(path,
W_OK));
+ gtk_widget_set_sensitive(ewl->edit_button, TRUE);
+ g_free(path);
+ }
+
+}
+
static gint editor_list_window_sort_cb(GtkTreeModel *model, GtkTreeIter *a,
GtkTreeIter *b, gpointer data)
{
gint n = GPOINTER_TO_INT(data);
@@ -456,13 +479,17 @@
G_CALLBACK(editor_list_window_edit_cb), ewl);
gtk_container_add(GTK_CONTAINER(hbox), button);
GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
+ gtk_widget_set_sensitive(button, FALSE);
gtk_widget_show(button);
+ ewl->edit_button = button;
button = pref_button_new(NULL, GTK_STOCK_DELETE, NULL, FALSE,
G_CALLBACK(editor_list_window_delete_cb), ewl);
gtk_container_add(GTK_CONTAINER(hbox), button);
GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
+ gtk_widget_set_sensitive(button, FALSE);
gtk_widget_show(button);
+ ewl->delete_button = button;
button = pref_button_new(NULL, GTK_STOCK_CLOSE, NULL, FALSE,
G_CALLBACK(editor_list_window_close_cb), ewl);
@@ -480,6 +507,7 @@
ewl->view =
gtk_tree_view_new_with_model(GTK_TREE_MODEL(desktop_file_list));
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(ewl->view));
gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection),
GTK_SELECTION_SINGLE);
+ g_signal_connect(selection, "changed",
G_CALLBACK(editor_list_window_selection_changed_cb), ewl);
gtk_tree_view_set_enable_search(GTK_TREE_VIEW(ewl->view), FALSE);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Join us December 9, 2009 for the Red Hat Virtual Experience,
a free event focused on virtualization and cloud computing.
Attend in-depth sessions from your desk. Your couch. Anywhere.
http://p.sf.net/sfu/redhat-sfdev2dev
_______________________________________________
Geeqie-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geeqie-svn