192 lines
7.5 KiB
Diff
192 lines
7.5 KiB
Diff
|
--- gnome-session-2.15.91/gnome-session/startup-programs.c.desensitize-invalid-buttons 2006-08-14 13:59:45.000000000 -0400
|
||
|
+++ gnome-session-2.15.91/gnome-session/startup-programs.c 2006-08-14 14:01:23.000000000 -0400
|
||
|
@@ -22,6 +22,7 @@
|
||
|
#include <config.h>
|
||
|
#include <ctype.h>
|
||
|
#include <stdlib.h>
|
||
|
+#include <unistd.h>
|
||
|
#include <glib/gstdio.h>
|
||
|
#include <gnome.h>
|
||
|
#include <libgnome/gnome-desktop-item.h>
|
||
|
@@ -541,6 +542,48 @@ startup_list_delete (GSList **sl, GtkTre
|
||
|
spc_write_state ();
|
||
|
}
|
||
|
|
||
|
+gboolean
|
||
|
+startup_list_can_edit (GSList **sl, GtkTreeModel *model, GtkTreeSelection *sel)
|
||
|
+{
|
||
|
+ ManualClient *client;
|
||
|
+ GtkTreeIter iter;
|
||
|
+ char *path, *basename;
|
||
|
+ const char * const * system_dirs;
|
||
|
+ int i;
|
||
|
+ gboolean can_edit = TRUE;
|
||
|
+
|
||
|
+ if (!gtk_tree_selection_get_selected (sel, NULL, &iter)) return FALSE;
|
||
|
+
|
||
|
+ gtk_tree_model_get (model, &iter, 0, &client, -1);
|
||
|
+
|
||
|
+ if (g_file_test (client->desktop_file, G_FILE_TEST_EXISTS) &&
|
||
|
+ access (client->desktop_file, W_OK) != 0)
|
||
|
+ return FALSE;
|
||
|
+
|
||
|
+ basename = g_path_get_basename (client->desktop_file);
|
||
|
+
|
||
|
+ system_dirs = g_get_system_data_dirs ();
|
||
|
+ for (i = 0; system_dirs[i] != NULL && can_edit; i++)
|
||
|
+ {
|
||
|
+ path = g_build_filename (system_dirs[i], "gnome", "autostart", basename, NULL);
|
||
|
+ if (g_file_test (path, G_FILE_TEST_EXISTS) && access (path, W_OK) != 0)
|
||
|
+ can_edit = FALSE;
|
||
|
+ g_free (path);
|
||
|
+ }
|
||
|
+
|
||
|
+ system_dirs = g_get_system_config_dirs ();
|
||
|
+ for (i = 0; system_dirs[i] != NULL && can_edit; i++)
|
||
|
+ {
|
||
|
+ path = g_build_filename (system_dirs[i], "autostart", basename, NULL);
|
||
|
+ if (g_file_test (path, G_FILE_TEST_EXISTS) && access (path, W_OK) != 0)
|
||
|
+ can_edit = FALSE;
|
||
|
+ g_free (path);
|
||
|
+ }
|
||
|
+
|
||
|
+ g_free (basename);
|
||
|
+ return can_edit;
|
||
|
+}
|
||
|
+
|
||
|
/* Check if the selected client can be enabled */
|
||
|
gboolean
|
||
|
startup_list_can_enable (GSList **sl, GtkTreeModel *model, GtkTreeSelection *sel)
|
||
|
--- gnome-session-2.15.91/gnome-session/session-properties-capplet.c.desensitize-invalid-buttons 2006-08-14 14:02:21.000000000 -0400
|
||
|
+++ gnome-session-2.15.91/gnome-session/session-properties-capplet.c 2006-08-14 14:15:57.000000000 -0400
|
||
|
@@ -91,16 +91,14 @@ static void saved_sessions (GtkWidget *w
|
||
|
#define SESSION_STOCK_EDIT "session-stock-edit"
|
||
|
|
||
|
static void
|
||
|
-selection_changed_cb (GtkTreeSelection *selection, GtkTreeView *view)
|
||
|
+session_selection_changed_cb (GtkTreeSelection *selection, GtkTreeView *view)
|
||
|
{
|
||
|
gboolean sel;
|
||
|
GtkWidget *edit_button;
|
||
|
GtkWidget *delete_button;
|
||
|
- GtkWidget *enable_button;
|
||
|
|
||
|
edit_button = g_object_get_data (G_OBJECT (view), "edit");
|
||
|
delete_button = g_object_get_data (G_OBJECT (view), "delete");
|
||
|
- enable_button = g_object_get_data (G_OBJECT (view), "enable");
|
||
|
|
||
|
sel = gtk_tree_selection_get_selected (selection, NULL, NULL);
|
||
|
|
||
|
@@ -109,29 +107,56 @@ selection_changed_cb (GtkTreeSelection *
|
||
|
|
||
|
if (delete_button)
|
||
|
gtk_widget_set_sensitive (delete_button, sel);
|
||
|
+}
|
||
|
+
|
||
|
+static void
|
||
|
+startup_selection_changed_cb (GtkTreeSelection *selection, GtkTreeView *view)
|
||
|
+{
|
||
|
+ gboolean sel, can_edit;
|
||
|
+ GtkWidget *edit_button;
|
||
|
+ GtkWidget *delete_button;
|
||
|
+ GtkWidget *enable_button;
|
||
|
|
||
|
- if (enable_button)
|
||
|
+ edit_button = g_object_get_data (G_OBJECT (view), "edit");
|
||
|
+ delete_button = g_object_get_data (G_OBJECT (view), "delete");
|
||
|
+ enable_button = g_object_get_data (G_OBJECT (view), "enable");
|
||
|
+
|
||
|
+ if (!edit_button || !delete_button || !enable_button)
|
||
|
+ return;
|
||
|
+
|
||
|
+ sel = gtk_tree_selection_get_selected (selection, NULL, NULL);
|
||
|
+ can_edit = startup_list_can_edit (&startup_list, startup_store, startup_sel);
|
||
|
+
|
||
|
+ if (sel && can_edit)
|
||
|
+ {
|
||
|
+ gtk_widget_set_sensitive (edit_button, TRUE);
|
||
|
+ gtk_widget_set_sensitive (delete_button, TRUE);
|
||
|
+ }
|
||
|
+ else
|
||
|
{
|
||
|
- if (sel)
|
||
|
+ gtk_widget_set_sensitive (edit_button, FALSE);
|
||
|
+ gtk_widget_set_sensitive (delete_button, FALSE);
|
||
|
+ }
|
||
|
+
|
||
|
+ if (sel)
|
||
|
+ {
|
||
|
+ if (startup_list_can_enable (&startup_list, startup_store, startup_sel))
|
||
|
{
|
||
|
- if (startup_list_can_enable (&startup_list, startup_store, startup_sel))
|
||
|
- {
|
||
|
- gtk_button_set_label (GTK_BUTTON (enable_button), _("Enable"));
|
||
|
- gtk_button_set_image (GTK_BUTTON (enable_button),
|
||
|
- gtk_image_new_from_stock (GTK_STOCK_YES, GTK_ICON_SIZE_BUTTON));
|
||
|
- }
|
||
|
- else
|
||
|
- {
|
||
|
- gtk_button_set_label (GTK_BUTTON (enable_button), _("Disable"));
|
||
|
- gtk_button_set_image (GTK_BUTTON (enable_button),
|
||
|
- gtk_image_new_from_stock (GTK_STOCK_NO, GTK_ICON_SIZE_BUTTON));
|
||
|
- }
|
||
|
-
|
||
|
- gtk_widget_set_sensitive (enable_button, TRUE);
|
||
|
+ gtk_button_set_label (GTK_BUTTON (enable_button), _("Enable"));
|
||
|
+ gtk_button_set_image (GTK_BUTTON (enable_button),
|
||
|
+ gtk_image_new_from_stock (GTK_STOCK_YES, GTK_ICON_SIZE_BUTTON));
|
||
|
}
|
||
|
else
|
||
|
- gtk_widget_set_sensitive (enable_button, FALSE);
|
||
|
+ {
|
||
|
+ gtk_button_set_label (GTK_BUTTON (enable_button), _("Disable"));
|
||
|
+ gtk_button_set_image (GTK_BUTTON (enable_button),
|
||
|
+ gtk_image_new_from_stock (GTK_STOCK_NO, GTK_ICON_SIZE_BUTTON));
|
||
|
+ }
|
||
|
+
|
||
|
+ gtk_widget_set_sensitive (enable_button, TRUE);
|
||
|
}
|
||
|
+ else
|
||
|
+ gtk_widget_set_sensitive (enable_button, FALSE);
|
||
|
}
|
||
|
|
||
|
static void
|
||
|
@@ -345,7 +370,7 @@ capplet_build (void)
|
||
|
GTK_WIDGET (sessions_view));
|
||
|
sessions_sel = gtk_tree_view_get_selection (sessions_view);
|
||
|
gtk_tree_selection_set_mode (sessions_sel, GTK_SELECTION_SINGLE);
|
||
|
- g_signal_connect (G_OBJECT (sessions_sel), "changed", (GCallback) selection_changed_cb, sessions_view);
|
||
|
+ g_signal_connect (G_OBJECT (sessions_sel), "changed", (GCallback) session_selection_changed_cb, sessions_view);
|
||
|
renderer = gtk_cell_renderer_text_new ();
|
||
|
column = gtk_tree_view_column_new_with_attributes (_("Session Name"), renderer, "text", 0, NULL);
|
||
|
gtk_tree_view_append_column (sessions_view, column);
|
||
|
@@ -433,7 +458,7 @@ capplet_build (void)
|
||
|
GTK_WIDGET (startup_view));
|
||
|
startup_sel = gtk_tree_view_get_selection (startup_view);
|
||
|
gtk_tree_selection_set_mode (startup_sel, GTK_SELECTION_SINGLE);
|
||
|
- g_signal_connect (G_OBJECT (startup_sel), "changed", (GCallback) selection_changed_cb, startup_view);
|
||
|
+ g_signal_connect (G_OBJECT (startup_sel), "changed", (GCallback) startup_selection_changed_cb, startup_view);
|
||
|
renderer = gtk_cell_renderer_text_new ();
|
||
|
column = gtk_tree_view_column_new_with_attributes (_("Command"), renderer, "text", 2, NULL);
|
||
|
gtk_tree_view_append_column (startup_view, column);
|
||
|
@@ -604,7 +629,7 @@ enable_startup_cb (void)
|
||
|
else
|
||
|
startup_list_disable (&startup_list, startup_store, startup_sel);
|
||
|
|
||
|
- selection_changed_cb (startup_sel, startup_view);
|
||
|
+ startup_selection_changed_cb (startup_sel, startup_view);
|
||
|
}
|
||
|
|
||
|
static void
|
||
|
--- gnome-session-2.15.91/gnome-session/session-properties-capplet.h.desensitize-invalid-buttons 2006-08-14 14:01:51.000000000 -0400
|
||
|
+++ gnome-session-2.15.91/gnome-session/session-properties-capplet.h 2006-08-14 14:02:09.000000000 -0400
|
||
|
@@ -34,6 +34,8 @@ void startup_list_edit_dialog (GSList **
|
||
|
void startup_list_delete (GSList **sl,
|
||
|
GtkTreeModel *model, GtkTreeSelection *sel);
|
||
|
|
||
|
+gboolean startup_list_can_edit (GSList **sl, GtkTreeModel *model, GtkTreeSelection *sel);
|
||
|
+
|
||
|
gboolean startup_list_can_enable (GSList **sl, GtkTreeModel *model, GtkTreeSelection *sel);
|
||
|
void startup_list_enable (GSList **sl, GtkTreeModel *model, GtkTreeSelection *sel);
|
||
|
void startup_list_disable (GSList **sl, GtkTreeModel *model, GtkTreeSelection *sel);
|