Index: xfce4-session/xfce4-autostart-editor/xfae-dialog.c =================================================================== --- xfce4-session/xfce4-autostart-editor/xfae-dialog.c (revision 27257) +++ xfce4-session/xfce4-autostart-editor/xfae-dialog.c (working copy) @@ -78,8 +78,20 @@ return type; } +static void +xfae_dialog_set_text (XfaeDialog *dialog, + gchar *name, + gchar *descr, + gchar *command) +{ + if (name != NULL) + gtk_entry_set_text (GTK_ENTRY(dialog->name_entry), name); + if (descr != NULL) + gtk_entry_set_text (GTK_ENTRY (dialog->descr_entry), descr); + if (command != NULL) + gtk_entry_set_text (GTK_ENTRY (dialog->command_entry), command); +} - static void xfae_dialog_init (XfaeDialog *dialog) { @@ -117,9 +129,8 @@ GTK_FILL, GTK_FILL, 0, 0); gtk_widget_show (label); - dialog->name_entry = g_object_new (GTK_TYPE_ENTRY, - "activates-default", TRUE, - NULL); + dialog->name_entry = gtk_entry_new(); + gtk_entry_set_activates_default(GTK_ENTRY(dialog->name_entry), TRUE); g_signal_connect_swapped (G_OBJECT (dialog->name_entry), "notify::text", G_CALLBACK (xfae_dialog_update), dialog); gtk_table_attach (GTK_TABLE (table), dialog->name_entry, 1, 2, 0, 1, @@ -235,9 +246,13 @@ * Return value: the newly allocated #XfaeDialog. **/ GtkWidget* -xfae_dialog_new (void) +xfae_dialog_new (gchar *name, + gchar *descr, + gchar *command) { - return g_object_new (XFAE_TYPE_DIALOG, NULL); + GtkWidget *dialog = g_object_new (XFAE_TYPE_DIALOG, NULL); + xfae_dialog_set_text(XFAE_DIALOG(dialog),name,descr,command); + return dialog; } @@ -271,5 +286,3 @@ g_strstrip (*descr); g_strstrip (*command); } - - Index: xfce4-session/xfce4-autostart-editor/xfae-model.c =================================================================== --- xfce4-session/xfce4-autostart-editor/xfae-model.c (revision 27257) +++ xfce4-session/xfce4-autostart-editor/xfae-model.c (working copy) @@ -685,7 +685,39 @@ } +void +xfae_model_get_info (XfaeModel *model, + GtkTreeIter *iter, + gchar *name, + gchar *description, + gchar *command, + GError **error) +{ + XfaeItem *item; + XfceRc *rc; + GList *lp; + const gchar *value; + g_return_val_if_fail (XFAE_IS_MODEL (model), FALSE); + g_return_val_if_fail (iter->stamp == model->stamp, FALSE); + g_return_val_if_fail (error == NULL || *error == NULL, FALSE); + + lp = iter->user_data; + item = lp->data; + + /* try to open the resource config */ + rc = xfce_rc_config_open (XFCE_RESOURCE_CONFIG, item->relpath, FALSE); + value = xfce_rc_read_entry(rc, "Name", "name"); + g_snprintf(name, 99, "%s", value); + + value = xfce_rc_read_entry(rc, "Comment", "desc"); + g_snprintf(description, 99, "%s", value); + + value = xfce_rc_read_entry(rc, "Exec", "cmd"); + g_snprintf(command, 99, "%s", value); + xfce_rc_close(rc); +} + /** * xfae_model_remove: * @model : a #XfaeModel. @@ -783,7 +815,3 @@ return TRUE; } - - - - Index: xfce4-session/xfce4-autostart-editor/xfae-dialog.h =================================================================== --- xfce4-session/xfce4-autostart-editor/xfae-dialog.h (revision 27257) +++ xfce4-session/xfce4-autostart-editor/xfae-dialog.h (working copy) @@ -38,7 +38,9 @@ GType xfae_dialog_get_type (void) G_GNUC_CONST; -GtkWidget *xfae_dialog_new (void); +GtkWidget *xfae_dialog_new (gchar *name, + gchar *descr, + gchar *command); void xfae_dialog_get (XfaeDialog *dialog, gchar **name, Index: xfce4-session/xfce4-autostart-editor/xfae-model.h =================================================================== --- xfce4-session/xfce4-autostart-editor/xfae-model.h (revision 27257) +++ xfce4-session/xfce4-autostart-editor/xfae-model.h (working copy) @@ -61,6 +61,13 @@ const gchar *command, GError **error); +void xfae_model_get_info (XfaeModel *model, + GtkTreeIter *iter, + gchar *name, + gchar *description, + gchar *command, + GError **error); + gboolean xfae_model_remove (XfaeModel *model, GtkTreeIter *iter, GError **error); Index: xfce4-session/xfce4-autostart-editor/xfae-window.c =================================================================== --- xfce4-session/xfce4-autostart-editor/xfae-window.c (revision 27257) +++ xfce4-session/xfce4-autostart-editor/xfae-window.c (working copy) @@ -32,6 +32,7 @@ static void xfae_window_class_init (XfaeWindowClass *klass); static void xfae_window_init (XfaeWindow *window); static void xfae_window_add (XfaeWindow *window); +static void xfae_window_edit (XfaeWindow *window); static void xfae_window_remove (XfaeWindow *window); static gboolean xfae_window_button_press_event (GtkWidget *treeview, GdkEventButton *event, @@ -206,6 +207,14 @@ gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 0); gtk_widget_show (button); + button = gtk_button_new_from_stock (GTK_STOCK_EDIT); + g_signal_connect_swapped (G_OBJECT (button), "clicked", + G_CALLBACK (xfae_window_edit), window); + g_signal_connect (G_OBJECT (selection), "changed", + G_CALLBACK (xfae_window_selection_changed), button); + gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 0); + gtk_widget_show (button); + button = gtk_button_new_from_stock (GTK_STOCK_CLOSE); g_signal_connect_swapped (G_OBJECT (button), "clicked", G_CALLBACK (gtk_widget_destroy), window); @@ -250,6 +259,13 @@ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show (item); + item = gtk_image_menu_item_new_from_stock (GTK_STOCK_EDIT, NULL); + g_signal_connect_swapped (G_OBJECT (item), "activate", + G_CALLBACK (xfae_window_edit), window); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + gtk_widget_set_sensitive (item, removable); + gtk_widget_show (item); + item = gtk_image_menu_item_new_from_stock (GTK_STOCK_REMOVE, NULL); g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (xfae_window_remove), window); @@ -290,7 +306,7 @@ gchar *descr; gchar *command; - dialog = xfae_dialog_new (); + dialog = xfae_dialog_new (NULL, NULL, NULL); gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (window)); if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) { @@ -312,8 +328,54 @@ gtk_widget_destroy (dialog); } +static void +xfae_window_edit (XfaeWindow *window) +{ + GtkTreeSelection *selection; + GtkTreeModel *model; + GtkTreeIter iter; + GError *error = NULL; + GtkWidget *dialog; + gchar *name; + gchar *desc; + gchar *cmd; + name = g_malloc0(100); + desc = g_malloc0(100); + cmd = g_malloc0(100); + + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (window->treeview)); + if (gtk_tree_selection_get_selected (selection, &model, &iter)) + { + xfae_model_get_info(XFAE_MODEL (model), &iter, name, desc, cmd, &error); + dialog = xfae_dialog_new (name,desc,cmd); + gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (window)); + if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) + { + + gtk_widget_hide (dialog); + xfae_dialog_get (XFAE_DIALOG (dialog), &name, &desc, &cmd); + + if (!xfae_model_remove (XFAE_MODEL (model), &iter, &error)) + { + xfce_err (error->message); + g_error_free (error); + } + model = gtk_tree_view_get_model (GTK_TREE_VIEW (window->treeview)); + if (!xfae_model_add (XFAE_MODEL (model), name, desc, cmd, &error)) + { + xfce_err (error->message); + g_error_free (error); + } + g_free(name); + g_free(desc); + g_free(cmd); + } + gtk_widget_destroy(dialog); + } +} + static void xfae_window_remove (XfaeWindow *window) {