[gnome-session] [capplet] Make GspApp independent of GTK+
- From: Vincent Untz <vuntz src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-session] [capplet] Make GspApp independent of GTK+
- Date: Wed, 24 Jun 2009 13:55:30 +0000 (UTC)
commit 4c87949443e9c9bc525484ef6a5713c4fd1410e4
Author: Vincent Untz <vuntz gnome org>
Date: Tue Jun 23 14:17:39 2009 +0200
[capplet] Make GspApp independent of GTK+
This mainly involved putting some code to edit the app back to
gsm-properties-dialog.c.
capplet/gsm-properties-dialog.c | 22 ++++++++-
capplet/gsp-app.c | 100 +++++++++++++++++++++------------------
capplet/gsp-app.h | 12 ++++-
3 files changed, 83 insertions(+), 51 deletions(-)
---
diff --git a/capplet/gsm-properties-dialog.c b/capplet/gsm-properties-dialog.c
index 874ccdf..db411f9 100644
--- a/capplet/gsm-properties-dialog.c
+++ b/capplet/gsm-properties-dialog.c
@@ -309,7 +309,7 @@ static void
on_add_app_clicked (GtkWidget *widget,
GsmPropertiesDialog *dialog)
{
- GtkWidget *add_dialog;
+ GtkWidget *add_dialog;
char *name;
char *exec;
char *comment;
@@ -374,7 +374,25 @@ on_edit_app_clicked (GtkWidget *widget,
-1);
if (app) {
- gsp_app_edit (app, GTK_WINDOW (dialog));
+ GtkWidget *edit_dialog;
+ char *name;
+ char *exec;
+ char *comment;
+
+ edit_dialog = gsm_app_dialog_new (gsp_app_get_name (app),
+ gsp_app_get_exec (app),
+ gsp_app_get_comment (app));
+ gtk_window_set_transient_for (GTK_WINDOW (edit_dialog),
+ GTK_WINDOW (dialog));
+
+ if (gsm_app_dialog_run (GSM_APP_DIALOG (edit_dialog),
+ &name, &exec, &comment)) {
+ gsp_app_update (app, name, comment, exec);
+ g_free (name);
+ g_free (exec);
+ g_free (comment);
+ }
+
g_object_unref (app);
}
}
diff --git a/capplet/gsp-app.c b/capplet/gsp-app.c
index 165cf31..dd4beef 100644
--- a/capplet/gsp-app.c
+++ b/capplet/gsp-app.c
@@ -529,6 +529,30 @@ gsp_app_set_enabled (GspApp *app,
}
const char *
+gsp_app_get_name (GspApp *app)
+{
+ g_return_val_if_fail (GSP_IS_APP (app), NULL);
+
+ return app->priv->name;
+}
+
+const char *
+gsp_app_get_exec (GspApp *app)
+{
+ g_return_val_if_fail (GSP_IS_APP (app), NULL);
+
+ return app->priv->exec;
+}
+
+const char *
+gsp_app_get_comment (GspApp *app)
+{
+ g_return_val_if_fail (GSP_IS_APP (app), NULL);
+
+ return app->priv->comment;
+}
+
+const char *
gsp_app_get_icon_name (GspApp *app)
{
g_return_val_if_fail (GSP_IS_APP (app), NULL);
@@ -582,61 +606,45 @@ gsp_app_get_description (GspApp *app)
*/
void
-gsp_app_edit (GspApp *app,
- GtkWindow *parent)
+gsp_app_update (GspApp *app,
+ const char *name,
+ const char *comment,
+ const char *exec)
{
- GtkWidget *dialog;
- char *name;
- char *exec;
- char *comment;
gboolean changed;
g_return_if_fail (GSP_IS_APP (app));
- dialog = gsm_app_dialog_new (app->priv->name,
- app->priv->exec,
- app->priv->comment);
- gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
-
- if (gsm_app_dialog_run (GSM_APP_DIALOG (dialog),
- &name, &exec, &comment)) {
- changed = FALSE;
+ changed = FALSE;
- if (!_gsp_str_equal (name, app->priv->name)) {
- changed = TRUE;
- g_free (app->priv->name);
- app->priv->name = name;
- app->priv->save_mask |= GSP_ASP_SAVE_MASK_NAME;
- } else {
- g_free (name);
- }
+ if (!_gsp_str_equal (name, app->priv->name)) {
+ changed = TRUE;
+ g_free (app->priv->name);
+ app->priv->name = g_strdup (name);
+ app->priv->save_mask |= GSP_ASP_SAVE_MASK_NAME;
+ }
- if (!_gsp_str_equal (comment, app->priv->comment)) {
- changed = TRUE;
- g_free (app->priv->comment);
- app->priv->comment = comment;
- app->priv->save_mask |= GSP_ASP_SAVE_MASK_COMMENT;
- } else {
- g_free (comment);
- }
+ if (!_gsp_str_equal (comment, app->priv->comment)) {
+ changed = TRUE;
+ g_free (app->priv->comment);
+ app->priv->comment = g_strdup (comment);
+ app->priv->save_mask |= GSP_ASP_SAVE_MASK_COMMENT;
+ }
- if (changed) {
- _gsp_app_update_description (app);
- }
+ if (changed) {
+ _gsp_app_update_description (app);
+ }
- if (!_gsp_str_equal (exec, app->priv->exec)) {
- changed = TRUE;
- g_free (app->priv->exec);
- app->priv->exec = exec;
- app->priv->save_mask |= GSP_ASP_SAVE_MASK_EXEC;
- } else {
- g_free (exec);
- }
+ if (!_gsp_str_equal (exec, app->priv->exec)) {
+ changed = TRUE;
+ g_free (app->priv->exec);
+ app->priv->exec = g_strdup (exec);
+ app->priv->save_mask |= GSP_ASP_SAVE_MASK_EXEC;
+ }
- if (changed) {
- _gsp_app_queue_save (app);
- _gsp_app_emit_changed (app);
- }
+ if (changed) {
+ _gsp_app_queue_save (app);
+ _gsp_app_emit_changed (app);
}
}
diff --git a/capplet/gsp-app.h b/capplet/gsp-app.h
index 9ab85bf..77716f7 100644
--- a/capplet/gsp-app.h
+++ b/capplet/gsp-app.h
@@ -25,7 +25,7 @@
#define __GSP_APP_H
#include <glib-object.h>
-#include <gtk/gtk.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
G_BEGIN_DECLS
@@ -61,11 +61,13 @@ GType gsp_app_get_type (void);
void gsp_app_create (const char *name,
const char *comment,
const char *exec);
+void gsp_app_update (GspApp *app,
+ const char *name,
+ const char *comment,
+ const char *exec);
gboolean gsp_app_copy_desktop_file (const char *uri);
-void gsp_app_edit (GspApp *app,
- GtkWindow *parent);
void gsp_app_delete (GspApp *app);
const char *gsp_app_get_basename (GspApp *app);
@@ -76,6 +78,10 @@ gboolean gsp_app_get_enabled (GspApp *app);
void gsp_app_set_enabled (GspApp *app,
gboolean enabled);
+const char *gsp_app_get_name (GspApp *app);
+const char *gsp_app_get_exec (GspApp *app);
+const char *gsp_app_get_comment (GspApp *app);
+
const char *gsp_app_get_description (GspApp *app);
const char *gsp_app_get_icon_name (GspApp *app);
GdkPixbuf *gsp_app_get_pixbuf (GspApp *app);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]