quick-lounge-applet r236 - in trunk: . data/ui po src
- From: paobac svn gnome org
- To: svn-commits-list gnome org
- Subject: quick-lounge-applet r236 - in trunk: . data/ui po src
- Date: Sun, 1 Feb 2009 21:46:59 +0000 (UTC)
Author: paobac
Date: Sun Feb 1 21:46:59 2009
New Revision: 236
URL: http://svn.gnome.org/viewvc/quick-lounge-applet?rev=236&view=rev
Log:
2009-02-01 Paolo Bacchilega <paobac svn gnome org>
* configure.ac: removed the gnome-desktop dependency.
* src/quick-separator.c:
* src/quick-lounge.h:
* src/quick-lounge.c:
* src/quick-button.h:
* src/quick-button.c:
* src/quick-box.h:
* src/quick-box.c:
* src/qck-desktop-entry-dialog.h: added
* src/qck-desktop-entry-dialog.c: added
* src/Makefile.am:
* src/gtk-utils.h:
* src/gtk-utils.c:
* src/gnome-ditem-edit.c: removed
* src/gnome-ditem-edit.h: removed
* src/file-utils.h:
* src/file-utils.c:
* src/dlg-properties.c:
* src/dlg-pick-applications.c:
Replaced the gnome-ditem-edit widget with a dialog similar to the one
used by gnome-panel.
* data/ui/Makefile.am:
* data/ui/desktop-entry-editor.ui: new file.
Added:
trunk/data/ui/desktop-entry-editor.ui
trunk/src/qck-desktop-entry-dialog.c
trunk/src/qck-desktop-entry-dialog.h
Removed:
trunk/src/gnome-ditem-edit.c
trunk/src/gnome-ditem-edit.h
Modified:
trunk/ChangeLog
trunk/configure.ac
trunk/data/ui/Makefile.am
trunk/po/ChangeLog
trunk/po/POTFILES.in
trunk/src/Makefile.am
trunk/src/dlg-pick-applications.c
trunk/src/dlg-properties.c
trunk/src/file-utils.c
trunk/src/file-utils.h
trunk/src/gtk-utils.c
trunk/src/gtk-utils.h
trunk/src/quick-box.c
trunk/src/quick-box.h
trunk/src/quick-button.c
trunk/src/quick-button.h
trunk/src/quick-lounge.c
trunk/src/quick-lounge.h
trunk/src/quick-separator.c
Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Sun Feb 1 21:46:59 2009
@@ -6,7 +6,7 @@
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_SRCDIR(src/quick-lounge.c)
-AM_INIT_AUTOMAKE([1.9 foreign no-dist-gzip dist-bzip2])
+AM_INIT_AUTOMAKE([1.9 foreign])
AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)
AC_PATH_PROG(GLIB_MKENUMS, glib-mkenums)
@@ -26,7 +26,6 @@
GTK_REQUIRED=2.14.0
LIBGNOME_REQUIRED=2.4.0
LIBGNOMEUI_REQUIRED=2.4.0
-LIBGNOME_DESKTOP_REQUIRED=2.4.0
LIBPANEL_REQUIRED=2.4.0
LIBGNOME_MENU_REQUIRED=2.12.0
@@ -34,7 +33,6 @@
AC_SUBST(GTK_REQUIRED)
AC_SUBST(LIBGNOME_REQUIRED)
AC_SUBST(LIBGNOMEUI_REQUIRED)
-AC_SUBST(LIBGNOME_DESKTOP_REQUIRED)
AC_SUBST(LIBPANEL_REQUIRED)
AC_SUBST(LIBGNOME_MENU_REQUIRED)
@@ -42,11 +40,12 @@
PKG_CHECK_MODULES(QL, \
glib-2.0 >= $GLIB_REQUIRED \
+ gio-2.0 \
+ gio-unix-2.0 \
gthread-2.0 \
gtk+-2.0 >= $GTK_REQUIRED \
libgnome-2.0 >= $LIBGNOME_REQUIRED \
libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED \
- gnome-desktop-2.0 >= $LIBGNOME_DESKTOP_REQUIRED \
libpanelapplet-2.0 >= $LIBPANEL_REQUIRED \
libgnome-menu >= $LIBGNOME_MENU_REQUIRED)
AC_SUBST(QL_CFLAGS)
Modified: trunk/data/ui/Makefile.am
==============================================================================
--- trunk/data/ui/Makefile.am (original)
+++ trunk/data/ui/Makefile.am Sun Feb 1 21:46:59 2009
@@ -1,6 +1,7 @@
uidir = $(datadir)/quick-lounge-applet/ui
ui_DATA = \
choose-from-menu.ui \
+ desktop-entry-editor.ui \
properties.ui
EXTRA_DIST = $(ui_DATA)
Added: trunk/data/ui/desktop-entry-editor.ui
==============================================================================
--- (empty file)
+++ trunk/data/ui/desktop-entry-editor.ui Sun Feb 1 21:46:59 2009
@@ -0,0 +1,170 @@
+<?xml version="1.0"?>
+<interface>
+ <requires lib="gtk+" version="2.14"/>
+ <!-- interface-naming-policy project-wide -->
+ <object class="GtkHBox" id="desktop_entry_editor">
+ <property name="visible">True</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkVBox" id="vbox1">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkButton" id="icon_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <child>
+ <object class="GtkImage" id="icon_image">
+ <property name="visible">True</property>
+ <property name="stock">gtk-missing-image</property>
+ <property name="icon-size">6</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkTable" id="table1">
+ <property name="visible">True</property>
+ <property name="n_rows">4</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">6</property>
+ <property name="row_spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes"><b>_Type:</b></property>
+ <property name="use_markup">True</property>
+ <property name="use_underline">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes"><b>_Name:</b></property>
+ <property name="use_markup">True</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes"><b>_Command:</b></property>
+ <property name="use_markup">True</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label4">
+ <property name="visible">True</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes"><b>C_omment:</b></property>
+ <property name="use_markup">True</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="name_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">●</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="comment_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">●</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="hbox1">
+ <property name="visible">True</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkEntry" id="exec_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">●</property>
+ <property name="invisible_char_set">True</property>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="browse_button">
+ <property name="label" translatable="yes">_Browse...</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="type_box">
+ <property name="visible">True</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+</interface>
Modified: trunk/po/POTFILES.in
==============================================================================
--- trunk/po/POTFILES.in (original)
+++ trunk/po/POTFILES.in Sun Feb 1 21:46:59 2009
@@ -2,6 +2,7 @@
data/GNOME_QuickLoungeApplet_Factory.server.in.in
data/quick-lounge.schemas.in
data/ui/choose-from-menu.ui
+data/ui/desktop-entry-editor.ui
data/ui/properties.ui
src/dlg-pick-applications.c
src/dlg-pick-applications.h
@@ -9,10 +10,10 @@
src/dlg-properties.h
src/file-utils.c
src/file-utils.h
-src/gnome-ditem-edit.c
-src/gnome-ditem-edit.h
src/gtk-utils.c
src/gtk-utils.h
+src/qck-desktop-entry-dialog.c
+src/qck-desktop-entry-dialog.h
src/quick-box.c
src/quick-box.h
src/quick-button.c
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Sun Feb 1 21:46:59 2009
@@ -2,9 +2,9 @@
-I$(top_srcdir) \
-I$(top_builddir) \
-DPREFIX=\"$(prefix)\" \
- -DSYSCONFDIR=\"$(sysconfdir)\" \
- -DDATADIR=\"$(datadir)\" \
- -DLIBDIR=\"$(libdir)\" \
+ -DSYSCONFDIR=\"$(sysconfdir)\" \
+ -DDATADIR=\"$(datadir)\" \
+ -DLIBDIR=\"$(libdir)\" \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-DUI_DIR=\"$(datadir)/quick-lounge-applet/ui\" \
-DGMENU_I_KNOW_THIS_IS_UNSTABLE \
@@ -22,6 +22,8 @@
file-utils.h \
gtk-utils.c \
gtk-utils.h \
+ qck-desktop-entry-dialog.c \
+ qck-desktop-entry-dialog.h \
quick-box.c \
quick-box.h \
quick-button.c \
@@ -32,8 +34,6 @@
quick-separator.h \
typedefs.h \
xstuff.c \
- xstuff.h \
- gnome-ditem-edit.c \
- gnome-ditem-edit.h
+ xstuff.h
quick_lounge_applet_LDADD = $(QL_LIBS) $(X_LIBS)
Modified: trunk/src/dlg-pick-applications.c
==============================================================================
--- trunk/src/dlg-pick-applications.c (original)
+++ trunk/src/dlg-pick-applications.c Sun Feb 1 21:46:59 2009
@@ -23,7 +23,6 @@
#include <config.h>
#include <string.h>
#include <gtk/gtk.h>
-#include <libgnome/gnome-desktop-item.h>
#include <gmenu-tree.h>
#include "dlg-pick-applications.h"
#include "dlg-properties.h"
@@ -77,7 +76,7 @@
help_cb (GtkWidget *widget,
DialogData *data)
{
- _gtk_show_help (GTK_WINDOW (data->dialog), "quick-lounge-usage-add-existing");
+ _gtk_show_help (GTK_WINDOW (data->dialog), "quick-lounge", "quick-lounge-usage-add-existing");
}
Modified: trunk/src/dlg-properties.c
==============================================================================
--- trunk/src/dlg-properties.c (original)
+++ trunk/src/dlg-properties.c Sun Feb 1 21:46:59 2009
@@ -34,7 +34,6 @@
#include "quick-separator.h"
#include "dlg-properties.h"
#include "dlg-pick-applications.h"
-#include "gnome-ditem-edit.h"
#define SEPARATOR_NAME _("Space")
#define ICON_SIZE 24
@@ -146,7 +145,7 @@
help_cb (GtkWidget *widget,
DialogData *data)
{
- _gtk_show_help (GTK_WINDOW (data->dialog), "quick-lounge-prefs");
+ _gtk_show_help (GTK_WINDOW (data->dialog), "quick-lounge", "quick-lounge-prefs");
}
@@ -378,9 +377,8 @@
static void
update_list (DialogData *data)
{
- GList *children, *scan;
- GtkBox *box = GTK_BOX (data->quick_box);
- GtkTreeIter select_iter;
+ GList *children, *scan;
+ GtkTreeIter select_iter;
gtk_list_store_clear (GTK_LIST_STORE (data->model));
@@ -437,7 +435,7 @@
gtk_list_store_set (GTK_LIST_STORE (data->model), &iter,
COLUMN_DATA, button,
COLUMN_ICON, pixbuf,
- COLUMN_NAME, button->text,
+ COLUMN_NAME, button->name,
-1);
g_object_unref (pixbuf);
}
@@ -621,7 +619,6 @@
GtkTreeSelection *selection;
GtkTreeIter iter;
GtkWidget *button;
- GnomeDesktopItem *ditem;
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (data->tree_view));
if (selection == NULL)
@@ -635,11 +632,8 @@
COLUMN_DATA, &button,
-1);
- ditem = g_object_get_data (G_OBJECT (button), "ditem");
- if (ditem == NULL)
- return;
-
- quick_lounge_util__item_properties (data->quick_lounge, button);
+ if (g_object_get_data (G_OBJECT (button), "desktop_entry") != NULL)
+ quick_lounge_util__item_properties (data->quick_lounge, button);
}
@@ -674,7 +668,6 @@
get_button_from_uri (QuickBox *quick_box,
const char *uri1)
{
- GtkBox *box = GTK_BOX (quick_box);
GList *children, *scan;
GtkWidget *retval = NULL;
@@ -989,7 +982,8 @@
8,
(guchar*) pos_data,
strlen (pos_data));
- } else
+ }
+ else
gtk_selection_data_set (selection_data,
selection_data->target,
8,
Modified: trunk/src/file-utils.c
==============================================================================
--- trunk/src/file-utils.c (original)
+++ trunk/src/file-utils.c Sun Feb 1 21:46:59 2009
@@ -21,6 +21,8 @@
*/
#include <config.h>
+#include <sys/types.h>
+#include <unistd.h>
#include <glib/gi18n.h>
#include "file-utils.h"
@@ -403,9 +405,9 @@
gboolean
-ensure_dir_exists (const char *uri,
- mode_t mode,
- GError **error)
+make_directory_tree_from_uri (const char *uri,
+ mode_t mode,
+ GError **error)
{
GFile *dir;
GError *priv_error = NULL;
@@ -437,7 +439,7 @@
gboolean result;
uri = g_filename_to_uri (path, NULL, NULL);
- result = ensure_dir_exists (uri, mode, error);
+ result = make_directory_tree_from_uri (uri, mode, error);
g_free (uri);
return result;
@@ -558,3 +560,100 @@
return g_list_reverse (list);
}
+
+
+gboolean
+g_write_file (GFile *file,
+ gboolean make_backup,
+ GFileCreateFlags flags,
+ void *buffer,
+ gsize count,
+ GCancellable *cancellable,
+ GError **error)
+{
+ gboolean success;
+ GOutputStream *stream;
+
+ stream = (GOutputStream *) g_file_replace (file, NULL, make_backup, flags, cancellable, error);
+ if (stream != NULL)
+ success = g_output_stream_write_all (stream, buffer, count, NULL, cancellable, error);
+ else
+ success = FALSE;
+
+ g_object_unref (stream);
+
+ return success;
+}
+
+
+GKeyFile *
+_g_key_file_dup (GKeyFile *file)
+{
+
+ GKeyFile *new_file;
+
+ new_file = g_key_file_new ();
+ if (file != NULL) {
+ char *data;
+ gsize length;
+
+ data = g_key_file_to_data (file, &length, NULL);
+ g_key_file_load_from_data (new_file, data, length, G_KEY_FILE_KEEP_TRANSLATIONS, NULL);
+
+ g_free (data);
+ }
+ else
+ g_key_file_set_string (new_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_TYPE, G_KEY_FILE_DESKTOP_TYPE_APPLICATION);
+
+ return new_file;
+}
+
+
+gboolean
+_g_desktop_entry_equal (GKeyFile *file1,
+ GKeyFile *file2)
+{
+ gboolean terminal1;
+ char *value1;
+ gboolean terminal2;
+ char *value2;
+
+ terminal1 = g_key_file_get_boolean (file1, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_TERMINAL, NULL);
+ terminal2 = g_key_file_get_boolean (file2, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_TERMINAL, NULL);
+ if (terminal1 != terminal2)
+ return FALSE;
+
+ value1 = g_key_file_get_string (file1, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_ICON, NULL);
+ value2 = g_key_file_get_string (file2, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_ICON, NULL);
+ if (g_strcmp0 (value1, value2) != 0) {
+ g_free (value1);
+ g_free (value2);
+ return FALSE;
+ }
+
+ value1 = g_key_file_get_locale_string (file1, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_NAME, NULL, NULL);
+ value2 = g_key_file_get_locale_string (file2, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_NAME, NULL, NULL);
+ if (g_strcmp0 (value1, value2) != 0) {
+ g_free (value1);
+ g_free (value2);
+ return FALSE;
+ }
+
+ value1 = g_key_file_get_string (file1, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_EXEC, NULL);
+ value2 = g_key_file_get_string (file2, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_EXEC, NULL);
+ if (g_strcmp0 (value1, value2) != 0) {
+ g_free (value1);
+ g_free (value2);
+ return FALSE;
+ }
+
+ value1 = g_key_file_get_locale_string (file1, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_COMMENT, NULL, NULL);
+ value2 = g_key_file_get_locale_string (file2, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_COMMENT, NULL, NULL);
+ if (g_strcmp0 (value1, value2) != 0) {
+ g_free (value1);
+ g_free (value2);
+ return FALSE;
+ }
+
+ return TRUE;
+}
Modified: trunk/src/file-utils.h
==============================================================================
--- trunk/src/file-utils.h (original)
+++ trunk/src/file-utils.h Sun Feb 1 21:46:59 2009
@@ -39,7 +39,7 @@
gboolean make_directory_tree (GFile *dir,
mode_t mode,
GError **error);
-gboolean ensure_dir_exists (const char *uri,
+gboolean make_directory_tree_from_uri (const char *uri,
mode_t mode,
GError **error);
gboolean make_directory_tree_from_path (const char *path,
@@ -58,5 +58,15 @@
char * get_unique_desktop_file (const char *base_dir);
gboolean is_desktop_file (const char *uri);
GList * get_file_list_from_url_list (char *url_list);
+gboolean g_write_file (GFile *file,
+ gboolean make_backup,
+ GFileCreateFlags flags,
+ void *buffer,
+ gsize count,
+ GCancellable *cancellable,
+ GError **error);
+GKeyFile * _g_key_file_dup (GKeyFile *file);
+gboolean _g_desktop_entry_equal (GKeyFile *file1,
+ GKeyFile *file2);
#endif /* FILE_UTILS_H */
Modified: trunk/src/gtk-utils.c
==============================================================================
--- trunk/src/gtk-utils.c (original)
+++ trunk/src/gtk-utils.c Sun Feb 1 21:46:59 2009
@@ -430,6 +430,20 @@
}
+
+int
+_gtk_icon_get_pixel_size (GtkWidget *widget,
+ GtkIconSize size)
+{
+ int icon_width, icon_height;
+
+ gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (widget),
+ size,
+ &icon_width, &icon_height);
+ return MAX (icon_width, icon_height);
+}
+
+
/* This function from gnome-panel/panel-util.c
* (C) 1997, 1998, 1999, 2000 The Free Software Foundation
* Copyright 2000 Helix Code, Inc.
@@ -443,10 +457,10 @@
*
* Modified by Paolo Bacchilega for the Quick Lounge applet
*/
-static char *
-panel_find_icon (GtkIconTheme *icon_theme,
- const char *icon_name,
- gint size)
+char *
+panel_find_icon (GtkIconTheme *icon_theme,
+ const char *icon_name,
+ gint size)
{
GtkIconInfo *icon_info;
char *retval;
@@ -492,8 +506,8 @@
if (icon_info) {
retval = g_strdup (gtk_icon_info_get_filename (icon_info));
gtk_icon_info_free (icon_info);
-
- } else
+ }
+ else
retval = NULL;
return retval;
@@ -501,9 +515,9 @@
GdkPixbuf *
-create_pixbuf (GtkIconTheme *icon_theme,
- const char *icon_name,
- int icon_size)
+create_pixbuf (GtkIconTheme *icon_theme,
+ const char *icon_name,
+ int icon_size)
{
char *icon_path;
GdkPixbuf *pixbuf;
@@ -548,13 +562,13 @@
GtkWidget *
create_image (GtkIconTheme *icon_theme,
- const char *icon_path,
+ const char *icon_name,
int icon_size)
{
GtkWidget *icon = NULL;
GdkPixbuf *pixbuf;
- pixbuf = create_pixbuf (icon_theme, icon_path, icon_size);
+ pixbuf = create_pixbuf (icon_theme, icon_name, icon_size);
if (pixbuf == NULL)
return NULL;
@@ -642,12 +656,13 @@
void
_gtk_show_help (GtkWindow *parent,
+ const char *manual,
const char *section)
{
char *uri;
GError *error = NULL;
- uri = g_strconcat ("ghelp:quick-lounge", section ? "?" : NULL, section, NULL);
+ uri = g_strconcat ("ghelp:", manual, section ? "?" : NULL, section, NULL);
if (! gtk_show_uri (gtk_window_get_screen (parent), uri, GDK_CURRENT_TIME, &error)) {
GtkWidget *dialog;
@@ -672,3 +687,27 @@
}
g_free (uri);
}
+
+
+GtkWidget *
+_gtk_combo_box_new_with_texts (const char *first_text,
+ ...)
+{
+ GtkWidget *combo_box;
+ va_list args;
+ const char *text;
+
+ combo_box = gtk_combo_box_new_text ();
+
+ va_start (args, first_text);
+
+ text = first_text;
+ while (text != NULL) {
+ gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), text);
+ text = va_arg (args, const char *);
+ }
+
+ va_end (args);
+
+ return combo_box;
+}
Modified: trunk/src/gtk-utils.h
==============================================================================
--- trunk/src/gtk-utils.h (original)
+++ trunk/src/gtk-utils.h Sun Feb 1 21:46:59 2009
@@ -23,7 +23,7 @@
#ifndef _GTK_UTILS_H
#define _GTK_UTILS_H
-#include <gtk/gtkwidget.h>
+#include <gtk/gtk.h>
GtkWidget * _gtk_image_new_from_xpm_data (char *xpm_data[]);
GtkWidget * _gtk_image_new_from_inline (const guint8 *data);
@@ -57,6 +57,12 @@
char * _gtk_label_get_locale_text (GtkLabel *label);
+int _gtk_icon_get_pixel_size (GtkWidget *widget,
+ GtkIconSize size);
+
+char * panel_find_icon (GtkIconTheme *icon_theme,
+ const char *icon_name,
+ int size);
GdkPixbuf * create_pixbuf (GtkIconTheme *icon_theme,
const char *icon_path,
int icon_size);
@@ -75,6 +81,9 @@
_gtk_builder_get_widget (GtkBuilder *builder,
const char *name);
void _gtk_show_help (GtkWindow *parent,
+ const char *manual,
const char *section);
-
+GtkWidget * _gtk_combo_box_new_with_texts (const char *first_text,
+ ...);
+
#endif /* _GTK_UTILS_H */
Added: trunk/src/qck-desktop-entry-dialog.c
==============================================================================
--- (empty file)
+++ trunk/src/qck-desktop-entry-dialog.c Sun Feb 1 21:46:59 2009
@@ -0,0 +1,419 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * Quick Lounge Applet
+ *
+ * Copyright (C) 2009 The Free Software Foundation, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+#include <glib/gi18n.h>
+#include "file-utils.h"
+#include "gtk-utils.h"
+#include "qck-desktop-entry-dialog.h"
+
+
+#define GET_WIDGET(name) _gtk_builder_get_widget (self->priv->builder, (name))
+
+
+enum {
+ CHANGED,
+ LAST_SIGNAL
+};
+
+static gpointer parent_class = NULL;
+static guint signals[LAST_SIGNAL] = { 0 };
+
+
+struct _QckDesktopEntryDialogPrivate {
+ GtkBuilder *builder;
+ GtkWidget *type_combobox;
+ GKeyFile *original;
+ GKeyFile *current;
+};
+
+
+static void
+qck_desktop_entry_dialog_finalize (GObject *object)
+{
+ QckDesktopEntryDialog *dialog;
+
+ dialog = QCK_DESKTOP_ENTRY_DIALOG (object);
+
+ if (dialog->priv != NULL) {
+ g_object_unref (dialog->priv->builder);
+ g_free (dialog->priv);
+ dialog->priv = NULL;
+ }
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+
+static void
+qck_desktop_entry_dialog_class_init (QckDesktopEntryDialogClass *class)
+{
+ GObjectClass *object_class;
+
+ parent_class = g_type_class_peek_parent (class);
+
+ object_class = (GObjectClass*) class;
+ object_class->finalize = qck_desktop_entry_dialog_finalize;
+
+ /* signals */
+
+ signals[CHANGED] = g_signal_new ("changed",
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (QckDesktopEntryDialogClass, changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOOLEAN,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_BOOLEAN);
+}
+
+
+static void
+qck_desktop_entry_dialog_init (QckDesktopEntryDialog *dialog)
+{
+ dialog->priv = g_new0 (QckDesktopEntryDialogPrivate, 1);
+}
+
+
+GType
+qck_desktop_entry_dialog_get_type (void)
+{
+ static GType type = 0;
+
+ if (! type) {
+ GTypeInfo type_info = {
+ sizeof (QckDesktopEntryDialogClass),
+ NULL,
+ NULL,
+ (GClassInitFunc) qck_desktop_entry_dialog_class_init,
+ NULL,
+ NULL,
+ sizeof (QckDesktopEntryDialog),
+ 0,
+ (GInstanceInitFunc) qck_desktop_entry_dialog_init
+ };
+
+ type = g_type_register_static (GTK_TYPE_DIALOG,
+ "QckDesktopEntryDialog",
+ &type_info,
+ 0);
+ }
+
+ return type;
+}
+
+
+static void
+qck_desktop_entry_dialog_changed (QckDesktopEntryDialog *self)
+{
+ g_signal_emit (self, signals[CHANGED], 0, _g_desktop_entry_equal (self->priv->current, self->priv->original));
+}
+
+
+static void
+type_combobox_changed_cb (GtkEditable *editable,
+ QckDesktopEntryDialog *self)
+{
+ g_key_file_set_boolean (self->priv->current,
+ G_KEY_FILE_DESKTOP_GROUP,
+ G_KEY_FILE_DESKTOP_KEY_NAME,
+ gtk_combo_box_get_active (GTK_COMBO_BOX (self->priv->type_combobox)) == 1);
+ qck_desktop_entry_dialog_changed (self);
+}
+
+
+static void
+name_entry_changed_cb (GtkEditable *editable,
+ QckDesktopEntryDialog *self)
+{
+ char **languages;
+
+ languages = (char **) g_get_language_names ();
+
+ g_key_file_set_locale_string (self->priv->current,
+ G_KEY_FILE_DESKTOP_GROUP,
+ G_KEY_FILE_DESKTOP_KEY_NAME,
+ languages[0],
+ gtk_entry_get_text (GTK_ENTRY (GET_WIDGET ("name_entry"))));
+ qck_desktop_entry_dialog_changed (self);
+}
+
+
+static void
+exec_entry_changed_cb (GtkEditable *editable,
+ QckDesktopEntryDialog *self)
+{
+ g_key_file_set_string (self->priv->current,
+ G_KEY_FILE_DESKTOP_GROUP,
+ G_KEY_FILE_DESKTOP_KEY_EXEC,
+ gtk_entry_get_text (GTK_ENTRY (GET_WIDGET ("exec_entry"))));
+ qck_desktop_entry_dialog_changed (self);
+}
+
+
+static void
+comment_entry_changed_cb (GtkEditable *editable,
+ QckDesktopEntryDialog *self)
+{
+ char **languages;
+
+ languages = (char **) g_get_language_names ();
+
+ g_key_file_set_locale_string (self->priv->current,
+ G_KEY_FILE_DESKTOP_GROUP,
+ G_KEY_FILE_DESKTOP_KEY_COMMENT,
+ languages[0],
+ gtk_entry_get_text (GTK_ENTRY (GET_WIDGET ("comment_entry"))));
+ qck_desktop_entry_dialog_changed (self);
+}
+
+
+static void
+qck_desktop_entry_dialog_update_icon (QckDesktopEntryDialog *self,
+ GKeyFile *entry)
+{
+ char *icon;
+ GdkPixbuf *image;
+
+ icon = g_key_file_get_string (entry, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_ICON, NULL);
+
+ image = create_pixbuf (gtk_icon_theme_get_default (), icon, _gtk_icon_get_pixel_size (GTK_WIDGET (self), GTK_ICON_SIZE_DIALOG));
+ if (image != NULL) {
+ gtk_image_set_from_pixbuf (GTK_IMAGE (GET_WIDGET ("icon_image")), image);
+ g_object_unref (image);
+ }
+ else
+ gtk_image_set_from_stock (GTK_IMAGE (GET_WIDGET ("icon_image")), GTK_STOCK_MISSING_IMAGE , GTK_ICON_SIZE_DIALOG);
+
+ g_free (icon);
+}
+
+
+static void
+file_chooser_response_cb (GtkWidget *widget,
+ int response,
+ QckDesktopEntryDialog *self)
+{
+ GtkFileChooser *file_chooser = GTK_FILE_CHOOSER (widget);
+ char *path;
+
+ if ((response == GTK_RESPONSE_CANCEL) || (response == GTK_RESPONSE_DELETE_EVENT)) {
+ gtk_widget_destroy (widget);
+ return;
+ }
+
+ path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_chooser));
+ if (path == NULL)
+ return;
+
+ g_key_file_set_string (self->priv->current, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_ICON, path);
+ qck_desktop_entry_dialog_update_icon (self, self->priv->current);
+
+ qck_desktop_entry_dialog_changed (self);
+
+ g_free (path);
+
+ if (response == GTK_RESPONSE_OK)
+ gtk_widget_destroy (GTK_WIDGET (file_chooser));
+}
+
+
+static void
+icon_button_clicked_cb (GtkButton *button,
+ QckDesktopEntryDialog *self)
+{
+ GtkWidget *file_chooser;
+ char *icon;
+ char *icon_path;
+ GFile *file;
+ char *uri;
+ gboolean set_current = FALSE;
+
+ file_chooser = gtk_file_chooser_dialog_new (_("Choose an Image"),
+ GTK_WINDOW (self),
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_APPLY, GTK_RESPONSE_APPLY,
+ GTK_STOCK_OK, GTK_RESPONSE_OK,
+ NULL);
+
+ gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (file_chooser), FALSE);
+ gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (file_chooser),TRUE);
+ gtk_dialog_set_default_response (GTK_DIALOG (file_chooser), GTK_RESPONSE_OK);
+
+ icon = g_key_file_get_string (self->priv->current, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_ICON, NULL);
+ icon_path = panel_find_icon (gtk_icon_theme_get_default (), icon, _gtk_icon_get_pixel_size (GTK_WIDGET (self), GTK_ICON_SIZE_DIALOG));
+ if (icon_path == NULL) {
+ icon_path = g_strdup ("/usr/share/pixmaps/");
+ set_current = TRUE;
+ }
+ file = g_file_new_for_path (icon_path);
+ uri = g_file_get_uri (file);
+ if (set_current)
+ gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (file_chooser), uri);
+ else
+ gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (file_chooser), uri);
+
+ g_signal_connect (G_OBJECT (file_chooser),
+ "response",
+ G_CALLBACK (file_chooser_response_cb),
+ self);
+
+ gtk_window_set_modal (GTK_WINDOW (file_chooser), TRUE);
+ gtk_widget_show (file_chooser);
+
+ g_free (uri);
+ g_object_unref (file);
+ g_free (icon_path);
+ g_free (icon);
+}
+
+
+static void
+qck_desktop_entry_dialog_construct (QckDesktopEntryDialog *self,
+ const char *title,
+ GtkWindow *parent,
+ GKeyFile *entry)
+{
+ GtkWidget *content;
+
+ if (title != NULL)
+ gtk_window_set_title (GTK_WINDOW (self), title);
+ if (parent != NULL)
+ gtk_window_set_transient_for (GTK_WINDOW (self), parent);
+ gtk_window_set_resizable (GTK_WINDOW (self), FALSE);
+ gtk_dialog_set_has_separator (GTK_DIALOG (self), FALSE);
+ gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (self)->vbox), 5);
+ gtk_container_set_border_width (GTK_CONTAINER (self), 5);
+
+ self->priv->builder = _gtk_builder_new_from_file ("desktop-entry-editor.ui");
+
+ content = _gtk_builder_get_widget (self->priv->builder, "desktop_entry_editor");
+ gtk_container_set_border_width (GTK_CONTAINER (content), 5);
+ gtk_widget_show (content);
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (self)->vbox), content, TRUE, TRUE, 0);
+
+ self->priv->type_combobox = _gtk_combo_box_new_with_texts (_("Application"), _("Application in Terminal"), NULL);
+ gtk_widget_show (self->priv->type_combobox);
+ gtk_box_pack_start (GTK_BOX (GET_WIDGET ("type_box")), self->priv->type_combobox, TRUE, TRUE, 0);
+
+ qck_desktop_entry_dialog_set_entry (self, entry);
+
+ g_signal_connect (self->priv->type_combobox,
+ "changed",
+ G_CALLBACK (type_combobox_changed_cb),
+ self);
+ g_signal_connect (GET_WIDGET ("name_entry"),
+ "changed",
+ G_CALLBACK (name_entry_changed_cb),
+ self);
+ g_signal_connect (GET_WIDGET ("exec_entry"),
+ "changed",
+ G_CALLBACK (exec_entry_changed_cb),
+ self);
+ g_signal_connect (GET_WIDGET ("comment_entry"),
+ "changed",
+ G_CALLBACK (comment_entry_changed_cb),
+ self);
+ g_signal_connect (GET_WIDGET ("icon_button"),
+ "clicked",
+ G_CALLBACK (icon_button_clicked_cb),
+ self);
+}
+
+
+GtkWidget *
+qck_desktop_entry_dialog_new (const char *title,
+ GtkWindow *parent,
+ GKeyFile *entry)
+{
+ QckDesktopEntryDialog *self;
+
+ self = g_object_new (QCK_TYPE_DESKTOP_ENTRY_DIALOG, NULL);
+ qck_desktop_entry_dialog_construct (self, title, parent, entry);
+
+ return (GtkWidget *) self;
+}
+
+
+static void
+qck_desktop_entry_dialog_update (QckDesktopEntryDialog *self,
+ GKeyFile *entry)
+{
+ gboolean terminal;
+ char *name;
+ char *exec;
+ char *comment;
+
+ terminal = g_key_file_get_boolean (entry, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_TERMINAL, NULL);
+ name = g_key_file_get_locale_string (entry, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_NAME, NULL, NULL);
+ exec = g_key_file_get_string (entry, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_EXEC, NULL);
+ comment = g_key_file_get_locale_string (entry, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_COMMENT, NULL, NULL);
+
+ gtk_combo_box_set_active (GTK_COMBO_BOX (self->priv->type_combobox), terminal ? 1 : 0);
+ gtk_entry_set_text (GTK_ENTRY (GET_WIDGET ("name_entry")), name ? name : "");
+ gtk_entry_set_text (GTK_ENTRY (GET_WIDGET ("exec_entry")), exec ? exec : "");
+ gtk_entry_set_text (GTK_ENTRY (GET_WIDGET ("comment_entry")), comment ? comment : "");
+
+ g_free (comment);
+ g_free (exec);
+ g_free (name);
+
+ qck_desktop_entry_dialog_update_icon (self, entry);
+}
+
+
+void
+qck_desktop_entry_dialog_set_entry (QckDesktopEntryDialog *self,
+ GKeyFile *entry)
+{
+ if (self->priv->original != NULL)
+ g_key_file_free (self->priv->original);
+ self->priv->original = _g_key_file_dup (entry);
+
+ if (self->priv->current != NULL)
+ g_key_file_free (self->priv->current);
+ self->priv->current = _g_key_file_dup (entry);
+
+ qck_desktop_entry_dialog_update (self, self->priv->current);
+}
+
+
+GKeyFile *
+qck_desktop_entry_dialog_get_entry (QckDesktopEntryDialog *self,
+ GError **error)
+{
+ return _g_key_file_dup (self->priv->current);
+}
+
+
+void
+qck_desktop_entry_dialog_revert (QckDesktopEntryDialog *self)
+{
+ if (self->priv->current != NULL)
+ g_key_file_free (self->priv->current);
+ self->priv->current = _g_key_file_dup (self->priv->original);
+
+ qck_desktop_entry_dialog_update (self, self->priv->current);
+ qck_desktop_entry_dialog_changed (self);
+}
Added: trunk/src/qck-desktop-entry-dialog.h
==============================================================================
--- (empty file)
+++ trunk/src/qck-desktop-entry-dialog.h Sun Feb 1 21:46:59 2009
@@ -0,0 +1,61 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * Quick Lounge Applet
+ *
+ * Copyright (C) 2009 The Free Software Foundation, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef QCK_DESKTOP_ENTRY_DIALOG_H
+#define QCK_DESKTOP_ENTRY_DIALOG_H
+
+#include <gtk/gtk.h>
+
+#define QCK_TYPE_DESKTOP_ENTRY_DIALOG (qck_desktop_entry_dialog_get_type ())
+#define QCK_DESKTOP_ENTRY_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), QCK_TYPE_DESKTOP_ENTRY_DIALOG, QckDesktopEntryDialog))
+#define QCK_DESKTOP_ENTRY_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), QCK_TYPE_DESKTOP_ENTRY_DIALOG, QckDesktopEntryDialogClass))
+#define QCK_IS_DESKTOP_ENTRY_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), QCK_TYPE_DESKTOP_ENTRY_DIALOG))
+#define QCK_IS_DESKTOP_ENTRY_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), QCK_TYPE_DESKTOP_ENTRY_DIALOG))
+#define QCK_DESKTOP_ENTRY_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), QCK_TYPE_DESKTOP_ENTRY_DIALOG, QckDesktopEntryDialogClass))
+
+typedef struct _QckDesktopEntryDialog QckDesktopEntryDialog;
+typedef struct _QckDesktopEntryDialogClass QckDesktopEntryDialogClass;
+typedef struct _QckDesktopEntryDialogPrivate QckDesktopEntryDialogPrivate;
+
+struct _QckDesktopEntryDialog {
+ GtkDialog parent_instance;
+ QckDesktopEntryDialogPrivate *priv;
+};
+
+struct _QckDesktopEntryDialogClass {
+ GtkDialogClass parent_class;
+
+ void (*changed) (QckDesktopEntryDialog *self,
+ gboolean reverted);
+};
+
+GType qck_desktop_entry_dialog_get_type (void);
+GtkWidget * qck_desktop_entry_dialog_new (const char *title,
+ GtkWindow *parent,
+ GKeyFile *entry);
+void qck_desktop_entry_dialog_set_entry (QckDesktopEntryDialog *self,
+ GKeyFile *entry);
+GKeyFile * qck_desktop_entry_dialog_get_entry (QckDesktopEntryDialog *self,
+ GError **error);
+void qck_desktop_entry_dialog_revert (QckDesktopEntryDialog *self);
+
+#endif /* QCK_DESKTOP_ENTRY_DIALOG_H */
Modified: trunk/src/quick-box.c
==============================================================================
--- trunk/src/quick-box.c (original)
+++ trunk/src/quick-box.c Sun Feb 1 21:46:59 2009
@@ -24,16 +24,15 @@
#include <stdlib.h>
#include <string.h>
#include <math.h>
+#include <gio/gdesktopappinfo.h>
#include <gtk/gtk.h>
#include <gconf/gconf-client.h>
-#include <libgnome/gnome-desktop-item.h>
#include "dlg-properties.h"
#include "quick-box.h"
#include "quick-button.h"
#include "quick-separator.h"
#include "gtk-utils.h"
#include "xstuff.h"
-#include "gnome-ditem-edit.h"
#define ICON_SPACING 1 /* spacing between icons */
#define ICON_SIZE_PANEL 22 /* icons size on panels */
@@ -798,7 +797,6 @@
GdkRectangle *rect)
{
GtkWidget *widget = GTK_WIDGET (quick_box);
- GtkBox *box = GTK_BOX (quick_box);
GList *children, *scan;
int i, cx, cy, cwidth, cheight;
@@ -965,31 +963,38 @@
}
-static gboolean
-item_activated (QuickButton *button)
+static void
+_g_desktop_entry_launch (GKeyFile *desktop_entry,
+ GtkWidget *source)
{
- GnomeDesktopItem *ditem;
-
- ditem = g_object_get_data (G_OBJECT (button), "ditem");
- if (ditem != NULL) {
- GError *error = NULL;
-
- if (enable_animations ())
- xstuff_zoom_animate (GTK_WIDGET (button), NULL);
-
- gnome_desktop_item_launch_on_screen (ditem,
- NULL,
- 0,
- gtk_widget_get_screen (GTK_WIDGET (button)),
- -1, &error);
+ GDesktopAppInfo *app_info;
+ GdkAppLaunchContext *context;
+ GError *error = NULL;
+
+ app_info = g_desktop_app_info_new_from_keyfile (desktop_entry);
+ context = gdk_app_launch_context_new ();
+
+ if (! g_app_info_launch (G_APP_INFO (app_info), NULL, G_APP_LAUNCH_CONTEXT (context), &error)) {
+ _gtk_error_dialog_from_gerror_run (NULL, &error);
+ }
+ else if ((source != NULL) && enable_animations ())
+ xstuff_zoom_animate (source, NULL);
+
+ g_object_unref (context);
+ g_object_unref (app_info);
+}
- if (error != NULL)
- _gtk_error_dialog_from_gerror_run (NULL, &error);
- return TRUE;
- }
+static gboolean
+item_activated (QuickButton *button)
+{
+ GKeyFile *desktop_entry;
- return FALSE;
+ desktop_entry = g_object_get_data (G_OBJECT (button), "desktop_entry");
+ if (desktop_entry != NULL)
+ _g_desktop_entry_launch (desktop_entry, GTK_WIDGET (button));
+
+ return TRUE;
}
@@ -1151,20 +1156,20 @@
children = gtk_container_get_children (GTK_CONTAINER (quick_box));
for (scan = children; scan; scan = scan->next) {
- GtkWidget *child_widget = scan->data;
- GnomeDesktopItem *ditem;
- GtkWidget *icon = NULL;
- char *icon_path = NULL;
- const char *text;
- const char *comment;
- char *tip;
+ GtkWidget *child_widget = scan->data;
+ GKeyFile *desktop_entry;
+ char *name;
+ char *icon;
+ GtkWidget *image = NULL;
+ char *comment;
+ char *tip;
if ((child_widget != NULL) && GTK_WIDGET_VISIBLE (child_widget))
continue;
- ditem = g_object_get_data (G_OBJECT (child_widget), "ditem");
+ desktop_entry = g_object_get_data (G_OBJECT (child_widget), "desktop_entry");
- if (ditem == NULL) { /* add separator */
+ if (desktop_entry == NULL) { /* add separator */
/* do not display the separator if it is the first
* item in the menu. */
@@ -1191,28 +1196,27 @@
/**/
- text = gnome_desktop_item_get_localestring (ditem, "Name");
- item = gtk_image_menu_item_new_with_label (text);
+ name = g_key_file_get_locale_string (desktop_entry, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_NAME, NULL, NULL);
+ item = gtk_image_menu_item_new_with_label (name);
- icon_path = gnome_desktop_item_get_icon (ditem, quick_box->priv->icon_theme);
- if (icon_path != NULL)
- icon = create_image (quick_box->priv->icon_theme, icon_path, ICON_SIZE_MENU);
+ icon = g_key_file_get_string (desktop_entry, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_ICON, NULL);
if (icon != NULL)
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), icon);
+ image = create_image (quick_box->priv->icon_theme, icon, ICON_SIZE_MENU);
+ if (image != NULL)
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
/**/
- comment = gnome_desktop_item_get_localestring (ditem, "Comment");
- if ((comment != NULL) && (*comment != 0))
+ comment = g_key_file_get_locale_string (desktop_entry, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_COMMENT, NULL, NULL);
+
+ if ((comment != NULL) && (strcmp (comment, "") != 0))
tip = g_strdup (comment);
else
- tip = g_strdup (text);
+ tip = g_strdup (name);
gtk_tooltips_set_tip (quick_box->tooltips,
GTK_WIDGET (item),
tip,
NULL);
- g_free (tip);
-
/**/
if (quick_box->priv->orient == PANEL_APPLET_ORIENT_UP)
@@ -1251,9 +1255,12 @@
G_CALLBACK (menu_item__drag_end),
quick_box);
- /**/
-
gtk_widget_show (item);
+
+ g_free (tip);
+ g_free (comment);
+ g_free (icon);
+ g_free (name);
}
g_list_free (children);
@@ -1566,48 +1573,54 @@
children = gtk_container_get_children (GTK_CONTAINER (quick_box));
for (scan = children; scan; scan = scan->next) {
- GtkWidget *child_widget = scan->data;
- GnomeDesktopItem *ditem;
- char *icon_path;
+ GtkWidget *child_widget = scan->data;
+ GKeyFile *desktop_entry;
+ char *icon;
if (! QUICK_IS_BUTTON (child_widget))
continue;
- ditem = g_object_get_data (G_OBJECT (child_widget), "ditem");
- if (ditem == NULL)
+ desktop_entry = g_object_get_data (G_OBJECT (child_widget), "desktop_entry");
+ if (desktop_entry == NULL)
continue;
- icon_path = gnome_desktop_item_get_icon (ditem, quick_box->priv->icon_theme);
- quick_button_set_pixmap (QUICK_BUTTON (child_widget), icon_path, child_size);
- g_free (icon_path);
+ icon = g_key_file_get_string (desktop_entry, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_ICON, NULL);
+ quick_button_set_pixmap (QUICK_BUTTON (child_widget), icon, child_size);
+ g_free (icon);
}
g_list_free (children);
}
GtkWidget *
-quick_box_add_button (QuickBox *quick_box,
- const char *uri,
- int pos)
-{
- GnomeDesktopItem *ditem;
- GtkWidget *button;
- const char *text;
- const char *comment;
- char *tip;
- char *icon_path;
- int child_size;
+quick_box_add_button (QuickBox *quick_box,
+ const char *uri,
+ int pos)
+{
+ char *filename;
+ GKeyFile *desktop_entry;
+ char *name;
+ GtkWidget *button;
+ char *comment;
+ char *tip;
+ char *icon_path;
+ int child_size;
- ditem = gnome_desktop_item_new_from_uri (uri, 0, NULL);
- if (ditem == NULL)
+ filename = g_filename_from_uri (uri, NULL, NULL);
+
+ desktop_entry = g_key_file_new ();
+ if (! g_key_file_load_from_file (desktop_entry, filename, G_KEY_FILE_KEEP_TRANSLATIONS, NULL)) {
+ g_free (filename);
return NULL;
+ }
- text = gnome_desktop_item_get_localestring (ditem, "Name");
- icon_path = gnome_desktop_item_get_icon (ditem, quick_box->priv->icon_theme);
+ g_free (filename);
+
+ icon_path = g_key_file_get_string (desktop_entry, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_ICON, NULL);
child_size = get_child_size (quick_box);
- button = quick_button_new (icon_path, child_size, text, quick_box->priv->icon_theme);
- g_free (icon_path);
-
+ name = g_key_file_get_locale_string (desktop_entry, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_NAME, NULL, NULL);
+ button = quick_button_new (icon_path, child_size, name, quick_box->priv->icon_theme);
+
if (button == NULL)
return NULL;
@@ -1625,9 +1638,9 @@
quick_box);
g_object_set_data_full (G_OBJECT (button),
- "ditem",
- ditem,
- (GDestroyNotify) gnome_desktop_item_unref);
+ "desktop_entry",
+ desktop_entry,
+ (GDestroyNotify) g_key_file_free);
g_object_set_data_full (G_OBJECT (button),
"uri",
g_strdup (uri),
@@ -1635,8 +1648,8 @@
/* tip */
- comment = gnome_desktop_item_get_localestring (ditem, "Comment");
- tip = g_strconcat (text,
+ comment = g_key_file_get_locale_string (desktop_entry, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_COMMENT, NULL, NULL);
+ tip = g_strconcat (name,
((comment != NULL) && (*comment != 0)) ? "\n" : NULL,
((comment != NULL) && (*comment != 0)) ? comment: NULL,
NULL);
@@ -1644,7 +1657,11 @@
button,
tip,
NULL);
+
g_free (tip);
+ g_free (comment);
+ g_free (icon_path);
+ g_free (name);
/**/
@@ -1678,7 +1695,7 @@
G_CALLBACK (button_button_press_cb),
NULL);
- g_object_set_data (G_OBJECT (quick_sep), "ditem", NULL);
+ g_object_set_data (G_OBJECT (quick_sep), "desktop_entry", NULL);
gtk_box_pack_start (GTK_BOX (quick_box), quick_sep, 0, 0, 0);
if (pos != -1)
@@ -1773,7 +1790,7 @@
quick_box->priv->size);
else if (QUICK_IS_BUTTON (widget))
quick_button_set_pixmap (QUICK_BUTTON (widget),
- QUICK_BUTTON (widget)->icon_path,
+ QUICK_BUTTON (widget)->icon,
size);
}
@@ -1902,35 +1919,34 @@
void
-quick_box_update_child (QuickBox *quick_box,
- QuickButton *quick_button,
- GnomeDesktopItem *ditem)
-{
- const char *text;
- const char *comment;
- char *icon_path;
- char *tip;
+quick_box_update_child (QuickBox *quick_box,
+ QuickButton *quick_button,
+ GKeyFile *desktop_entry)
+{
+ GKeyFile *new_desktop_entry;
+ char *icon;
+ char *name;
+ char *comment;
+ char *tip;
g_return_if_fail (QUICK_IS_BOX (quick_box));
g_return_if_fail (QUICK_IS_BUTTON (quick_button));
- gnome_desktop_item_ref (ditem);
+ new_desktop_entry = _g_key_file_dup (desktop_entry);
+
g_object_set_data_full (G_OBJECT (quick_button),
- "ditem",
- ditem,
- (GDestroyNotify) gnome_desktop_item_unref);
-
- icon_path = gnome_desktop_item_get_icon (ditem, quick_box->priv->icon_theme);
- quick_button_set_pixmap (quick_button,
- icon_path,
- get_child_size (quick_box));
- g_free (icon_path);
+ "desktop_entry",
+ new_desktop_entry,
+ (GDestroyNotify) g_key_file_free);
- text = gnome_desktop_item_get_localestring (ditem, "Name");
- quick_button_set_text (quick_button, text);
+ icon = g_key_file_get_string (new_desktop_entry, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_ICON, NULL);
+ quick_button_set_pixmap (quick_button, icon, get_child_size (quick_box));
+
+ name = g_key_file_get_locale_string (new_desktop_entry, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_NAME, NULL, NULL);
+ quick_button_set_text (quick_button, name);
- comment = gnome_desktop_item_get_localestring (ditem, "Comment");
- tip = g_strconcat (text,
+ comment = g_key_file_get_locale_string (new_desktop_entry, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_COMMENT, NULL, NULL);
+ tip = g_strconcat (name,
((comment != NULL) && (*comment != 0)) ? "\n" : NULL,
comment,
NULL);
@@ -1938,7 +1954,9 @@
GTK_WIDGET (quick_button),
tip,
NULL);
+
g_free (tip);
+ g_free (comment);
+ g_free (name);
+ g_free (icon);
}
-
-
Modified: trunk/src/quick-box.h
==============================================================================
--- trunk/src/quick-box.h (original)
+++ trunk/src/quick-box.h Sun Feb 1 21:46:59 2009
@@ -25,7 +25,6 @@
#include <glib.h>
#include <gtk/gtk.h>
-#include <libgnome/gnome-desktop-item.h>
#include <panel-applet.h>
#include "quick-button.h"
#include "quick-separator.h"
@@ -110,6 +109,6 @@
void quick_box_update_child (QuickBox *qbox,
QuickButton *child,
- GnomeDesktopItem *ditem);
+ GKeyFile *desktop_entry);
#endif /* QUICK_BOX_H */
Modified: trunk/src/quick-button.c
==============================================================================
--- trunk/src/quick-button.c (original)
+++ trunk/src/quick-button.c Sun Feb 1 21:46:59 2009
@@ -35,6 +35,7 @@
#include <string.h>
#include <gtk/gtk.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
+#include "gtk-utils.h"
#include "quick-button.h"
#define DEFAULT_OFFSET 2
@@ -72,7 +73,7 @@
GdkEventCrossing *event);
static void quick_button_button_pressed (GtkButton *button);
static void quick_button_button_released (GtkButton *button);
-void set_pixmap (QuickButton *button,
+static void set_pixmap (QuickButton *button,
const char *icon_path,
int size);
@@ -206,14 +207,14 @@
button->scaled_bright = NULL;
}
- if (button->icon_path != NULL) {
- g_free (button->icon_path);
- button->icon_path = NULL;
+ if (button->icon != NULL) {
+ g_free (button->icon);
+ button->icon = NULL;
}
- if (button->text != NULL) {
- g_free (button->text);
- button->text = NULL;
+ if (button->name != NULL) {
+ g_free (button->name);
+ button->name = NULL;
}
if (button->icon_theme != NULL) {
@@ -261,23 +262,27 @@
static GdkPixbuf *
-get_missing (GtkIconTheme *theme,
- int preffered_size)
+get_missing (GtkIconTheme *theme,
+ int preffered_size)
{
GtkIconInfo *icon_info;
const char *filename = NULL;
+ GdkPixbuf *pixbuf;
icon_info = gtk_icon_theme_lookup_icon (theme,
- "gnome-unknown",
+ "gtk-missing-image",
preffered_size,
0);
- filename = gtk_icon_info_get_filename (icon_info);
+ filename = gtk_icon_info_get_filename (icon_info);
+ if (filename != NULL)
+ pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
+ else
+ pixbuf = missing_pixbuf (preffered_size);
+
gtk_icon_info_free (icon_info);
- if (filename == NULL)
- return missing_pixbuf (preffered_size);
-
- return gdk_pixbuf_new_from_file (filename, NULL);
+
+ return pixbuf;
}
@@ -345,28 +350,21 @@
static void
button_load_pixbuf (QuickButton *button,
- const char *path,
+ const char *icon_name,
int preffered_size)
{
- GdkPixbuf *new_pixbuf = NULL;
- GError *gerror = NULL;
- int w, h;
- int pixbuf_w, pixbuf_h;
- double scale;
+ GdkPixbuf *new_pixbuf = NULL;
+ int w, h;
+ int pixbuf_w, pixbuf_h;
+ double scale;
if (preffered_size <= 0)
preffered_size = DEFAULT_SIZE;
-
- if (path == NULL)
- new_pixbuf = get_missing (button->icon_theme, preffered_size);
- else
- new_pixbuf = gdk_pixbuf_new_from_file (path, &gerror);
- if (new_pixbuf == NULL) {
- g_clear_error (&gerror);
+ new_pixbuf = create_pixbuf (button->icon_theme, icon_name, preffered_size);
+ if (new_pixbuf == NULL)
new_pixbuf = get_missing (button->icon_theme, preffered_size);
- }
/**/
@@ -382,16 +380,14 @@
w = MAX ((double) w * scale, 1);
h = MAX ((double) h * scale, 1);
- /**/
-
if (button->scaled != NULL)
g_object_unref (button->scaled);
- if (button->scaled_bright != NULL)
- g_object_unref (button->scaled_bright);
-
button->scaled = gdk_pixbuf_scale_simple (button->pixbuf,
w, h,
GDK_INTERP_BILINEAR);
+
+ if (button->scaled_bright != NULL)
+ g_object_unref (button->scaled_bright);
button->scaled_bright = make_bright_pixbuf (button->scaled);
}
@@ -657,9 +653,9 @@
GtkWidget *
-quick_button_new (const char *icon_path,
+quick_button_new (const char *icon,
int size,
- const char *text,
+ const char *name,
GtkIconTheme *icon_theme)
{
QuickButton *button;
@@ -668,12 +664,12 @@
button = QUICK_BUTTON (g_object_new (quick_button_get_type (), NULL));
- button->icon_path = (icon_path != NULL) ? g_strdup (icon_path) : NULL;
+ button->icon = (icon != NULL) ? g_strdup (icon) : NULL;
button->size = size;
- button->text = (text != NULL) ? g_strdup (text) : NULL;
+ button->name = (name != NULL) ? g_strdup (name) : NULL;
button->icon_theme = g_object_ref (icon_theme);
- button_load_pixbuf (button, icon_path, size);
+ button_load_pixbuf (button, icon, size);
gtk_drag_source_set (GTK_WIDGET (button),
GDK_BUTTON1_MASK,
@@ -695,41 +691,40 @@
void
quick_button_set_pixmap (QuickButton *button,
- const char *icon_path,
+ const char *icon,
int size)
{
- QUICK_BUTTON_GET_CLASS (G_OBJECT (button))->set_pixmap (button, icon_path, size);
+ QUICK_BUTTON_GET_CLASS (G_OBJECT (button))->set_pixmap (button, icon, size);
}
-void
+static void
set_pixmap (QuickButton *button,
- const char *icon_path,
+ const char *icon,
int size)
{
g_return_if_fail (QUICK_IS_BUTTON (button));
g_return_if_fail (size > 0);
- button->size = size;
- if (icon_path != button->icon_path) {
- g_free (button->icon_path);
- button->icon_path = g_strdup (icon_path);
+ if (icon != button->icon) {
+ g_free (button->icon);
+ button->icon = g_strdup (icon);
}
-
- button_load_pixbuf (button, icon_path, size);
-
+ button->size = size;
+
+ button_load_pixbuf (button, icon, size);
gtk_widget_queue_resize (GTK_WIDGET (button));
}
void
quick_button_set_text (QuickButton *button,
- const char *text)
+ const char *name)
{
g_return_if_fail (QUICK_IS_BUTTON (button));
- g_free (button->text);
- button->text = text ? g_strdup (text ) : NULL;
+ g_free (button->name);
+ button->name = name ? g_strdup (name) : NULL;
gtk_widget_queue_draw (GTK_WIDGET (button));
}
Modified: trunk/src/quick-button.h
==============================================================================
--- trunk/src/quick-button.h (original)
+++ trunk/src/quick-button.h Sun Feb 1 21:46:59 2009
@@ -39,16 +39,15 @@
{
GtkButton __parent;
+ char *name;
+ char *icon;
+ int size;
+
+ guint dnd_highlight : 1;
+ guint pressed_timeout;
GdkPixbuf *pixbuf;
GdkPixbuf *scaled;
GdkPixbuf *scaled_bright;
-
- char *icon_path;
- int size;
- char *text;
- guint dnd_highlight:1;
- guint pressed_timeout;
-
GtkIconTheme *icon_theme;
};
@@ -59,7 +58,7 @@
/*< virtual functions >*/
void (*set_pixmap) (QuickButton *button,
- const char *icon_path,
+ const char *icon,
int size);
/*< signals >*/
@@ -68,19 +67,15 @@
};
GType quick_button_get_type (void) G_GNUC_CONST;
-
GtkWidget* quick_button_new (const char *icon_path,
int size,
const char *text,
GtkIconTheme *icon_theme);
-
void quick_button_set_pixmap (QuickButton *button,
- const char *icon_path,
+ const char *icon,
int size);
-
void quick_button_set_text (QuickButton *button,
const char *text);
-
void quick_button_set_dnd_highlight (QuickButton *button,
gboolean highlight);
Modified: trunk/src/quick-lounge.c
==============================================================================
--- trunk/src/quick-lounge.c (original)
+++ trunk/src/quick-lounge.c Sun Feb 1 21:46:59 2009
@@ -26,7 +26,6 @@
#include <gtk/gtk.h>
#include <gconf/gconf-client.h>
#include <libgnome/libgnome.h>
-#include <libgnome/gnome-desktop-item.h>
#include <libgnomeui/libgnomeui.h>
#include <panel-applet.h>
#include <panel-applet-gconf.h>
@@ -34,10 +33,10 @@
#include "dlg-properties.h"
#include "file-utils.h"
#include "gtk-utils.h"
+#include "qck-desktop-entry-dialog.h"
#include "quick-box.h"
#include "quick-separator.h"
#include "quick-lounge.h"
-#include "gnome-ditem-edit.h"
#define APPLET_IID "OAFIID:GNOME_QuickLoungeApplet"
#define APPLET_FACTORY_IID "OAFIID:GNOME_QuickLoungeApplet_Factory"
@@ -58,7 +57,8 @@
enum {
- REVERT_BUTTON
+ REVERT_BUTTON,
+ QCK_RESPONSE_REVERT
};
@@ -102,23 +102,7 @@
QuickLounge *quick_lounge,
const gchar *verbname)
{
- GError *error = NULL;
-
- gnome_help_display_desktop_on_screen (
- NULL,
- "quick-lounge",
- "quick-lounge",
- NULL,
- gtk_widget_get_screen (GTK_WIDGET (quick_lounge->applet)),
- &error);
-
- if (error) {
- _gtk_error_dialog_run (NULL,
- ERROR_FORMAT,
- _("Could not display help"),
- error->message);
- g_error_free (error);
- }
+ _gtk_show_help (NULL, "quick-lounge", NULL);
}
@@ -174,15 +158,6 @@
static void
-gh_desktop_item_unref (gpointer key,
- gpointer value,
- gpointer user_data)
-{
- gnome_desktop_item_unref (value);
-}
-
-
-static void
applet_destroy (GtkWidget *applet,
QuickLounge *quick_lounge)
{
@@ -192,16 +167,7 @@
gtk_widget_destroy (quick_lounge->prop_dialog);
g_free (quick_lounge->location);
-
- if (quick_lounge->ditem_hash != NULL) {
- g_hash_table_foreach (quick_lounge->ditem_hash,
- gh_desktop_item_unref,
- NULL);
- g_hash_table_destroy (quick_lounge->ditem_hash);
- }
-
g_object_unref (quick_lounge->icon_theme);
-
g_free (quick_lounge);
}
@@ -317,183 +283,90 @@
/* -- Button Context Menu -- */
-static gboolean
-ditem_properties_apply_timeout (gpointer data)
-{
- GtkWidget *dialog = data;
- GnomeDItemEdit *dedit;
- GError *error = NULL;
- GnomeDesktopItem *ditem, *orig_ditem;
- QuickLounge *quick_lounge;
- QuickButton *button;
- QuickBox *quick_box;
- GtkWidget *revert_button;
- const char *uri;
-
- dedit = g_object_get_data (G_OBJECT (dialog), "ditem_edit");
-
- g_object_set_data (G_OBJECT (dedit), "apply_timeout", NULL);
-
- /* save */
-
- quick_box = g_object_get_data (G_OBJECT (dialog), "quick_box");
- button = g_object_get_data (G_OBJECT (dialog), "button");
- orig_ditem = g_object_get_data (G_OBJECT (button), "ditem");
- uri = g_object_get_data (G_OBJECT (button), "uri");
- quick_lounge = g_object_get_data (G_OBJECT (quick_box), "quick_lounge");
- ditem = gnome_ditem_edit_get_ditem (dedit);
- gnome_desktop_item_set_location (ditem, gnome_desktop_item_get_location (orig_ditem));
- gnome_desktop_item_save (ditem, uri, TRUE, &error);
-
- /* save the error for later */
-
- if (error != NULL) {
- g_object_set_data_full (G_OBJECT (dedit), "SavingError",
- g_strdup (error->message),
- (GDestroyNotify) g_free);
- g_clear_error (&error);
- } else
- g_object_set_data (G_OBJECT (dedit), "SavingError", NULL);
-
- /* update */
-
- quick_box_update_child (quick_box, button, ditem);
- dlg_properties_update (quick_lounge->prop_dialog);
- revert_button = g_object_get_data (G_OBJECT (dialog), "revert_button");
- gtk_widget_set_sensitive (revert_button, TRUE);
-
- return FALSE;
-}
-
-
-static void ditem_properties_changed (GtkWidget *dedit, gpointer data);
+typedef struct {
+ QuickLounge *quick_lounge;
+ GtkWidget *button;
+ int position;
+} EditItemData;
static void
-ditem_properties_clicked (GtkWidget *w,
- int response,
- gpointer data)
-{
- GtkWidget *dialog = data;
-
- if (response == GTK_RESPONSE_HELP) {
- GError *error = NULL;
-
- gnome_help_display_desktop_on_screen (NULL,
- "user-guide",
- "user-guide.xml",
- "gospanel-52",
- gtk_window_get_screen (GTK_WINDOW (dialog)),
- &error);
-
- if (error) {
- GtkWidget *message_dialog;
- message_dialog = gtk_message_dialog_new (NULL, 0,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- _("There was an error displaying help: %s"),
- error->message);
- g_error_free (error);
- gtk_dialog_run (GTK_DIALOG (message_dialog));
- gtk_widget_destroy (message_dialog);
- }
- } else if (response == REVERT_BUTTON) {
- QuickButton *button;
- GnomeDItemEdit *dedit;
- GtkWidget *revert_button;
- GnomeDesktopItem *revert_ditem, *ditem;
-
- dedit = g_object_get_data (G_OBJECT (dialog), "ditem_edit");
- button = g_object_get_data (G_OBJECT (dialog), "button");
- revert_ditem = g_object_get_data (G_OBJECT (dialog), "revert_ditem");
-
- g_signal_handlers_block_by_func (G_OBJECT (dedit),
- ditem_properties_changed,
- dialog);
-
- ditem = gnome_desktop_item_copy (revert_ditem);
- gnome_ditem_edit_set_ditem (GNOME_DITEM_EDIT (dedit), ditem);
- gnome_desktop_item_unref (ditem);
-
- g_signal_handlers_unblock_by_func (G_OBJECT (dedit),
- ditem_properties_changed,
- dialog);
-
- ditem_properties_apply_timeout (dialog);
-
- revert_button = g_object_get_data (G_OBJECT (dialog), "revert_button");
- gtk_widget_set_sensitive (revert_button, FALSE);
-
- } else if (response == GTK_RESPONSE_CLOSE)
- gtk_widget_destroy (dialog);
+edit_desktop_entry_dialog_destroy_cb (GtkWidget *widget,
+ gpointer user_data)
+{
+ g_free (user_data);
}
static void
-ditem_properties_changed (GtkWidget *dedit,
- gpointer data)
+edit_desktop_entry_dialog_response_cb (GtkDialog *dialog,
+ int response,
+ gpointer user_data)
{
- GtkWidget *dialog = data;
- gpointer timeout_data;
- guint timeout;
-
- timeout_data = g_object_get_data (G_OBJECT (dedit), "apply_timeout");
- timeout = GPOINTER_TO_UINT (timeout_data);
-
- g_object_set_data (G_OBJECT (dedit), "apply_timeout", NULL);
-
- if (timeout != 0)
- g_source_remove (timeout);
-
- /* Will delay save for after 0.2 seconds */
- timeout = g_timeout_add (2 * 100,
- ditem_properties_apply_timeout,
- dialog);
-
- g_object_set_data (G_OBJECT (dedit),
- "apply_timeout",
- GUINT_TO_POINTER (timeout));
+ switch (response) {
+ case GTK_RESPONSE_HELP:
+ _gtk_show_help (NULL, "user-guide", "gospanel-52");
+ break;
+
+ case QCK_RESPONSE_REVERT:
+ qck_desktop_entry_dialog_revert (QCK_DESKTOP_ENTRY_DIALOG (dialog));
+ break;
+
+ case GTK_RESPONSE_CLOSE:
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ break;
+
+ default:
+ break;
+ }
}
static void
-ditem_properties_close (GtkWidget *dialog,
- GtkWidget *data)
-{
- GnomeDItemEdit *dedit;
- const char *saving_error;
- gpointer timeout_data;
- guint timeout;
- GnomeDesktopItem *revert_ditem;
-
- dedit = g_object_get_data (G_OBJECT (dialog), "ditem_edit");
- revert_ditem = g_object_get_data (G_OBJECT (dialog), "revert_ditem");
-
- g_signal_handlers_disconnect_by_func (G_OBJECT (dedit),
- ditem_properties_changed,
- dialog);
-
- timeout_data = g_object_get_data (G_OBJECT (dedit), "apply_timeout");
- timeout = GPOINTER_TO_UINT (timeout_data);
-
- g_object_set_data (G_OBJECT (dedit), "apply_timeout", NULL);
-
- /* If there was a timeout, then something changed after last save,
- * so we must save again now */
- if (timeout != 0) {
- g_source_remove (timeout);
- ditem_properties_apply_timeout (dialog);
- }
-
- saving_error = g_object_get_data (G_OBJECT (dedit), "SavingError");
- if (saving_error != NULL)
- _gtk_error_dialog_run (NULL,
- _("Cannot save changes to launcher\n\n"
- "Details: %s"),
- saving_error);
-
- gnome_ditem_edit_clear (dedit);
- gnome_desktop_item_unref (revert_ditem);
+edit_desktop_entry_dialog_changed_cb (GtkDialog *dialog,
+ gboolean reverted,
+ gpointer user_data)
+{
+ EditItemData *edit_data = user_data;
+ GtkWidget *button = edit_data->button;
+ GKeyFile *desktop_entry;
+ GError *error = NULL;
+ char *data;
+ gsize length;
+ const char *uri;
+ GFile *file;
+
+ gtk_dialog_set_response_sensitive (dialog, QCK_RESPONSE_REVERT, ! reverted);
+
+ desktop_entry = qck_desktop_entry_dialog_get_entry (QCK_DESKTOP_ENTRY_DIALOG (dialog), &error);
+ if (error != NULL) {
+ _gtk_error_dialog_from_gerror_run (GTK_WINDOW (dialog), &error);
+ return;
+ }
+
+ if (desktop_entry == NULL)
+ return;
+
+ data = g_key_file_to_data (desktop_entry, &length, &error);
+ if (data == NULL) {
+ g_key_file_free (desktop_entry);
+ _gtk_error_dialog_from_gerror_run (GTK_WINDOW (dialog), &error);
+ return;
+ }
+
+ uri = g_object_get_data (G_OBJECT (edit_data->button), "uri");
+ file = g_file_new_for_uri (uri);
+ if (! g_write_file (file, FALSE, G_FILE_CREATE_NONE, data, length, NULL, &error)) {
+ _gtk_error_dialog_from_gerror_run (GTK_WINDOW (dialog), &error);
+ }
+ else {
+ quick_box_update_child (edit_data->quick_lounge->quick_box, (QuickButton*) button, desktop_entry);
+ dlg_properties_update (edit_data->quick_lounge->prop_dialog);
+ }
+
+ g_object_unref (file);
+ g_free (data);
+ g_key_file_free (desktop_entry);
}
@@ -501,61 +374,38 @@
quick_lounge_util__item_properties (QuickLounge *quick_lounge,
GtkWidget *button)
{
- GtkWidget *widget;
- GtkDialog *dialog;
- GtkWidget *dedit;
- GnomeDesktopItem *ditem;
- GnomeDesktopItem *revert_ditem;
- GtkWidget *revert_button;
-
- widget = gtk_dialog_new_with_buttons (_("Launcher Properties"),
- NULL, 0 /* flags */,
- GTK_STOCK_HELP,
- GTK_RESPONSE_HELP,
- NULL);
- gtk_window_set_icon_name (GTK_WINDOW (widget), "quick-lounge-applet");
- gtk_window_set_screen (GTK_WINDOW (widget), gtk_widget_get_screen (GTK_WIDGET (quick_lounge->applet)));
-
- dialog = GTK_DIALOG (widget);
-
- revert_button = gtk_dialog_add_button (dialog, GTK_STOCK_REVERT_TO_SAVED, REVERT_BUTTON);
- gtk_dialog_add_button (dialog, GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
-
- gtk_dialog_set_has_separator (dialog, FALSE);
- gtk_dialog_set_default_response (dialog, GTK_RESPONSE_CLOSE);
-
- ditem = g_object_get_data (G_OBJECT (button), "ditem");
- revert_ditem = gnome_desktop_item_copy (ditem);
-
- dedit = gnome_ditem_edit_new ();
- gnome_ditem_edit_set_ditem (GNOME_DITEM_EDIT (dedit), ditem);
- gtk_widget_show (dedit);
-
- gtk_box_pack_start (GTK_BOX (dialog->vbox), dedit, TRUE, TRUE, 0);
- gtk_container_set_border_width (GTK_CONTAINER (dialog), 6);
- gtk_container_set_border_width (GTK_CONTAINER (dedit), 6);
- gtk_box_set_spacing (GTK_BOX (dialog->vbox), 6);
-
- g_object_set_data (G_OBJECT (dialog), "quick_box", button->parent);
- g_object_set_data (G_OBJECT (dialog), "button", button);
- g_object_set_data (G_OBJECT (dialog), "ditem_edit", dedit);
- g_object_set_data (G_OBJECT (dialog), "revert_button", revert_button);
- g_object_set_data (G_OBJECT (dialog), "revert_ditem", revert_ditem);
-
- g_signal_connect (dedit, "changed",
- G_CALLBACK (ditem_properties_changed),
- dialog);
-
- g_signal_connect (G_OBJECT (dialog), "response",
- G_CALLBACK (ditem_properties_clicked),
- dialog);
- g_signal_connect (G_OBJECT (dialog), "destroy",
- G_CALLBACK (ditem_properties_close),
- dialog);
-
- gtk_widget_set_sensitive (revert_button, FALSE);
- gnome_ditem_edit_grab_focus (GNOME_DITEM_EDIT (dedit));
- gtk_widget_show (widget);
+ EditItemData *data;
+ GtkWidget *dialog;
+ GKeyFile *desktop_entry;
+
+ data = g_new0 (EditItemData, 1);
+ data->quick_lounge = quick_lounge;
+ data->button = button;
+
+ desktop_entry = g_object_get_data (G_OBJECT (button), "desktop_entry");
+
+ dialog = qck_desktop_entry_dialog_new (_("Launcher Properties"), NULL, desktop_entry);
+ gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_HELP, GTK_RESPONSE_HELP);
+ gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_REVERT_TO_SAVED, QCK_RESPONSE_REVERT);
+ gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
+
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), QCK_RESPONSE_REVERT, FALSE);
+
+ g_signal_connect (dialog,
+ "destroy",
+ G_CALLBACK (edit_desktop_entry_dialog_destroy_cb),
+ data);
+ g_signal_connect (dialog,
+ "response",
+ G_CALLBACK (edit_desktop_entry_dialog_response_cb),
+ data);
+ g_signal_connect (dialog,
+ "changed",
+ G_CALLBACK (edit_desktop_entry_dialog_changed_cb),
+ data);
+
+ gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
+ gtk_window_present (GTK_WINDOW (dialog));
}
@@ -566,8 +416,7 @@
const char *uri;
QuickLounge *quick_lounge;
- quick_lounge = g_object_get_data (G_OBJECT (quick_box),
- "quick_lounge");
+ quick_lounge = g_object_get_data (G_OBJECT (quick_box), "quick_lounge");
uri = g_object_get_data (G_OBJECT (button), "uri");
if (uri != NULL) {
@@ -654,122 +503,109 @@
static void
-new_launcher_dialog_response_cb (GtkWidget *dialog,
- int response,
- GtkWidget *data)
-{
- QuickLounge *quick_lounge;
- GnomeDItemEdit *dedit;
- gpointer ppos;
- int pos;
-
- quick_lounge = g_object_get_data (G_OBJECT (dialog), "quick_lounge");
- dedit = g_object_get_data (G_OBJECT (dialog), "ditem_edit");
- ppos = g_object_get_data (G_OBJECT (dialog), "position");
- pos = GPOINTER_TO_INT (ppos);
-
- if (response == GTK_RESPONSE_HELP) {
- GError *error = NULL;
-
- gnome_help_display_desktop_on_screen (NULL,
- "user-guide",
- "user-guide.xml",
- "gospanel-52",
- gtk_window_get_screen (GTK_WINDOW (dialog)),
- &error);
-
- if (error) {
- GtkWidget *message_dialog;
- message_dialog = gtk_message_dialog_new (NULL, 0,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- _("There was an error displaying help: %s"),
- error->message);
- g_error_free (error);
- gtk_dialog_run (GTK_DIALOG (message_dialog));
- gtk_widget_destroy (message_dialog);
- }
+new_desktop_entry_dialog_response_cb (GtkDialog *dialog,
+ int response,
+ gpointer user_data)
+{
+ EditItemData *edit_data = user_data;
+ GKeyFile *desktop_entry;
+ GError *error = NULL;
+ char *data;
+ gsize length;
+ char *uri;
+ GFile *file;
+
+ switch (response) {
+ case GTK_RESPONSE_HELP:
+ _gtk_show_help (NULL, "user-guide", "gospanel-52");
+ break;
+
+ case GTK_RESPONSE_CANCEL:
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ break;
+
+ default:
+ break;
}
- else if (response == GTK_RESPONSE_OK) {
- GnomeDesktopItem *ditem;
- char *uri, *path;
- GFile *file;
- GError *error = NULL;
-
- uri = quick_lounge_util__get_unique_uri (quick_lounge);
-
- file = g_file_new_for_uri (uri);
- path = g_file_get_path (file);
- g_object_unref (file);
-
- ditem = gnome_ditem_edit_get_ditem (dedit);
- gnome_desktop_item_set_location_file (ditem, path);
- g_free (path);
-
- if (! gnome_desktop_item_save (ditem, NULL, TRUE, &error)) {
- _gtk_error_dialog_run (NULL,
- ERROR_FORMAT,
- _("Could not create the new launcher"),
- error->message);
- g_free (uri);
- g_clear_error (&error);
- gtk_widget_destroy (dialog);
- return;
- }
-
- quick_box_add_button (quick_lounge->quick_box, uri, pos + 1);
- g_free (uri);
-
- quick_lounge_save_order (quick_lounge);
- dlg_properties_update (quick_lounge->prop_dialog);
+
+ if (response != GTK_RESPONSE_OK)
+ return;
+
+ desktop_entry = qck_desktop_entry_dialog_get_entry (QCK_DESKTOP_ENTRY_DIALOG (dialog), &error);
+ if (error != NULL) {
+ _gtk_error_dialog_run (NULL,
+ ERROR_FORMAT,
+ _("Could not create the new launcher"),
+ error->message);
+ g_clear_error (&error);
+ return;
+ }
+
+ if (desktop_entry == NULL)
+ return;
+
+ data = g_key_file_to_data (desktop_entry, &length, &error);
+ if (data == NULL) {
+ g_key_file_free (desktop_entry);
+ _gtk_error_dialog_run (NULL,
+ ERROR_FORMAT,
+ _("Could not create the new launcher"),
+ error->message);
+ g_clear_error (&error);
+ return;
+ }
+
+ uri = quick_lounge_util__get_unique_uri (edit_data->quick_lounge);
+ file = g_file_new_for_uri (uri);
+ if (! g_write_file (file, FALSE, G_FILE_CREATE_NONE, data, length, NULL, &error)) {
+ _gtk_error_dialog_run (NULL,
+ ERROR_FORMAT,
+ _("Could not create the new launcher"),
+ error->message);
+ g_clear_error (&error);
+ }
+ else {
+ quick_box_add_button (edit_data->quick_lounge->quick_box, uri, edit_data->position + 1);
+ quick_lounge_save_order (edit_data->quick_lounge);
+ dlg_properties_update (edit_data->quick_lounge->prop_dialog);
- gtk_widget_destroy (dialog);
+ gtk_widget_destroy (GTK_WIDGET (dialog));
}
- else if (response == GTK_RESPONSE_CANCEL)
- gtk_widget_destroy (dialog);
+
+ g_object_unref (file);
+ g_free (uri);
+ g_free (data);
+ g_key_file_free (desktop_entry);
}
void
quick_lounge_new_launcher (QuickLounge *quick_lounge,
- int pos)
+ int position)
{
- GtkWidget *widget;
- GtkDialog *dialog;
- GtkWidget *dedit;
-
- widget = gtk_dialog_new_with_buttons (_("New Launcher"),
- NULL, 0 /* flags */,
- GTK_STOCK_HELP, GTK_RESPONSE_HELP,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OK, GTK_RESPONSE_OK,
- NULL);
- gtk_window_set_icon_name (GTK_WINDOW (widget), "quick-lounge-applet");
- gtk_window_set_screen (GTK_WINDOW (widget), gtk_widget_get_screen (GTK_WIDGET (quick_lounge->applet)));
-
- dialog = GTK_DIALOG (widget);
-
- gtk_dialog_set_has_separator (dialog, FALSE);
- gtk_dialog_set_default_response (dialog, GTK_RESPONSE_OK);
-
- dedit = gnome_ditem_edit_new ();
- gtk_widget_show (dedit);
-
- gtk_box_pack_start (GTK_BOX (dialog->vbox), dedit, TRUE, TRUE, 0);
- gtk_container_set_border_width (GTK_CONTAINER (dialog), 6);
- gtk_container_set_border_width (GTK_CONTAINER (dedit), 6);
- gtk_box_set_spacing (GTK_BOX (dialog->vbox), 6);
-
- g_object_set_data (G_OBJECT (dialog), "quick_lounge", quick_lounge);
- g_object_set_data (G_OBJECT (dialog), "ditem_edit", dedit);
- g_object_set_data (G_OBJECT (dialog), "position", GINT_TO_POINTER (pos));
-
- g_signal_connect (G_OBJECT (dialog), "response",
- G_CALLBACK (new_launcher_dialog_response_cb),
- dialog);
+ EditItemData *data;
+ GtkWidget *dialog;
+
+ data = g_new0 (EditItemData, 1);
+ data->quick_lounge = quick_lounge;
+ data->position = position;
+
+ dialog = qck_desktop_entry_dialog_new (_("New Launcher"), NULL, NULL);
+ gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_HELP, GTK_RESPONSE_HELP);
+ gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
+ gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_OK, GTK_RESPONSE_OK);
+
+ g_signal_connect (dialog,
+ "destroy",
+ G_CALLBACK (edit_desktop_entry_dialog_destroy_cb),
+ data);
+ g_signal_connect (dialog,
+ "response",
+ G_CALLBACK (new_desktop_entry_dialog_response_cb),
+ data);
- gnome_ditem_edit_grab_focus (GNOME_DITEM_EDIT (dedit));
- gtk_widget_show (widget);
+ gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
+ gtk_window_present (GTK_WINDOW (dialog));
}
@@ -1052,28 +888,25 @@
void
quick_lounge_save_order (QuickLounge *quick_lounge)
{
- PanelApplet *applet = PANEL_APPLET (quick_lounge->applet);
- GConfClient *client;
- char *full_key;
- GList *children, *scan;
- GSList *uri_list = NULL;
+ PanelApplet *applet = PANEL_APPLET (quick_lounge->applet);
+ GConfClient *client;
+ char *full_key;
+ GList *children, *scan;
+ GSList *uri_list = NULL;
children = gtk_container_get_children (GTK_CONTAINER (quick_lounge->quick_box));
for (scan = children; scan; scan = scan->next) {
- GtkWidget *child_widget = scan->data;
- GnomeDesktopItem *ditem;
-
+ GtkWidget *child_widget = scan->data;
+ char *uri;
+
if (QUICK_IS_SEPARATOR (child_widget)) {
uri_list = g_slist_prepend (uri_list, g_strdup (""));
continue;
}
- ditem = g_object_get_data (G_OBJECT (child_widget), "ditem");
- if (ditem != NULL) {
- const char *uri;
- uri = file_name_from_path (gnome_desktop_item_get_location (ditem));
- uri_list = g_slist_prepend (uri_list, g_strdup (uri));
- }
+ uri = g_object_get_data (G_OBJECT (child_widget), "uri");
+ if (uri != NULL)
+ uri_list = g_slist_prepend (uri_list, g_strdup (file_name_from_path (uri)));
}
g_list_free (children);
@@ -1387,7 +1220,7 @@
char *unique_dir = NULL;
base_dir = g_build_filename (g_get_home_dir (), BASE_DIR, NULL);
- ensure_dir_exists (base_dir, 0700, NULL);
+ make_directory_tree_from_path (base_dir, 0700, NULL);
while (unique_dir == NULL) {
char *path;
@@ -1407,7 +1240,7 @@
}
g_free (base_dir);
- ensure_dir_exists (unique_dir, 0700, NULL);
+ make_directory_tree_from_path (unique_dir, 0700, NULL);
return unique_dir;
}
@@ -1470,12 +1303,6 @@
quick_lounge->applet = GTK_WIDGET (applet);
quick_lounge->size = panel_applet_get_size (applet);
quick_lounge->orientation = panel_applet_get_orient (applet);
-
- quick_lounge->ditem_hash = g_hash_table_new_full (g_str_hash,
- g_str_equal,
- g_free,
- NULL);
-
quick_lounge->icon_theme = gtk_icon_theme_get_default ();
/**/
Modified: trunk/src/quick-lounge.h
==============================================================================
--- trunk/src/quick-lounge.h (original)
+++ trunk/src/quick-lounge.h Sun Feb 1 21:46:59 2009
@@ -38,9 +38,6 @@
char *location;
int size;
PanelAppletOrient orientation;
-
- GHashTable *ditem_hash;
-
GtkIconTheme *icon_theme;
} QuickLounge;
Modified: trunk/src/quick-separator.c
==============================================================================
--- trunk/src/quick-separator.c (original)
+++ trunk/src/quick-separator.c Sun Feb 1 21:46:59 2009
@@ -195,14 +195,13 @@
object = g_object_new (quick_separator_get_type (), NULL);
- button = QUICK_BUTTON (object);
- button->icon_path = NULL;
- button->size = size;
- button->text = NULL;
-
- sep = QUICK_SEPARATOR (object);
+ button = QUICK_BUTTON (object);
+ button->name = NULL;
+ button->icon = NULL;
+ button->size = size;
+ sep = QUICK_SEPARATOR (object);
sep->panel_size = panel_size;
- sep->orient = orient;
+ sep->orient = orient;
return GTK_WIDGET (object);
}
@@ -210,7 +209,7 @@
static void
quick_separator_set_pixmap (QuickButton *button,
- const char *icon_path,
+ const char *icon,
int size)
{
g_return_if_fail (QUICK_IS_BUTTON (button));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]