[gnome-panel/wip/muktupavels/launcher] panel: remove old launcher object
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel/wip/muktupavels/launcher] panel: remove old launcher object
- Date: Mon, 13 Apr 2020 02:05:58 +0000 (UTC)
commit d106e7c5d8499318d1846096e3276b65720ad05b
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Sun Apr 12 17:37:13 2020 +0300
panel: remove old launcher object
Existing launcher objects will be turned into applets.
We still need PanelDItemEditor to create new launcher from drag &
drop.
gnome-panel/Makefile.am | 2 -
gnome-panel/applet.c | 12 +-
gnome-panel/applet.h | 3 -
gnome-panel/button-widget.c | 34 -
gnome-panel/button-widget.h | 4 -
gnome-panel/launcher.c | 1184 -----------------------------
gnome-panel/launcher.h | 64 --
gnome-panel/libpanel-util/panel-keyfile.c | 51 --
gnome-panel/libpanel-util/panel-keyfile.h | 4 -
gnome-panel/libpanel-util/panel-launch.c | 30 +-
gnome-panel/libpanel-util/panel-launch.h | 11 -
gnome-panel/panel-addto-dialog.c | 407 +---------
gnome-panel/panel-addto-dialog.ui | 23 +-
gnome-panel/panel-ditem-editor.c | 685 +----------------
gnome-panel/panel-ditem-editor.h | 31 +-
gnome-panel/panel-enums.h | 1 -
gnome-panel/panel-object-loader.c | 9 +-
gnome-panel/panel-util.c | 69 +-
gnome-panel/panel-util.h | 13 -
gnome-panel/panel.c | 329 ++++++--
po/POTFILES.in | 1 -
21 files changed, 329 insertions(+), 2638 deletions(-)
---
diff --git a/gnome-panel/Makefile.am b/gnome-panel/Makefile.am
index 583c0c998..509901dc2 100644
--- a/gnome-panel/Makefile.am
+++ b/gnome-panel/Makefile.am
@@ -32,7 +32,6 @@ panel_sources = \
panel-util.c \
panel-run-dialog.c \
panel-context-menu.c \
- launcher.c \
panel-applet-frame.c \
panel-applets-manager.c \
panel-action-button.c \
@@ -60,7 +59,6 @@ panel_headers = \
panel-util.h \
panel-run-dialog.h \
panel-context-menu.h \
- launcher.h \
panel-applet-frame.h \
panel-applets-manager.h \
panel-action-button.h \
diff --git a/gnome-panel/applet.c b/gnome-panel/applet.c
index ece1599e9..7779e22c5 100644
--- a/gnome-panel/applet.c
+++ b/gnome-panel/applet.c
@@ -19,7 +19,6 @@
#include <libpanel-util/panel-show.h>
#include "button-widget.h"
-#include "launcher.h"
#include "panel.h"
#include "panel-bindings.h"
#include "panel-applet-frame.h"
@@ -72,9 +71,6 @@ panel_applet_clean (AppletInfo *info)
{
g_return_if_fail (info != NULL);
- if (info->type == PANEL_OBJECT_LAUNCHER)
- panel_launcher_delete (info->data);
-
if (info->widget) {
GtkWidget *widget = info->widget;
@@ -136,12 +132,6 @@ applet_callback_callback (GtkWidget *widget,
g_return_if_fail (menu->info != NULL);
switch (menu->info->type) {
- case PANEL_OBJECT_LAUNCHER:
- if (!strcmp (menu->name, "launch"))
- launcher_launch (menu->info->data, widget);
- else if (!strcmp (menu->name, "properties"))
- launcher_properties (menu->info->data);
- break;
case PANEL_OBJECT_ACTION:
panel_action_button_invoke_menu (
PANEL_ACTION_BUTTON (menu->info->widget), menu->name);
@@ -181,7 +171,7 @@ applet_menu_deactivate (GtkWidget *w,
panel_toplevel_pop_autohide_disabler (panel_widget->toplevel);
}
-AppletUserMenu *
+static AppletUserMenu *
panel_applet_get_callback (GList *user_menu,
const char *name)
{
diff --git a/gnome-panel/applet.h b/gnome-panel/applet.h
index 3edfa56e8..91541737d 100644
--- a/gnome-panel/applet.h
+++ b/gnome-panel/applet.h
@@ -64,9 +64,6 @@ void panel_applet_add_callback (AppletInfo *info,
const gchar *menuitem_text,
CallbackEnabledFunc is_enabled_func);
-AppletUserMenu *panel_applet_get_callback (GList *user_menu,
- const gchar *name);
-
void panel_applet_save_position (AppletInfo *applet_info,
const char *id,
gboolean immediate);
diff --git a/gnome-panel/button-widget.c b/gnome-panel/button-widget.c
index e223805ab..c5904565a 100644
--- a/gnome-panel/button-widget.c
+++ b/gnome-panel/button-widget.c
@@ -605,21 +605,6 @@ button_widget_class_init (ButtonWidgetClass *klass)
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
}
-GtkWidget *
-button_widget_new (const char *filename,
- PanelOrientation orientation)
-{
- GtkWidget *retval;
-
- retval = g_object_new (
- BUTTON_TYPE_WIDGET,
- "orientation", orientation,
- "icon-name", filename,
- NULL);
-
- return retval;
-}
-
void
button_widget_set_activatable (ButtonWidget *button,
gboolean activatable)
@@ -688,14 +673,6 @@ button_widget_set_orientation (ButtonWidget *button,
g_object_notify (G_OBJECT (button), "orientation");
}
-PanelOrientation
-button_widget_get_orientation (ButtonWidget *button)
-{
- g_return_val_if_fail (BUTTON_IS_WIDGET (button), 0);
-
- return button->priv->orientation;
-}
-
void
button_widget_set_dnd_highlight (ButtonWidget *button,
gboolean dnd_highlight)
@@ -721,14 +698,3 @@ button_widget_get_icon_theme (ButtonWidget *button)
return button->priv->icon_theme;
}
-
-GdkPixbuf *
-button_widget_get_pixbuf (ButtonWidget *button)
-{
- g_return_val_if_fail (BUTTON_IS_WIDGET (button), NULL);
-
- if (!button->priv->pixbuf)
- return NULL;
-
- return g_object_ref (button->priv->pixbuf);
-}
diff --git a/gnome-panel/button-widget.h b/gnome-panel/button-widget.h
index dc87fd3d1..91fcb2a65 100644
--- a/gnome-panel/button-widget.h
+++ b/gnome-panel/button-widget.h
@@ -27,19 +27,15 @@ struct _ButtonWidgetClass {
};
GType button_widget_get_type (void) G_GNUC_CONST;
-GtkWidget * button_widget_new (const char *pixmap,
- PanelOrientation orientation);
void button_widget_set_activatable (ButtonWidget *button,
gboolean activatable);
void button_widget_set_icon_name (ButtonWidget *button,
const char *icon_name);
void button_widget_set_orientation (ButtonWidget *button,
PanelOrientation orientation);
-PanelOrientation button_widget_get_orientation (ButtonWidget *button);
void button_widget_set_dnd_highlight (ButtonWidget *button,
gboolean dnd_highlight);
GtkIconTheme *button_widget_get_icon_theme (ButtonWidget *button);
-GdkPixbuf *button_widget_get_pixbuf (ButtonWidget *button);
G_END_DECLS
diff --git a/gnome-panel/libpanel-util/panel-keyfile.c b/gnome-panel/libpanel-util/panel-keyfile.c
index b43792491..64efb4560 100644
--- a/gnome-panel/libpanel-util/panel-keyfile.c
+++ b/gnome-panel/libpanel-util/panel-keyfile.c
@@ -152,57 +152,6 @@ panel_key_file_to_file (GKeyFile *keyfile,
return res;
}
-gboolean
-panel_key_file_load_from_uri (GKeyFile *keyfile,
- const gchar *uri,
- GKeyFileFlags flags,
- GError **error)
-{
- char *scheme;
- gboolean is_local;
- gboolean result;
-
- g_return_val_if_fail (keyfile != NULL, FALSE);
- g_return_val_if_fail (uri != NULL, FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- scheme = g_uri_parse_scheme (uri);
- is_local = (scheme == NULL) || !g_ascii_strcasecmp (scheme, "file");
- g_free (scheme);
-
- if (is_local) {
- char *path;
-
- if (g_path_is_absolute (uri))
- path = g_filename_from_utf8 (uri, -1, NULL, NULL, NULL);
- else
- path = g_filename_from_uri (uri, NULL, NULL);
- result = g_key_file_load_from_file (keyfile, path,
- flags, error);
- g_free (path);
- } else {
- GFile *file;
- char *contents;
- gsize size;
- gboolean ret;
-
- file = g_file_new_for_uri (uri);
- ret = g_file_load_contents (file, NULL, &contents, &size,
- NULL, NULL);
- g_object_unref (file);
-
- if (!ret)
- return FALSE;
-
- result = g_key_file_load_from_data (keyfile, contents, size,
- flags, error);
-
- g_free (contents);
- }
-
- return result;
-}
-
gboolean
panel_key_file_get_boolean (GKeyFile *keyfile,
const gchar *key,
diff --git a/gnome-panel/libpanel-util/panel-keyfile.h b/gnome-panel/libpanel-util/panel-keyfile.h
index 7c5060f73..0db2d39fe 100644
--- a/gnome-panel/libpanel-util/panel-keyfile.h
+++ b/gnome-panel/libpanel-util/panel-keyfile.h
@@ -34,10 +34,6 @@ GKeyFile *panel_key_file_new_desktop (void);
gboolean panel_key_file_to_file (GKeyFile *keyfile,
const gchar *file,
GError **error);
-gboolean panel_key_file_load_from_uri (GKeyFile *keyfile,
- const gchar *uri,
- GKeyFileFlags flags,
- GError **error);
gboolean panel_key_file_get_boolean (GKeyFile *keyfile,
const gchar *key,
diff --git a/gnome-panel/libpanel-util/panel-launch.c b/gnome-panel/libpanel-util/panel-launch.c
index 44ebfdef1..290315ef2 100644
--- a/gnome-panel/libpanel-util/panel-launch.c
+++ b/gnome-panel/libpanel-util/panel-launch.c
@@ -99,7 +99,7 @@ gather_pid_callback (GDesktopAppInfo *gapp,
g_child_watch_add (pid, dummy_child_watch, NULL);
}
-gboolean
+static gboolean
panel_app_info_launch_uris (GAppInfo *appinfo,
GList *uris,
GdkScreen *screen,
@@ -132,34 +132,6 @@ panel_app_info_launch_uris (GAppInfo *appinfo,
screen, local_error, error);
}
-gboolean
-panel_launch_key_file (GKeyFile *keyfile,
- GList *uri_list,
- GdkScreen *screen,
- GError **error)
-{
- GDesktopAppInfo *appinfo;
- gboolean retval;
-
- g_return_val_if_fail (keyfile != NULL, FALSE);
- g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- appinfo = g_desktop_app_info_new_from_keyfile (keyfile);
-
- if (appinfo == NULL)
- return FALSE;
-
- retval = panel_app_info_launch_uris (G_APP_INFO (appinfo),
- uri_list, screen,
- gtk_get_current_event_time (),
- error);
-
- g_object_unref (appinfo);
-
- return retval;
-}
-
gboolean
panel_launch_desktop_file (const char *desktop_file,
GdkScreen *screen,
diff --git a/gnome-panel/libpanel-util/panel-launch.h b/gnome-panel/libpanel-util/panel-launch.h
index b2c5a4bd3..608482bca 100644
--- a/gnome-panel/libpanel-util/panel-launch.h
+++ b/gnome-panel/libpanel-util/panel-launch.h
@@ -28,17 +28,6 @@
G_BEGIN_DECLS
-gboolean panel_app_info_launch_uris (GAppInfo *appinfo,
- GList *uris,
- GdkScreen *screen,
- guint32 timestamp,
- GError **error);
-
-gboolean panel_launch_key_file (GKeyFile *keyfile,
- GList *uri_list,
- GdkScreen *screen,
- GError **error);
-
gboolean panel_launch_desktop_file (const char *desktop_file,
GdkScreen *screen,
GError **error);
diff --git a/gnome-panel/panel-addto-dialog.c b/gnome-panel/panel-addto-dialog.c
index 1193be920..1163a6047 100644
--- a/gnome-panel/panel-addto-dialog.c
+++ b/gnome-panel/panel-addto-dialog.c
@@ -26,11 +26,8 @@
#include <glib/gi18n.h>
#include <gdk/gdkx.h>
-#include <gmenu-tree.h>
-
#include <libpanel-util/panel-glib.h>
-#include "launcher.h"
#include "panel.h"
#include "panel-applets-manager.h"
#include "panel-applet-frame.h"
@@ -50,22 +47,14 @@ struct _PanelAddtoDialog
GtkWidget *dialog_vbox;
GtkWidget *label;
GtkWidget *search_entry;
- GtkWidget *back_button;
GtkWidget *add_button;
GtkWidget *close_button;
GtkWidget *tree_view;
- GtkWidget *tree_view_selection;
GtkTreeModel *applet_model;
GtkTreeModel *filter_applet_model;
- GtkTreeModel *application_model;
- GtkTreeModel *filter_application_model;
-
- GMenuTree *menu_tree;
GSList *applet_list;
- GSList *application_list;
- GSList *settings_list;
gchar *search_text;
gchar *applet_search_text;
@@ -79,11 +68,7 @@ static GQuark panel_addto_dialog_quark = 0;
typedef enum {
PANEL_ADDTO_APPLET,
- PANEL_ADDTO_ACTION,
- PANEL_ADDTO_LAUNCHER_MENU,
- PANEL_ADDTO_LAUNCHER,
- PANEL_ADDTO_LAUNCHER_NEW,
- PANEL_ADDTO_MENU
+ PANEL_ADDTO_ACTION
} PanelAddtoItemType;
typedef struct {
@@ -92,7 +77,6 @@ typedef struct {
char *description;
GIcon *icon;
PanelActionButtonType action_type;
- char *launcher_path;
char *iid;
} PanelAddtoItemInfo;
@@ -109,8 +93,6 @@ enum {
NUMBER_COLUMNS
};
-static void panel_addto_present_applications (PanelAddtoDialog *dialog);
-static void panel_addto_present_applets (PanelAddtoDialog *dialog);
static gboolean panel_addto_filter_func (GtkTreeModel *model,
GtkTreeIter *iter,
gpointer data);
@@ -243,23 +225,6 @@ panel_addto_setup_drag (GtkTreeView *tree_view,
NULL);
}
-static void
-panel_addto_setup_launcher_drag (GtkTreeView *tree_view,
- const char *path)
-{
- static const GtkTargetEntry target[] = {
- { (gchar *) "text/uri-list", 0, 0 }
- };
- char *uri;
- char *uri_list;
-
- uri = g_filename_to_uri (path, NULL, NULL);
- uri_list = g_strconcat (uri, "\r\n", NULL);
- panel_addto_setup_drag (tree_view, target, uri_list);
- g_free (uri_list);
- g_free (uri);
-}
-
static void
panel_addto_setup_applet_drag (GtkTreeView *tree_view,
const char *iid)
@@ -356,33 +321,6 @@ panel_addto_append_item (PanelAddtoDialog *dialog,
}
}
-static void
-panel_addto_append_special_applets (PanelAddtoDialog *dialog,
- GtkListStore *model)
-{
- PanelAddtoItemInfo *special;
-
- if (!panel_lockdown_get_disable_command_line_s ()) {
- special = g_new0 (PanelAddtoItemInfo, 1);
- special->type = PANEL_ADDTO_LAUNCHER_NEW;
- special->name = g_strdup (_("Custom Application Launcher"));
- special->description = g_strdup (_("Create a new launcher"));
- special->icon = g_themed_icon_new (PANEL_ICON_LAUNCHER);
- special->action_type = PANEL_ACTION_NONE;
- special->iid = g_strdup ("LAUNCHER:ASK");
- panel_addto_append_item (dialog, model, special);
- }
-
- special = g_new0 (PanelAddtoItemInfo, 1);
- special->type = PANEL_ADDTO_LAUNCHER_MENU;
- special->name = g_strdup (_("Application Launcher..."));
- special->description = g_strdup (_("Copy a launcher from the applications menu"));
- special->icon = g_themed_icon_new (PANEL_ICON_LAUNCHER);
- special->action_type = PANEL_ACTION_NONE;
- special->iid = g_strdup ("LAUNCHER:MENU");
- panel_addto_append_item (dialog, model, special);
-}
-
static void
panel_addto_make_applet_model (PanelAddtoDialog *dialog)
{
@@ -407,7 +345,6 @@ panel_addto_make_applet_model (PanelAddtoDialog *dialog)
G_TYPE_STRING);
if (panel_layout_is_writable ()) {
- panel_addto_append_special_applets (dialog, model);
if (dialog->applet_list)
panel_addto_append_item (dialog, model, NULL);
}
@@ -423,257 +360,6 @@ panel_addto_make_applet_model (PanelAddtoDialog *dialog)
dialog, NULL);
}
-typedef enum {
- PANEL_ADDTO_MENU_SHOW_DIRECTORIES = 1 << 0,
- PANEL_ADDTO_MENU_SHOW_ENTRIES = 1 << 1,
- PANEL_ADDTO_MENU_SHOW_ALIAS = 1 << 2
-#define PANEL_ADDTO_MENU_SHOW_ALL (PANEL_ADDTO_MENU_SHOW_DIRECTORIES | PANEL_ADDTO_MENU_SHOW_ENTRIES |
PANEL_ADDTO_MENU_SHOW_ALIAS)
-} PanelAddtoMenuShowFlags;
-
-static void panel_addto_make_application_list (GSList **parent_list,
- GMenuTreeDirectory *directory,
- const char *filename,
- PanelAddtoMenuShowFlags show_flags);
-
-static void
-panel_addto_prepend_directory (GSList **parent_list,
- GMenuTreeDirectory *directory,
- const char *filename)
-{
- PanelAddtoAppList *data;
- GIcon *icon;
-
- data = g_new0 (PanelAddtoAppList, 1);
-
- icon = gmenu_tree_directory_get_icon (directory);
- if (icon)
- g_object_ref (icon);
-
- data->item_info.type = PANEL_ADDTO_MENU;
- data->item_info.name = g_strdup (gmenu_tree_directory_get_name (directory));
- data->item_info.description = g_strdup (gmenu_tree_directory_get_comment (directory));
- data->item_info.icon = icon;
-
- *parent_list = g_slist_prepend (*parent_list, data);
-
- /* We always want to show everything in non-root directories */
- panel_addto_make_application_list (&data->children, directory,
- filename, PANEL_ADDTO_MENU_SHOW_ALL);
-}
-
-static void
-panel_addto_prepend_entry (GSList **parent_list,
- GMenuTreeEntry *entry,
- const char *filename)
-{
- PanelAddtoAppList *data;
- GAppInfo *app_info;
- GIcon *icon;
-
- data = g_new0 (PanelAddtoAppList, 1);
-
- app_info = G_APP_INFO (gmenu_tree_entry_get_app_info (entry));
-
- icon = g_app_info_get_icon (app_info);
- if (icon)
- g_object_ref (icon);
-
- data->item_info.type = PANEL_ADDTO_LAUNCHER;
- data->item_info.name = g_strdup (g_app_info_get_display_name (app_info));
- data->item_info.description = g_strdup (g_app_info_get_description (app_info));
- data->item_info.icon = icon;
- data->item_info.launcher_path = g_strdup (gmenu_tree_entry_get_desktop_file_path (entry));
-
- *parent_list = g_slist_prepend (*parent_list, data);
-}
-
-static void
-panel_addto_prepend_alias (GSList **parent_list,
- GMenuTreeAlias *alias,
- const char *filename)
-{
- GMenuTreeItemType type;
-
- type = gmenu_tree_alias_get_aliased_item_type (alias);
-
- if (type == GMENU_TREE_ITEM_DIRECTORY) {
- GMenuTreeDirectory *directory = gmenu_tree_alias_get_aliased_directory (alias);
- panel_addto_prepend_directory (parent_list,
- directory,
- filename);
- gmenu_tree_item_unref (directory);
- } else if (type == GMENU_TREE_ITEM_ENTRY) {
- GMenuTreeEntry *entry = gmenu_tree_alias_get_aliased_entry (alias);
- panel_addto_prepend_entry (parent_list,
- entry,
- filename);
- gmenu_tree_item_unref (entry);
- }
-}
-
-static void
-panel_addto_make_application_list (GSList **parent_list,
- GMenuTreeDirectory *directory,
- const char *filename,
- PanelAddtoMenuShowFlags show_flags)
-{
- GMenuTreeIter *iter;
- GMenuTreeItemType next_type;
-
- iter = gmenu_tree_directory_iter (directory);
-
- while ((next_type = gmenu_tree_iter_next (iter)) != GMENU_TREE_ITEM_INVALID) {
- if (next_type == GMENU_TREE_ITEM_DIRECTORY) {
- if (show_flags & PANEL_ADDTO_MENU_SHOW_DIRECTORIES) {
- GMenuTreeDirectory *dir = gmenu_tree_iter_get_directory (iter);
- panel_addto_prepend_directory (parent_list, dir, filename);
- gmenu_tree_item_unref (dir);
- }
- } else if (next_type == GMENU_TREE_ITEM_ENTRY) {
- if (show_flags & PANEL_ADDTO_MENU_SHOW_ENTRIES) {
- GMenuTreeEntry *entry = gmenu_tree_iter_get_entry (iter);
- panel_addto_prepend_entry (parent_list, entry, filename);
- gmenu_tree_item_unref (entry);
- }
- } else if (next_type == GMENU_TREE_ITEM_ALIAS) {
- if (show_flags & PANEL_ADDTO_MENU_SHOW_ALIAS) {
- GMenuTreeAlias *alias = gmenu_tree_iter_get_alias (iter);
- panel_addto_prepend_alias (parent_list, alias, filename);
- gmenu_tree_item_unref (alias);
- }
- }
- }
- gmenu_tree_iter_unref (iter);
-
- *parent_list = g_slist_reverse (*parent_list);
-}
-
-static void
-panel_addto_populate_application_model (GtkTreeStore *store,
- GtkTreeIter *parent,
- GSList *app_list)
-{
- PanelAddtoAppList *data;
- GtkTreeIter iter;
- char *text;
- GSList *app;
-
- for (app = app_list; app != NULL; app = app->next) {
- PanelAddtoItemInfo *column_data;
-
- data = app->data;
- gtk_tree_store_append (store, &iter, parent);
-
- text = panel_addto_make_text (data->item_info.name,
- data->item_info.description);
-
- column_data = NULL;
- if (data->item_info.type != PANEL_ADDTO_MENU)
- column_data = &data->item_info;
-
- gtk_tree_store_set (store, &iter,
- COLUMN_ICON, data->item_info.icon,
- COLUMN_TEXT, text,
- COLUMN_DATA, column_data,
- COLUMN_SEARCH, data->item_info.name,
- -1);
-
- g_free (text);
-
- if (data->children != NULL)
- panel_addto_populate_application_model (store,
- &iter,
- data->children);
- }
-}
-
-static gchar *
-get_applications_menu (void)
-{
- const gchar *xdg_menu_prefx = g_getenv ("XDG_MENU_PREFIX");
- return g_strdup_printf ("%sapplications.menu",
- !PANEL_GLIB_STR_EMPTY (xdg_menu_prefx) ? xdg_menu_prefx : "gnome-");
-}
-
-static void
-panel_addto_make_application_model (PanelAddtoDialog *dialog)
-{
- GtkTreeStore *store;
- GMenuTree *tree;
- GMenuTreeDirectory *root;
- gchar *applications_menu;
-
- if (dialog->filter_application_model != NULL)
- return;
-
- store = gtk_tree_store_new (NUMBER_COLUMNS,
- G_TYPE_ICON,
- G_TYPE_STRING,
- G_TYPE_POINTER,
- G_TYPE_STRING);
-
- applications_menu = get_applications_menu ();
- tree = gmenu_tree_new (applications_menu, GMENU_TREE_FLAGS_SORT_DISPLAY_NAME);
-
- if (!gmenu_tree_load_sync (tree, NULL)) {
- g_object_unref (tree);
- tree = NULL;
- }
-
- if (tree != NULL && (root = gmenu_tree_get_root_directory (tree))) {
- panel_addto_make_application_list (&dialog->application_list,
- root, applications_menu,
- PANEL_ADDTO_MENU_SHOW_ALL);
- panel_addto_populate_application_model (store, NULL, dialog->application_list);
-
- gmenu_tree_item_unref (root);
- }
-
- g_free (applications_menu);
-
- if (tree != NULL)
- g_object_unref (tree);
-
- tree = gmenu_tree_new ("gnomecc.menu", GMENU_TREE_FLAGS_SORT_DISPLAY_NAME);
-
- if (!gmenu_tree_load_sync (tree, NULL)) {
- g_object_unref (tree);
- tree = NULL;
- }
-
- if (tree != NULL && (root = gmenu_tree_get_root_directory (tree))) {
- GtkTreeIter iter;
-
- gtk_tree_store_append (store, &iter, NULL);
- gtk_tree_store_set (store, &iter,
- COLUMN_ICON, NULL,
- COLUMN_TEXT, NULL,
- COLUMN_DATA, NULL,
- COLUMN_SEARCH, NULL,
- -1);
-
- /* The gnome-control-center shell does not display toplevel
- * entries that are not directories, so do the same. */
- panel_addto_make_application_list (&dialog->settings_list,
- root, "gnomecc.menu",
- PANEL_ADDTO_MENU_SHOW_DIRECTORIES);
- panel_addto_populate_application_model (store, NULL,
- dialog->settings_list);
-
- gmenu_tree_item_unref (root);
- }
-
- if (tree != NULL)
- g_object_unref (tree);
-
- dialog->application_model = GTK_TREE_MODEL (store);
- dialog->filter_application_model = gtk_tree_model_filter_new (GTK_TREE_MODEL
(dialog->application_model),
- NULL);
- gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (dialog->filter_application_model),
- panel_addto_filter_func,
- dialog, NULL);
-}
-
typedef struct
{
PanelAddtoDialog *dialog;
@@ -763,20 +449,6 @@ panel_addto_add_item (PanelAddtoDialog *dialog,
pack_index,
item_info->action_type);
break;
- case PANEL_ADDTO_LAUNCHER_MENU:
- panel_addto_present_applications (dialog);
- break;
- case PANEL_ADDTO_LAUNCHER:
- panel_launcher_create (dialog->panel_widget->toplevel,
- dialog->insert_pack_type,
- pack_index,
- item_info->launcher_path);
- break;
- case PANEL_ADDTO_LAUNCHER_NEW:
- ask_about_launcher (NULL, dialog->panel_widget,
- dialog->insert_pack_type);
- break;
- case PANEL_ADDTO_MENU:
default:
break;
}
@@ -810,13 +482,6 @@ panel_addto_dialog_add_button_cb (PanelAddtoDialog *dialog,
}
}
-static void
-panel_addto_dialog_back_button_cb (PanelAddtoDialog *dialog,
- GtkWidget *widget)
-{
- panel_addto_present_applets (dialog);
-}
-
static void
panel_addto_dialog_close_button_cb (PanelAddtoDialog *dialog,
GtkWidget *widget)
@@ -824,25 +489,6 @@ panel_addto_dialog_close_button_cb (PanelAddtoDialog *dialog,
gtk_widget_destroy (GTK_WIDGET (dialog));
}
-static void
-panel_addto_present_applications (PanelAddtoDialog *dialog)
-{
- if (dialog->filter_application_model == NULL)
- panel_addto_make_application_model (dialog);
- gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->tree_view),
- dialog->filter_application_model);
- gtk_window_set_focus (GTK_WINDOW (dialog),
- dialog->search_entry);
- gtk_widget_set_sensitive (dialog->back_button, TRUE);
-
- if (dialog->applet_search_text)
- g_free (dialog->applet_search_text);
-
- dialog->applet_search_text = g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->search_entry)));
- /* show everything */
- gtk_entry_set_text (GTK_ENTRY (dialog->search_entry), "");
-}
-
static void
panel_addto_present_applets (PanelAddtoDialog *dialog)
{
@@ -852,7 +498,6 @@ panel_addto_present_applets (PanelAddtoDialog *dialog)
dialog->filter_applet_model);
gtk_window_set_focus (GTK_WINDOW (dialog),
dialog->search_entry);
- gtk_widget_set_sensitive (dialog->back_button, FALSE);
if (dialog->applet_search_text) {
gtk_entry_set_text (GTK_ENTRY (dialog->search_entry),
@@ -882,29 +527,6 @@ panel_addto_dialog_free_item_info (PanelAddtoItemInfo *item_info)
g_free (item_info->iid);
item_info->iid = NULL;
-
- g_free (item_info->launcher_path);
- item_info->launcher_path = NULL;
-}
-
-static void
-panel_addto_dialog_free_application_list (GSList *application_list)
-{
- PanelAddtoAppList *data;
- GSList *app;
-
- if (application_list == NULL)
- return;
-
- for (app = application_list; app != NULL; app = app->next) {
- data = app->data;
- if (data->children) {
- panel_addto_dialog_free_application_list (data->children);
- }
- panel_addto_dialog_free_item_info (&data->item_info);
- g_free (data);
- }
- g_slist_free (application_list);
}
static void
@@ -1041,26 +663,12 @@ panel_addto_selection_changed (PanelAddtoDialog *dialog,
gtk_widget_set_sensitive (GTK_WIDGET (dialog->add_button), TRUE);
- if (data->type == PANEL_ADDTO_LAUNCHER_MENU) {
- gtk_button_set_label (GTK_BUTTON (dialog->add_button),
- _("_Forward"));
- } else {
- gtk_button_set_label (GTK_BUTTON (dialog->add_button),
- _("_Add"));
- }
-
/* only allow dragging applets if we can add applets */
if (panel_layout_is_writable ()) {
- if (data->type == PANEL_ADDTO_LAUNCHER) {
- panel_addto_setup_launcher_drag (GTK_TREE_VIEW (dialog->tree_view),
- data->launcher_path);
- } else if (data->type == PANEL_ADDTO_APPLET) {
+ if (data->type == PANEL_ADDTO_APPLET) {
panel_addto_setup_applet_drag (GTK_TREE_VIEW (dialog->tree_view),
data->iid);
- } else if (data->type == PANEL_ADDTO_LAUNCHER_MENU) {
- gtk_tree_view_unset_rows_drag_source (GTK_TREE_VIEW (dialog->tree_view));
- } else if (data->type == PANEL_ADDTO_MENU) {
- } else {
+ } else if (data->type == PANEL_ADDTO_ACTION) {
panel_addto_setup_internal_applet_drag (GTK_TREE_VIEW (dialog->tree_view),
data->iid);
}
@@ -1150,9 +758,6 @@ panel_addto_dialog_dispose (GObject *object)
g_clear_object (&dialog->filter_applet_model);
g_clear_object (&dialog->applet_model);
- g_clear_object (&dialog->filter_application_model);
- g_clear_object (&dialog->application_model);
- g_clear_object (&dialog->menu_tree);
G_OBJECT_CLASS (panel_addto_dialog_parent_class)->dispose (object);
}
@@ -1185,9 +790,6 @@ panel_addto_dialog_finalize (GObject *object)
}
g_slist_free (dialog->applet_list);
- panel_addto_dialog_free_application_list (dialog->application_list);
- panel_addto_dialog_free_application_list (dialog->settings_list);
-
G_OBJECT_CLASS (panel_addto_dialog_parent_class)->finalize (object);
}
@@ -1210,13 +812,10 @@ panel_addto_dialog_class_init (PanelAddtoDialogClass *dialog_class)
gtk_widget_class_bind_template_child (widget_class, PanelAddtoDialog, label);
gtk_widget_class_bind_template_child (widget_class, PanelAddtoDialog, search_entry);
gtk_widget_class_bind_template_child (widget_class, PanelAddtoDialog, add_button);
- gtk_widget_class_bind_template_child (widget_class, PanelAddtoDialog, back_button);
gtk_widget_class_bind_template_child (widget_class, PanelAddtoDialog, close_button);
gtk_widget_class_bind_template_child (widget_class, PanelAddtoDialog, tree_view);
- gtk_widget_class_bind_template_child (widget_class, PanelAddtoDialog, tree_view_selection);
gtk_widget_class_bind_template_callback (widget_class, panel_addto_dialog_add_button_cb);
- gtk_widget_class_bind_template_callback (widget_class, panel_addto_dialog_back_button_cb);
gtk_widget_class_bind_template_callback (widget_class, panel_addto_dialog_close_button_cb);
gtk_widget_class_bind_template_callback (widget_class, panel_addto_search_entry_changed);
gtk_widget_class_bind_template_callback (widget_class, panel_addto_search_entry_activated);
diff --git a/gnome-panel/panel-addto-dialog.ui b/gnome-panel/panel-addto-dialog.ui
index dd5f8dad9..954dea770 100644
--- a/gnome-panel/panel-addto-dialog.ui
+++ b/gnome-panel/panel-addto-dialog.ui
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.19.0 -->
+<!-- Generated with glade 3.22.2 -->
<interface>
- <requires lib="gtk+" version="3.16"/>
+ <requires lib="gtk+" version="3.20"/>
<object class="GtkListStore" id="liststore">
<columns>
<!-- column-name icon -->
@@ -14,6 +14,9 @@
<property name="can_focus">False</property>
<property name="border_width">10</property>
<property name="title" translatable="yes">Add to Panel</property>
+ <child type="titlebar">
+ <placeholder/>
+ </child>
<child>
<object class="GtkBox" id="dialog_vbox">
<property name="visible">True</property>
@@ -137,22 +140,6 @@
<property name="can_focus">False</property>
<property name="spacing">5</property>
<property name="layout_style">end</property>
- <child>
- <object class="GtkButton" id="back_button">
- <property name="label" translatable="yes">_Back</property>
- <property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_underline">True</property>
- <signal name="clicked" handler="panel_addto_dialog_back_button_cb" swapped="yes"/>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
<child>
<object class="GtkButton" id="add_button">
<property name="label" translatable="yes">_Add</property>
diff --git a/gnome-panel/panel-ditem-editor.c b/gnome-panel/panel-ditem-editor.c
index cd0413e5e..ff0049083 100644
--- a/gnome-panel/panel-ditem-editor.c
+++ b/gnome-panel/panel-ditem-editor.c
@@ -43,16 +43,10 @@ struct _PanelDItemEditorPrivate
everything in the display so we load a file, or get a ditem,
sync the display and ref the ditem */
GKeyFile *key_file;
- gboolean free_key_file;
- /* the revert ditem will only contain relevant keys */
- GKeyFile *revert_key_file;
- gboolean reverting;
gboolean dirty;
- guint save_timeout;
char *uri; /* file location */
- gboolean new_file;
gboolean combo_setuped;
PanelDitemSaveUri save_uri;
@@ -72,19 +66,10 @@ struct _PanelDItemEditorPrivate
GtkWidget *comment_entry;
GtkWidget *icon_chooser;
- GtkWidget *revert_button;
- GtkWidget *close_button;
GtkWidget *cancel_button;
GtkWidget *ok_button;
};
-/* Time in seconds after which we save the file on the disk */
-#define SAVE_FREQUENCY 2
-
-enum {
- REVERT_BUTTON
-};
-
typedef enum {
PANEL_DITEM_EDITOR_TYPE_NULL,
PANEL_DITEM_EDITOR_TYPE_APPLICATION,
@@ -113,47 +98,12 @@ static ComboItem type_items [] = {
PANEL_DITEM_EDITOR_TYPE_LINK }
};
-typedef struct {
- const char *key;
- GType type;
- gboolean default_value;
- gboolean locale;
-} RevertKey;
-
-static RevertKey revert_keys [] = {
- { "Type", G_TYPE_STRING, FALSE, FALSE },
- { "Terminal", G_TYPE_BOOLEAN, FALSE, FALSE },
- { "Exec", G_TYPE_STRING, FALSE, FALSE },
- { "URL", G_TYPE_STRING, FALSE, FALSE },
- /* locale keys */
- { "Icon", G_TYPE_STRING, FALSE, TRUE },
- { "Name", G_TYPE_STRING, FALSE, TRUE },
- { "Comment", G_TYPE_STRING, FALSE, TRUE },
- { "X-GNOME-FullName", G_TYPE_STRING, FALSE, TRUE },
- /* C version of those keys */
- { "Icon", G_TYPE_STRING, FALSE, FALSE },
- { "Name", G_TYPE_STRING, FALSE, FALSE },
- { "Comment", G_TYPE_STRING, FALSE, FALSE },
- { "X-GNOME-FullName", G_TYPE_STRING, FALSE, FALSE }
-};
-
enum {
SAVED,
- CHANGED,
- NAME_CHANGED,
- COMMAND_CHANGED,
- COMMENT_CHANGED,
- ICON_CHANGED,
ERROR_REPORTED,
LAST_SIGNAL
};
-enum {
- PROP_0,
- PROP_KEYFILE,
- PROP_URI
-};
-
static guint ditem_edit_signals[LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE_WITH_PRIVATE (PanelDItemEditor, panel_ditem_editor, GTK_TYPE_DIALOG)
@@ -168,18 +118,6 @@ static void response_cb (GtkDialog *dialog,
static void setup_icon_chooser (PanelDItemEditor *dialog,
const char *icon_name);
-static gboolean panel_ditem_editor_save (PanelDItemEditor *dialog,
- gboolean report_errors);
-static gboolean panel_ditem_editor_save_timeout (gpointer data);
-static void panel_ditem_editor_revert (PanelDItemEditor *dialog);
-
-static void panel_ditem_editor_key_file_loaded (PanelDItemEditor *dialog);
-static gboolean panel_ditem_editor_load_uri (PanelDItemEditor *dialog,
- GError **error);
-
-static void panel_ditem_editor_set_key_file (PanelDItemEditor *dialog,
- GKeyFile *key_file);
-
static PanelDItemEditorType
map_type_from_desktop_item (const char *type,
gboolean terminal)
@@ -204,8 +142,6 @@ panel_ditem_editor_constructor (GType type,
{
GObject *obj;
PanelDItemEditor *dialog;
- GFile *file;
- gboolean loaded;
obj = G_OBJECT_CLASS (panel_ditem_editor_parent_class)->constructor (type,
n_construct_properties,
@@ -213,93 +149,16 @@ panel_ditem_editor_constructor (GType type,
dialog = PANEL_DITEM_EDITOR (obj);
- if (dialog->priv->key_file) {
- panel_ditem_editor_key_file_loaded (dialog);
- dialog->priv->new_file = FALSE;
- dialog->priv->free_key_file = FALSE;
- loaded = TRUE;
- } else {
- dialog->priv->key_file = panel_key_file_new_desktop ();
- dialog->priv->free_key_file = TRUE;
- loaded = FALSE;
- }
-
- if (!loaded && dialog->priv->uri) {
- file = g_file_new_for_uri (dialog->priv->uri);
- if (g_file_query_exists (file, NULL)) {
- //FIXME what if there's an error?
- panel_ditem_editor_load_uri (dialog, NULL);
- dialog->priv->new_file = FALSE;
- } else {
- dialog->priv->new_file = TRUE;
- }
- g_object_unref (file);
- } else {
- dialog->priv->new_file = !loaded;
- }
+ dialog->priv->key_file = panel_key_file_new_desktop ();
dialog->priv->dirty = FALSE;
panel_ditem_editor_setup_ui (dialog);
-
- if (dialog->priv->new_file)
- setup_icon_chooser (dialog, NULL);
+ setup_icon_chooser (dialog, NULL);
return obj;
}
-static void
-panel_ditem_editor_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- PanelDItemEditor *dialog;
-
- g_return_if_fail (PANEL_IS_DITEM_EDITOR (object));
-
- dialog = PANEL_DITEM_EDITOR (object);
-
- switch (prop_id) {
- case PROP_KEYFILE:
- g_value_set_pointer (value, panel_ditem_editor_get_key_file (dialog));
- break;
- case PROP_URI:
- g_value_set_string (value, panel_ditem_editor_get_uri (dialog));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-panel_ditem_editor_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- PanelDItemEditor *dialog;
-
- g_return_if_fail (PANEL_IS_DITEM_EDITOR (object));
-
- dialog = PANEL_DITEM_EDITOR (object);
-
- switch (prop_id) {
- case PROP_KEYFILE:
- panel_ditem_editor_set_key_file (dialog,
- g_value_get_pointer (value));
- break;
- case PROP_URI:
- panel_ditem_editor_set_uri (dialog,
- g_value_get_string (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
static void
panel_ditem_editor_dispose (GObject *object)
{
@@ -307,24 +166,10 @@ panel_ditem_editor_dispose (GObject *object)
dialog = PANEL_DITEM_EDITOR (object);
- /* If there was a timeout, then something changed after last save,
- * so we must save again now */
- if (dialog->priv->save_timeout) {
- g_source_remove (dialog->priv->save_timeout);
- dialog->priv->save_timeout = 0;
- panel_ditem_editor_save (dialog, FALSE);
- }
-
- /* remember, destroy can be run multiple times! */
-
- if (dialog->priv->free_key_file && dialog->priv->key_file != NULL)
+ if (dialog->priv->key_file != NULL)
g_key_file_free (dialog->priv->key_file);
dialog->priv->key_file = NULL;
- if (dialog->priv->revert_key_file != NULL)
- g_key_file_free (dialog->priv->revert_key_file);
- dialog->priv->revert_key_file = NULL;
-
if (dialog->priv->uri != NULL)
g_free (dialog->priv->uri);
dialog->priv->uri = NULL;
@@ -338,108 +183,28 @@ panel_ditem_editor_class_init (PanelDItemEditorClass *class)
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
gobject_class->constructor = panel_ditem_editor_constructor;
- gobject_class->get_property = panel_ditem_editor_get_property;
- gobject_class->set_property = panel_ditem_editor_set_property;
gobject_class->dispose = panel_ditem_editor_dispose;
ditem_edit_signals[SAVED] =
g_signal_new ("saved",
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (PanelDItemEditorClass,
- changed),
+ 0,
NULL,
NULL,
NULL,
G_TYPE_NONE, 0);
- ditem_edit_signals[CHANGED] =
- g_signal_new ("changed",
- G_TYPE_FROM_CLASS (gobject_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (PanelDItemEditorClass,
- changed),
- NULL,
- NULL,
- NULL,
- G_TYPE_NONE, 0);
-
- ditem_edit_signals[NAME_CHANGED] =
- g_signal_new ("name_changed",
- G_TYPE_FROM_CLASS (gobject_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (PanelDItemEditorClass,
- name_changed),
- NULL,
- NULL,
- NULL,
- G_TYPE_NONE, 1,
- G_TYPE_STRING);
-
- ditem_edit_signals[COMMAND_CHANGED] =
- g_signal_new ("command_changed",
- G_TYPE_FROM_CLASS (gobject_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (PanelDItemEditorClass,
- command_changed),
- NULL,
- NULL,
- NULL,
- G_TYPE_NONE, 1,
- G_TYPE_STRING);
-
- ditem_edit_signals[COMMENT_CHANGED] =
- g_signal_new ("comment_changed",
- G_TYPE_FROM_CLASS (gobject_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (PanelDItemEditorClass,
- comment_changed),
- NULL,
- NULL,
- NULL,
- G_TYPE_NONE, 1,
- G_TYPE_STRING);
-
- ditem_edit_signals[ICON_CHANGED] =
- g_signal_new ("icon_changed",
- G_TYPE_FROM_CLASS (gobject_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (PanelDItemEditorClass,
- icon_changed),
- NULL,
- NULL,
- NULL,
- G_TYPE_NONE, 1,
- G_TYPE_STRING);
-
ditem_edit_signals[ERROR_REPORTED] =
g_signal_new ("error_reported",
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (PanelDItemEditorClass,
- error_reported),
+ 0,
NULL,
NULL,
NULL,
G_TYPE_NONE, 2,
G_TYPE_STRING, G_TYPE_STRING);
-
- g_object_class_install_property (
- gobject_class,
- PROP_KEYFILE,
- g_param_spec_pointer ("keyfile",
- "Key File",
- "A key file containing the data from the .desktop file",
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
- g_object_class_install_property (
- gobject_class,
- PROP_URI,
- g_param_spec_string ("uri",
- "URI",
- "The URI of the .desktop file",
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
}
static GtkWidget *
@@ -600,15 +365,6 @@ panel_ditem_editor_make_ui (PanelDItemEditor *dialog)
gtk_label_set_mnemonic_widget (GTK_LABEL (priv->comment_label),
priv->comment_entry);
- priv->revert_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
- _("_Revert"),
- REVERT_BUTTON);
- gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
- REVERT_BUTTON,
- FALSE);
- priv->close_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
- _("_Close"),
- GTK_RESPONSE_CLOSE);
priv->cancel_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
_("_Cancel"),
GTK_RESPONSE_CANCEL);
@@ -623,95 +379,44 @@ static void
panel_ditem_editor_setup_ui (PanelDItemEditor *dialog)
{
PanelDItemEditorPrivate *priv;
- PanelDItemEditorType type;
- gboolean show_combo;
priv = dialog->priv;
- type = panel_ditem_editor_get_item_type (dialog);
-
- if (priv->new_file) {
- gtk_widget_hide (priv->revert_button);
- gtk_widget_hide (priv->close_button);
- gtk_widget_show (priv->cancel_button);
- gtk_widget_show (priv->ok_button);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog),
- GTK_RESPONSE_OK);
- if (!priv->combo_setuped) {
- setup_combo (priv->type_combo,
- type_items, G_N_ELEMENTS (type_items),
- NULL);
- priv->combo_setuped = TRUE;
- }
-
- gtk_combo_box_set_active (GTK_COMBO_BOX (priv->type_combo), 0);
+ gtk_widget_show (priv->cancel_button);
+ gtk_widget_show (priv->ok_button);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog),
+ GTK_RESPONSE_OK);
- show_combo = TRUE;
- } else {
- gtk_widget_show (priv->revert_button);
- gtk_widget_show (priv->close_button);
- gtk_widget_hide (priv->cancel_button);
- gtk_widget_hide (priv->ok_button);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog),
- GTK_RESPONSE_CLOSE);
-
- show_combo = (type != PANEL_DITEM_EDITOR_TYPE_LINK);
+ if (!priv->combo_setuped) {
+ setup_combo (priv->type_combo,
+ type_items, G_N_ELEMENTS (type_items),
+ NULL);
+ priv->combo_setuped = TRUE;
}
- if (show_combo) {
- grid_attach_label (GTK_GRID (priv->grid), priv->type_label, 1, 0, 1, 1);
- grid_attach_entry (GTK_GRID (priv->grid), priv->type_combo, 2, 0, 1, 1);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (priv->type_combo), 0);
- grid_attach_label (GTK_GRID (priv->grid), priv->name_label, 1, 1, 1, 1);
- grid_attach_entry (GTK_GRID (priv->grid), priv->name_entry, 2, 1, 1, 1);
+ grid_attach_label (GTK_GRID (priv->grid), priv->type_label, 1, 0, 1, 1);
+ grid_attach_entry (GTK_GRID (priv->grid), priv->type_combo, 2, 0, 1, 1);
- grid_attach_label (GTK_GRID (priv->grid), priv->command_label, 1, 2, 1, 1);
- grid_attach_entry (GTK_GRID (priv->grid), priv->command_hbox, 2, 2, 1, 1);
+ grid_attach_label (GTK_GRID (priv->grid), priv->name_label, 1, 1, 1, 1);
+ grid_attach_entry (GTK_GRID (priv->grid), priv->name_entry, 2, 1, 1, 1);
- grid_attach_label (GTK_GRID (priv->grid), priv->comment_label, 1, 3, 1, 1);
- grid_attach_entry (GTK_GRID (priv->grid), priv->comment_entry, 2, 3, 1, 1);
- } else {
- grid_attach_label (GTK_GRID (priv->grid), priv->name_label, 1, 0, 1, 1);
- grid_attach_entry (GTK_GRID (priv->grid), priv->name_entry, 2, 0, 1, 1);
+ grid_attach_label (GTK_GRID (priv->grid), priv->command_label, 1, 2, 1, 1);
+ grid_attach_entry (GTK_GRID (priv->grid), priv->command_hbox, 2, 2, 1, 1);
- grid_attach_label (GTK_GRID (priv->grid), priv->command_label, 1, 1, 1, 1);
- grid_attach_entry (GTK_GRID (priv->grid), priv->command_hbox, 2, 1, 1, 1);
-
- grid_attach_label (GTK_GRID (priv->grid), priv->comment_label, 1, 2, 1, 1);
- grid_attach_entry (GTK_GRID (priv->grid), priv->comment_entry, 2, 2, 1, 1);
- }
+ grid_attach_label (GTK_GRID (priv->grid), priv->comment_label, 1, 3, 1, 1);
+ grid_attach_entry (GTK_GRID (priv->grid), priv->comment_entry, 2, 3, 1, 1);
type_combo_changed (dialog);
gtk_widget_grab_focus (priv->name_entry);
}
-/*
- * Will save after SAVE_FREQUENCY milliseconds of no changes. If something is
- * changed, the save is postponed to another SAVE_FREQUENCY seconds. This seems
- * to be a saner behaviour than just saving every N seconds.
- */
static void
panel_ditem_editor_changed (PanelDItemEditor *dialog)
{
- if (!dialog->priv->new_file) {
- if (dialog->priv->save_timeout != 0)
- g_source_remove (dialog->priv->save_timeout);
-
- dialog->priv->save_timeout = g_timeout_add_seconds (
- SAVE_FREQUENCY,
- panel_ditem_editor_save_timeout,
- dialog);
-
- /* We can revert to the original state */
- if (dialog->priv->revert_key_file != NULL)
- gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
- REVERT_BUTTON,
- TRUE);
- }
-
dialog->priv->dirty = TRUE;
- g_signal_emit (G_OBJECT (dialog), ditem_edit_signals[CHANGED], 0);
}
static void
@@ -720,9 +425,6 @@ panel_ditem_editor_activated (PanelDItemEditor *dialog)
if (gtk_widget_get_visible (dialog->priv->ok_button))
gtk_dialog_response (GTK_DIALOG (dialog),
GTK_RESPONSE_OK);
- else if (gtk_widget_get_visible (dialog->priv->close_button))
- gtk_dialog_response (GTK_DIALOG (dialog),
- GTK_RESPONSE_CLOSE);
}
static void
@@ -732,24 +434,15 @@ panel_ditem_editor_name_changed (PanelDItemEditor *dialog)
name = gtk_entry_get_text (GTK_ENTRY (dialog->priv->name_entry));
- if (!dialog->priv->reverting) {
- /* When reverting, we don't need to set the content of the key
- * file; we only want to send a signal. Changing the key file
- * could actually break the revert since it might overwrite the
- * old Name value with the X-GNOME-FullName value */
- if (name && name[0])
- panel_key_file_set_locale_string (dialog->priv->key_file,
- "Name", name);
- else
- panel_key_file_remove_all_locale_key (dialog->priv->key_file,
- "Name");
-
+ if (name && name[0])
+ panel_key_file_set_locale_string (dialog->priv->key_file,
+ "Name", name);
+ else
panel_key_file_remove_all_locale_key (dialog->priv->key_file,
- "X-GNOME-FullName");
- }
+ "Name");
- g_signal_emit (G_OBJECT (dialog), ditem_edit_signals[NAME_CHANGED], 0,
- name);
+ panel_key_file_remove_all_locale_key (dialog->priv->key_file,
+ "X-GNOME-FullName");
}
static void
@@ -800,9 +493,6 @@ panel_ditem_editor_command_changed (PanelDItemEditor *dialog)
panel_key_file_remove_key (dialog->priv->key_file, "Exec");
panel_key_file_remove_key (dialog->priv->key_file, "URL");
}
-
- g_signal_emit (G_OBJECT (dialog), ditem_edit_signals[COMMAND_CHANGED],
- 0, exec_or_uri);
}
static void
@@ -818,9 +508,6 @@ panel_ditem_editor_comment_changed (PanelDItemEditor *dialog)
else
panel_key_file_remove_all_locale_key (dialog->priv->key_file,
"Comment");
-
- g_signal_emit (G_OBJECT (dialog), ditem_edit_signals[COMMENT_CHANGED],
- 0, comment);
}
static void
@@ -833,9 +520,6 @@ panel_ditem_editor_icon_changed (PanelDItemEditor *dialog,
else
panel_key_file_remove_all_locale_key (dialog->priv->key_file,
"Icon");
-
- g_signal_emit (G_OBJECT (dialog), ditem_edit_signals[ICON_CHANGED], 0,
- icon);
}
static void
@@ -975,48 +659,6 @@ panel_ditem_editor_connect_signals (PanelDItemEditor *dialog)
g_signal_connect (dialog, "response", G_CALLBACK (response_cb), NULL);
}
-static void
-panel_ditem_editor_block_signals (PanelDItemEditor *dialog)
-{
- PanelDItemEditorPrivate *priv;
-
- priv = dialog->priv;
-
-#define BLOCK_CHANGED(widget, callback) \
- g_signal_handlers_block_by_func (G_OBJECT (widget), \
- G_CALLBACK (callback), \
- dialog); \
- g_signal_handlers_block_by_func (G_OBJECT (widget), \
- G_CALLBACK (panel_ditem_editor_changed), \
- dialog);
- BLOCK_CHANGED (priv->type_combo, type_combo_changed);
- BLOCK_CHANGED (priv->name_entry, panel_ditem_editor_name_changed);
- BLOCK_CHANGED (priv->command_entry, panel_ditem_editor_command_changed);
- BLOCK_CHANGED (priv->comment_entry, panel_ditem_editor_comment_changed);
- BLOCK_CHANGED (priv->icon_chooser, panel_ditem_editor_icon_changed);
-}
-
-static void
-panel_ditem_editor_unblock_signals (PanelDItemEditor *dialog)
-{
- PanelDItemEditorPrivate *priv;
-
- priv = dialog->priv;
-
-#define UNBLOCK_CHANGED(widget, callback) \
- g_signal_handlers_unblock_by_func (G_OBJECT (widget), \
- G_CALLBACK (callback), \
- dialog); \
- g_signal_handlers_unblock_by_func (G_OBJECT (widget), \
- G_CALLBACK (panel_ditem_editor_changed), \
- dialog);
- UNBLOCK_CHANGED (priv->type_combo, type_combo_changed);
- UNBLOCK_CHANGED (priv->name_entry, panel_ditem_editor_name_changed);
- UNBLOCK_CHANGED (priv->command_entry, panel_ditem_editor_command_changed);
- UNBLOCK_CHANGED (priv->comment_entry, panel_ditem_editor_comment_changed);
- UNBLOCK_CHANGED (priv->icon_chooser, panel_ditem_editor_icon_changed);
-}
-
static void
panel_ditem_editor_init (PanelDItemEditor *dialog)
{
@@ -1027,13 +669,8 @@ panel_ditem_editor_init (PanelDItemEditor *dialog)
dialog->priv = priv;
priv->key_file = NULL;
- priv->free_key_file = FALSE;
- priv->revert_key_file = NULL;
- priv->reverting = FALSE;
priv->dirty = FALSE;
- priv->save_timeout = 0;
priv->uri = NULL;
- priv->new_file = TRUE;
priv->save_uri = NULL;
priv->save_uri_data = NULL;
priv->combo_setuped = FALSE;
@@ -1189,11 +826,6 @@ panel_ditem_editor_sync_display (PanelDItemEditor *dialog)
buffer = panel_key_file_get_locale_string (key_file, "Icon");
setup_icon_chooser (dialog, buffer);
g_free (buffer);
-
- if (dialog->priv->save_timeout != 0) {
- g_source_remove (dialog->priv->save_timeout);
- dialog->priv->save_timeout = 0;
- }
}
static gboolean
@@ -1208,10 +840,6 @@ panel_ditem_editor_save (PanelDItemEditor *dialog,
g_return_val_if_fail (dialog->priv->save_uri != NULL ||
dialog->priv->uri != NULL, FALSE);
- if (dialog->priv->save_timeout != 0)
- g_source_remove (dialog->priv->save_timeout);
- dialog->priv->save_timeout = 0;
-
if (!dialog->priv->dirty)
return TRUE;
@@ -1295,37 +923,16 @@ panel_ditem_editor_save (PanelDItemEditor *dialog,
return TRUE;
}
-static gboolean
-panel_ditem_editor_save_timeout (gpointer data)
-{
- PanelDItemEditor *dialog;
-
- dialog = PANEL_DITEM_EDITOR (data);
- panel_ditem_editor_save (dialog, FALSE);
-
- return FALSE;
-}
-
static void
response_cb (GtkDialog *dialog,
gint response_id)
{
switch (response_id) {
- case REVERT_BUTTON:
- panel_ditem_editor_revert (PANEL_DITEM_EDITOR (dialog));
- gtk_dialog_set_response_sensitive (dialog,
- REVERT_BUTTON,
- FALSE);
- break;
case GTK_RESPONSE_OK:
- case GTK_RESPONSE_CLOSE:
if (panel_ditem_editor_save (PANEL_DITEM_EDITOR (dialog), TRUE))
gtk_widget_destroy (GTK_WIDGET (dialog));
break;
case GTK_RESPONSE_DELETE_EVENT:
- if (!PANEL_DITEM_EDITOR (dialog)->priv->new_file)
- /* We need to revert the changes */
- gtk_dialog_response (dialog, REVERT_BUTTON);
gtk_widget_destroy (GTK_WIDGET (dialog));
break;
case GTK_RESPONSE_CANCEL:
@@ -1336,226 +943,12 @@ response_cb (GtkDialog *dialog,
}
}
-static void
-panel_ditem_editor_revert (PanelDItemEditor *dialog)
-{
- gulong i;
- char *string;
- gboolean boolean;
- GKeyFile *key_file;
- GKeyFile *revert_key_file;
-
- g_return_if_fail (PANEL_IS_DITEM_EDITOR (dialog));
-
- dialog->priv->reverting = TRUE;
-
- key_file = dialog->priv->key_file;
- revert_key_file = dialog->priv->revert_key_file;
-
- g_assert (revert_key_file != NULL);
-
- for (i = 0; i < G_N_ELEMENTS (revert_keys); i++) {
- if (revert_keys [i].type == G_TYPE_STRING) {
- if (revert_keys [i].locale) {
- string = panel_key_file_get_locale_string (
- revert_key_file,
- revert_keys [i].key);
- if (string == NULL)
- panel_key_file_remove_all_locale_key (
- key_file,
- revert_keys [i].key);
- else
- panel_key_file_set_locale_string (
- key_file,
- revert_keys [i].key,
- string);
- } else {
- string = panel_key_file_get_string (
- revert_key_file,
- revert_keys [i].key);
- if (string == NULL)
- panel_key_file_remove_key (
- key_file,
- revert_keys [i].key);
- else
- panel_key_file_set_string (
- key_file,
- revert_keys [i].key,
- string);
- }
- g_free (string);
- } else if (revert_keys [i].type == G_TYPE_BOOLEAN) {
- boolean = panel_key_file_get_boolean (
- revert_key_file,
- revert_keys [i].key,
- revert_keys [i].default_value);
- panel_key_file_set_boolean (key_file,
- revert_keys [i].key,
- boolean);
- } else {
- g_assert_not_reached ();
- }
- }
-
- panel_ditem_editor_sync_display (dialog);
-
- if (!dialog->priv->new_file) {
- if (dialog->priv->save_timeout != 0)
- g_source_remove (dialog->priv->save_timeout);
-
- dialog->priv->save_timeout = g_timeout_add_seconds (
- SAVE_FREQUENCY,
- panel_ditem_editor_save_timeout,
- dialog);
- }
-
- dialog->priv->reverting = FALSE;
-}
-
-static void
-panel_ditem_editor_set_revert (PanelDItemEditor *dialog)
-{
- gulong i;
- char *string;
- gboolean boolean;
- GKeyFile *key_file;
- GKeyFile *revert_key_file;
-
- g_return_if_fail (PANEL_IS_DITEM_EDITOR (dialog));
-
- key_file = dialog->priv->key_file;
- if (dialog->priv->revert_key_file)
- g_key_file_free (dialog->priv->revert_key_file);
- dialog->priv->revert_key_file = g_key_file_new ();
- revert_key_file = dialog->priv->revert_key_file;
-
- for (i = 0; i < G_N_ELEMENTS (revert_keys); i++) {
- if (revert_keys [i].type == G_TYPE_STRING) {
- if (revert_keys [i].locale) {
- string = panel_key_file_get_locale_string (
- key_file,
- revert_keys [i].key);
- if (string != NULL)
- panel_key_file_set_locale_string (
- revert_key_file,
- revert_keys [i].key,
- string);
- } else {
- string = panel_key_file_get_string (
- key_file,
- revert_keys [i].key);
- if (string != NULL)
- panel_key_file_set_string (
- revert_key_file,
- revert_keys [i].key,
- string);
- }
- g_free (string);
- } else if (revert_keys [i].type == G_TYPE_BOOLEAN) {
- boolean = panel_key_file_get_boolean (
- key_file,
- revert_keys [i].key,
- revert_keys [i].default_value);
- panel_key_file_set_boolean (revert_key_file,
- revert_keys [i].key,
- boolean);
- } else {
- g_assert_not_reached ();
- }
- }
-}
-
-static void
-panel_ditem_editor_key_file_loaded (PanelDItemEditor *dialog)
-{
- /* the user is not changing any value here, so block the signals about
- * changing a value */
- panel_ditem_editor_block_signals (dialog);
- panel_ditem_editor_sync_display (dialog);
- panel_ditem_editor_unblock_signals (dialog);
-
- /* This should be after panel_ditem_editor_sync_display ()
- * so the revert button is insensitive */
- if (dialog->priv->revert_key_file != NULL)
- gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
- REVERT_BUTTON,
- TRUE);
- else
- panel_ditem_editor_set_revert (dialog);
-}
-
-static gboolean
-panel_ditem_editor_load_uri (PanelDItemEditor *dialog,
- GError **error)
-{
- GKeyFile *key_file;
-
- g_return_val_if_fail (PANEL_IS_DITEM_EDITOR (dialog), FALSE);
- g_return_val_if_fail (dialog->priv->uri != NULL, FALSE);
-
- key_file = g_key_file_new ();
-
- if (!panel_key_file_load_from_uri (key_file,
- dialog->priv->uri,
- G_KEY_FILE_KEEP_COMMENTS|G_KEY_FILE_KEEP_TRANSLATIONS,
- error)) {
- g_key_file_free (key_file);
- return FALSE;
- }
-
- if (dialog->priv->free_key_file && dialog->priv->key_file)
- g_key_file_free (dialog->priv->key_file);
- dialog->priv->key_file = key_file;
-
- panel_ditem_editor_key_file_loaded (dialog);
-
- return TRUE;
-}
-
-static GtkWidget *
-panel_ditem_editor_new_full (GtkWindow *parent,
- GKeyFile *key_file,
- const char *uri,
- const char *title)
-{
- GtkWidget *dialog;
-
- dialog = g_object_new (PANEL_TYPE_DITEM_EDITOR,
- "title", title,
- "keyfile", key_file,
- "uri", uri,
- NULL);
-
- if (parent)
- gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
-
- return dialog;
-}
-
GtkWidget *
-panel_ditem_editor_new (GtkWindow *parent,
- GKeyFile *key_file,
- const char *uri,
- const char *title)
+panel_ditem_editor_new (const char *title)
{
- return panel_ditem_editor_new_full (parent, key_file, uri,
- title);
-}
-
-static void
-panel_ditem_editor_set_key_file (PanelDItemEditor *dialog,
- GKeyFile *key_file)
-{
- g_return_if_fail (PANEL_IS_DITEM_EDITOR (dialog));
-
- if (dialog->priv->key_file == key_file)
- return;
-
- if (dialog->priv->free_key_file && dialog->priv->key_file)
- g_key_file_free (dialog->priv->key_file);
- dialog->priv->key_file = key_file;
-
- g_object_notify (G_OBJECT (dialog), "keyfile");
+ return g_object_new (PANEL_TYPE_DITEM_EDITOR,
+ "title", title,
+ NULL);
}
void
@@ -1577,8 +970,6 @@ panel_ditem_editor_set_uri (PanelDItemEditor *dialog,
if (uri && uri [0])
dialog->priv->uri = g_strdup (uri);
-
- g_object_notify (G_OBJECT (dialog), "uri");
}
GKeyFile *
@@ -1589,14 +980,6 @@ panel_ditem_editor_get_key_file (PanelDItemEditor *dialog)
return dialog->priv->key_file;
}
-GKeyFile *
-panel_ditem_editor_get_revert_key_file (PanelDItemEditor *dialog)
-{
- g_return_val_if_fail (PANEL_IS_DITEM_EDITOR (dialog), NULL);
-
- return dialog->priv->revert_key_file;
-}
-
const char *
panel_ditem_editor_get_uri (PanelDItemEditor *dialog)
{
diff --git a/gnome-panel/panel-ditem-editor.h b/gnome-panel/panel-ditem-editor.h
index 6f3239059..63ca2821d 100644
--- a/gnome-panel/panel-ditem-editor.h
+++ b/gnome-panel/panel-ditem-editor.h
@@ -43,31 +43,6 @@ typedef struct _PanelDItemEditorPrivate PanelDItemEditorPrivate;
struct _PanelDItemEditorClass
{
GtkDialogClass parent_class;
-
- /* File has been saved */
- void (* saved) (PanelDItemEditor *dialog);
-
- /* Any information changed */
- void (* changed) (PanelDItemEditor *dialog);
-
- /* These more specific signals are provided since they
- * will likely require a display update */
- /* The name of the item has changed. */
- void (* name_changed) (PanelDItemEditor *dialog,
- const char *name);
- /* The command of the item has changed. */
- void (* command_changed) (PanelDItemEditor *dialog,
- const char *command);
- /* The comment of the item has changed. */
- void (* comment_changed) (PanelDItemEditor *dialog,
- const char *comment);
- /* The icon in particular has changed. */
- void (* icon_changed) (PanelDItemEditor *dialog,
- const char *icon);
-
- /* An error is reported. */
- void (* error_reported) (PanelDItemEditor *dialog,
- const char *error);
};
struct _PanelDItemEditor
@@ -81,15 +56,11 @@ typedef char * (*PanelDitemSaveUri) (PanelDItemEditor *dialog, gpointer data);
GType panel_ditem_editor_get_type (void);
-GtkWidget *panel_ditem_editor_new (GtkWindow *parent,
- GKeyFile *key_file,
- const char *uri,
- const char *title);
+GtkWidget *panel_ditem_editor_new (const char *title);
void panel_ditem_editor_sync_display (PanelDItemEditor *dialog);
GKeyFile *panel_ditem_editor_get_key_file (PanelDItemEditor *dialog);
-GKeyFile *panel_ditem_editor_get_revert_key_file (PanelDItemEditor *dialog);
void panel_ditem_editor_set_uri (PanelDItemEditor *dialog,
const char *uri);
diff --git a/gnome-panel/panel-enums.h b/gnome-panel/panel-enums.h
index d1e920313..1cb4b7e6b 100644
--- a/gnome-panel/panel-enums.h
+++ b/gnome-panel/panel-enums.h
@@ -32,7 +32,6 @@ G_BEGIN_DECLS
#define PANEL_VERTICAL_MASK (PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT)
typedef enum {
- PANEL_OBJECT_LAUNCHER,
PANEL_OBJECT_APPLET,
PANEL_OBJECT_ACTION
} PanelObjectType;
diff --git a/gnome-panel/panel-object-loader.c b/gnome-panel/panel-object-loader.c
index 830cc3042..39198b733 100644
--- a/gnome-panel/panel-object-loader.c
+++ b/gnome-panel/panel-object-loader.c
@@ -36,7 +36,6 @@
#include "panel-toplevel.h"
/* Includes for objects we can load */
-#include "launcher.h"
#include "panel-action-button.h"
#include "panel-applet-frame.h"
@@ -200,11 +199,6 @@ panel_object_loader_idle_handler (gpointer dummy)
object->id,
object->settings);
break;
- case PANEL_OBJECT_LAUNCHER:
- launcher_load (panel_widget,
- object->id,
- object->settings);
- break;
case PANEL_OBJECT_ACTION:
panel_action_button_load (panel_widget,
object->id,
@@ -345,8 +339,7 @@ static struct {
const char *id;
gboolean has_detail;
} panel_object_iid_map[] = {
- { PANEL_OBJECT_ACTION, "ActionButton" , TRUE },
- { PANEL_OBJECT_LAUNCHER, "Launcher" , FALSE }
+ { PANEL_OBJECT_ACTION, "ActionButton", TRUE }
};
char *
diff --git a/gnome-panel/panel-util.c b/gnome-panel/panel-util.c
index 36c54e6c2..8e007aad1 100644
--- a/gnome-panel/panel-util.c
+++ b/gnome-panel/panel-util.c
@@ -36,7 +36,6 @@
#include "applet.h"
#include "panel-bindings.h"
-#include "launcher.h"
#include "panel-icon-names.h"
#include "panel-schemas.h"
@@ -166,22 +165,7 @@ panel_ensure_dir (const char *dirname)
return TRUE;
}
-gboolean
-panel_uri_exists (const char *uri)
-{
- GFile *suri;
- gboolean ret;
-
- g_return_val_if_fail (uri != NULL, FALSE);
-
- suri = g_file_new_for_uri (uri);
- ret = g_file_query_exists (suri, NULL);
- g_object_unref (suri);
-
- return ret;
-}
-
-char *
+static char *
panel_find_icon (GtkIconTheme *icon_theme,
const char *icon_name,
gint size)
@@ -265,7 +249,7 @@ panel_load_icon (GtkIconTheme *icon_theme,
return retval;
}
-char *
+static char *
panel_util_get_from_personal_path (const char *file)
{
return g_build_filename (g_get_user_config_dir (),
@@ -278,32 +262,7 @@ panel_launcher_get_personal_path (void)
return panel_util_get_from_personal_path ("launchers");
}
-gboolean
-panel_launcher_is_in_personal_path (const char *location)
-{
- GFile *file;
- GFile *launchers_dir;
- char *launchers_path;
- gboolean retval;
-
- if (!location)
- return FALSE;
-
- launchers_path = panel_launcher_get_personal_path ();
- launchers_dir = g_file_new_for_path (launchers_path);
- g_free (launchers_path);
-
- file = panel_launcher_get_gfile (location);
-
- retval = g_file_has_prefix (file, launchers_dir);
-
- g_object_unref (file);
- g_object_unref (launchers_dir);
-
- return retval;
-}
-
-GFile *
+static GFile *
panel_launcher_get_gfile (const char *location)
{
char *path;
@@ -322,26 +281,6 @@ panel_launcher_get_gfile (const char *location)
return file;
}
-char *
-panel_launcher_get_uri (const char *location)
-{
- char *path;
- char *uri;
-
- if (!g_ascii_strncasecmp (location, "file:", strlen ("file:")))
- return g_strdup (location);
-
- if (!g_path_is_absolute (location))
- path = panel_make_full_path (NULL, location);
- else
- path = g_strdup (location);
-
- uri = g_filename_to_uri (path, NULL, NULL);
- g_free (path);
-
- return uri;
-}
-
char *
panel_launcher_get_filename (const char *location)
{
@@ -394,7 +333,7 @@ panel_make_full_path (const char *dir,
return retval;
}
-char *
+static char *
panel_make_unique_desktop_path_from_name (const char *dir,
const char *name)
{
diff --git a/gnome-panel/panel-util.h b/gnome-panel/panel-util.h
index 30a10c0f6..0d347e783 100644
--- a/gnome-panel/panel-util.h
+++ b/gnome-panel/panel-util.h
@@ -13,11 +13,6 @@ char * panel_util_make_exec_uri_for_desktop (const char *exec);
void panel_push_window_busy (GtkWidget *window);
void panel_pop_window_busy (GtkWidget *window);
-gboolean panel_uri_exists (const char *uri);
-
-char * panel_find_icon (GtkIconTheme *icon_theme,
- const char *icon_name,
- int size);
GdkPixbuf * panel_load_icon (GtkIconTheme *icon_theme,
const char *icon_name,
int size,
@@ -25,17 +20,10 @@ GdkPixbuf * panel_load_icon (GtkIconTheme *icon_theme,
int desired_height,
char **error_msg);
-char *panel_util_get_from_personal_path (const char *file);
-
-GFile *panel_launcher_get_gfile (const char *location);
-char *panel_launcher_get_uri (const char *location);
char *panel_launcher_get_filename (const char *location);
-gboolean panel_launcher_is_in_personal_path (const char *location);
char *panel_make_full_path (const char *dir,
const char *filename);
-char *panel_make_unique_desktop_path_from_name (const char *dir,
- const char *name);
char *panel_make_unique_desktop_uri (const char *dir,
const char *source);
@@ -43,7 +31,6 @@ char *panel_util_get_icon_name_from_g_icon (GIcon *gicon);
char *guess_icon_from_exec (GtkIconTheme *icon_theme,
GKeyFile *key_file);
-const char *panel_util_get_vfs_method_display_name (const char *method);
char *panel_util_get_label_for_uri (const char *text_uri);
char *panel_util_get_icon_for_uri (const char *text_uri);
diff --git a/gnome-panel/panel.c b/gnome-panel/panel.c
index b770b54bf..b06425527 100644
--- a/gnome-panel/panel.c
+++ b/gnome-panel/panel.c
@@ -20,16 +20,18 @@
#include <gdk/gdkkeysyms.h>
#include <gtk/gtkx.h>
+#include <libpanel-util/panel-error.h>
#include <libpanel-util/panel-glib.h>
+#include <libpanel-util/panel-keyfile.h>
#include "panel.h"
#include "applet.h"
#include "button-widget.h"
-#include "launcher.h"
#include "panel-applets-manager.h"
#include "panel-bindings.h"
#include "panel-context-menu.h"
+#include "panel-ditem-editor.h"
#include "panel-util.h"
#include "panel-applet-frame.h"
#include "panel-action-button.h"
@@ -74,7 +76,6 @@ orientation_change (AppletInfo *info,
panel_applet_frame_change_orientation (
PANEL_APPLET_FRAME (info->widget), orientation);
break;
- case PANEL_OBJECT_LAUNCHER:
case PANEL_OBJECT_ACTION:
button_widget_set_orientation (BUTTON_WIDGET (info->widget), orientation);
break;
@@ -384,6 +385,242 @@ reset_background (PanelToplevel *toplevel)
return TRUE;
}
+static void
+create_launcher (PanelToplevel *toplevel,
+ PanelObjectPackType pack_type,
+ int pack_index,
+ const char *location)
+{
+ char *no_uri;
+ char *new_location;
+ GVariantBuilder builder;
+ GVariant *variant;
+ GVariant *settings;
+
+ g_return_if_fail (location != NULL);
+
+ no_uri = NULL;
+ /* if we have an URI, it might contain escaped characters (? : etc)
+ * that might get unescaped on disk */
+ if (!g_ascii_strncasecmp (location, "file:", strlen ("file:")))
+ no_uri = g_filename_from_uri (location, NULL, NULL);
+
+ if (no_uri == NULL)
+ no_uri = g_strdup (location);
+
+ new_location = panel_launcher_get_filename (no_uri);
+
+ if (new_location == NULL)
+ new_location = no_uri;
+ else
+ g_free (no_uri);
+
+ g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
+
+ variant = g_variant_new_string (new_location);
+ g_variant_builder_add (&builder, "{sv}", "location", variant);
+ g_free (new_location);
+
+ settings = g_variant_builder_end (&builder);
+ g_variant_ref_sink (settings);
+
+ panel_applet_frame_create (toplevel,
+ pack_type,
+ pack_index,
+ "org.gnome.gnome-panel.launcher::custom-launcher",
+ settings);
+
+ g_variant_unref (settings);
+}
+
+static char *
+panel_launcher_find_writable_uri (const char *launcher_location,
+ const char *source)
+{
+ char *path;
+ char *uri;
+
+ if (!launcher_location)
+ return panel_make_unique_desktop_uri (NULL, source);
+
+ if (!strchr (launcher_location, G_DIR_SEPARATOR)) {
+ path = panel_make_full_path (NULL, launcher_location);
+ uri = g_filename_to_uri (path, NULL, NULL);
+ g_free (path);
+ return uri;
+ }
+
+ if (panel_launcher_get_filename (launcher_location) != NULL) {
+ /* we have a file in the user directory. We either have a path
+ * or an URI */
+ if (g_path_is_absolute (launcher_location))
+ return g_filename_to_uri (launcher_location,
+ NULL, NULL);
+ else
+ return g_strdup (launcher_location);
+ }
+
+ return panel_make_unique_desktop_uri (NULL, source);
+}
+
+static char *
+launcher_save_uri (PanelDItemEditor *dialog,
+ gpointer data)
+{
+ GKeyFile *key_file;
+ char *type;
+ char *exec_or_uri;
+ char *new_uri;
+ const char *uri;
+
+ key_file = panel_ditem_editor_get_key_file (dialog);
+ type = panel_key_file_get_string (key_file, "Type");
+ if (type && !strcmp (type, "Application"))
+ exec_or_uri = panel_key_file_get_string (key_file, "Exec");
+ else if (type && !strcmp (type, "Link"))
+ exec_or_uri = panel_key_file_get_string (key_file, "URL");
+ else
+ exec_or_uri = panel_key_file_get_string (key_file, "Name");
+ g_free (type);
+
+ new_uri = panel_launcher_find_writable_uri (NULL, exec_or_uri);
+
+ g_free (exec_or_uri);
+
+ uri = panel_ditem_editor_get_uri (dialog);
+
+ if (!uri || (new_uri && strcmp (new_uri, uri)))
+ return new_uri;
+
+ g_free (new_uri);
+
+ return NULL;
+}
+
+static void
+launcher_error_reported (GtkWidget *dialog,
+ const char *primary,
+ const char *secondary,
+ gpointer data)
+{
+ panel_error_dialog (GTK_WINDOW (dialog), NULL,
+ "error_editing_launcher", TRUE,
+ primary, secondary);
+}
+
+static void
+launcher_new_saved (GtkWidget *dialog,
+ gpointer data)
+{
+ PanelWidget *panel;
+ PanelObjectPackType pack_type;
+ int pack_index;
+ const char *uri;
+
+ pack_type = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (dialog),
+ "pack-type"));
+ panel = g_object_get_data (G_OBJECT (dialog), "panel");
+
+ pack_index = panel_widget_get_new_pack_index (panel, pack_type);
+
+ uri = panel_ditem_editor_get_uri (PANEL_DITEM_EDITOR (dialog));
+ if (panel_launcher_get_filename (uri) != NULL)
+ uri = panel_launcher_get_filename (uri);
+
+ create_launcher (panel->toplevel, pack_type, pack_index, uri);
+}
+
+static void
+ask_about_launcher (const char *file,
+ PanelWidget *panel,
+ PanelObjectPackType pack_type)
+{
+ GtkWidget *dialog;
+ GKeyFile *key_file;
+
+ if (panel_lockdown_get_disable_command_line_s ())
+ return;
+
+ dialog = panel_ditem_editor_new (_("Create Launcher"));
+ panel_widget_register_open_dialog (panel, dialog);
+
+ key_file = panel_ditem_editor_get_key_file (PANEL_DITEM_EDITOR (dialog));
+ if (file != NULL)
+ panel_key_file_set_string (key_file, "Exec", file);
+ panel_key_file_set_string (key_file, "Type", "Application");
+ panel_ditem_editor_sync_display (PANEL_DITEM_EDITOR (dialog));
+
+ panel_ditem_register_save_uri_func (PANEL_DITEM_EDITOR (dialog),
+ launcher_save_uri,
+ NULL);
+
+ g_signal_connect (G_OBJECT (dialog), "saved",
+ G_CALLBACK (launcher_new_saved), NULL);
+
+ g_signal_connect (G_OBJECT (dialog), "error_reported",
+ G_CALLBACK (launcher_error_reported), NULL);
+
+ gtk_window_set_screen (GTK_WINDOW (dialog),
+ gtk_widget_get_screen (GTK_WIDGET (panel)));
+
+ g_object_set_data (G_OBJECT (dialog), "pack-type",
+ GINT_TO_POINTER (pack_type));
+ g_object_set_data (G_OBJECT (dialog), "panel", panel);
+
+ gtk_widget_show (dialog);
+}
+
+static void
+create_launcher_from_info (PanelToplevel *toplevel,
+ PanelObjectPackType pack_type,
+ int pack_index,
+ gboolean exec_info,
+ const char *exec_or_uri,
+ const char *name,
+ const char *comment,
+ const char *icon)
+{
+ GVariantBuilder builder;
+ GVariant *variant;
+ GVariant *settings;
+
+ g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
+
+ variant = g_variant_new_string (name);
+ g_variant_builder_add (&builder, "{sv}", "name", variant);
+
+ variant = g_variant_new_string (exec_or_uri);
+ g_variant_builder_add (&builder, "{sv}", "command", variant);
+
+ variant = g_variant_new_string (comment);
+ g_variant_builder_add (&builder, "{sv}", "comment", variant);
+
+ variant = g_variant_new_string (icon);
+ g_variant_builder_add (&builder, "{sv}", "icon", variant);
+
+ if (exec_info)
+ {
+ variant = g_variant_new_string ("Application");
+ g_variant_builder_add (&builder, "{sv}", "type", variant);
+ }
+ else
+ {
+ variant = g_variant_new_string ("Link");
+ g_variant_builder_add (&builder, "{sv}", "type", variant);
+ }
+
+ settings = g_variant_builder_end (&builder);
+ g_variant_ref_sink (settings);
+
+ panel_applet_frame_create (toplevel,
+ pack_type,
+ pack_index,
+ "org.gnome.gnome-panel.launcher::custom-launcher",
+ settings);
+
+ g_variant_unref (settings);
+}
+
static gboolean
drop_url (PanelWidget *panel,
PanelObjectPackType pack_type,
@@ -418,10 +655,10 @@ drop_url (PanelWidget *panel,
else
name = netscape_url[NETSCAPE_URL_NAME];
- panel_launcher_create_from_info (panel->toplevel, pack_type, pack_index,
- FALSE,
- netscape_url[NETSCAPE_URL_URL],
- name, comment, PANEL_ICON_REMOTE);
+ create_launcher_from_info (panel->toplevel, pack_type, pack_index,
+ FALSE,
+ netscape_url[NETSCAPE_URL_URL],
+ name, comment, PANEL_ICON_REMOTE);
g_free (comment);
g_strfreev (netscape_url);
@@ -464,8 +701,8 @@ drop_uri (PanelWidget *panel,
comment = g_strdup_printf (_("Open '%s'"), buf);
g_free (buf);
- panel_launcher_create_from_info (panel->toplevel, pack_type, pack_index,
- FALSE, uri, name, comment, icon);
+ create_launcher_from_info (panel->toplevel, pack_type, pack_index,
+ FALSE, uri, name, comment, icon);
g_free (name);
g_free (comment);
@@ -504,31 +741,31 @@ drop_nautilus_desktop_uri (PanelWidget *panel,
g_free (uri_tmp);
g_object_unref (file);
- panel_launcher_create_from_info (panel->toplevel,
- pack_type, pack_index,
- TRUE, /* is_exec? */
- "nautilus", /* exec */
- name, /* name */
- _("Open your personal folder"), /* comment */
- PANEL_ICON_HOME); /* icon name */
+ create_launcher_from_info (panel->toplevel,
+ pack_type, pack_index,
+ TRUE, /* is_exec? */
+ "nautilus", /* exec */
+ name, /* name */
+ _("Open your personal folder"), /* comment */
+ PANEL_ICON_HOME); /* icon name */
g_free (name);
} else if (strncmp (basename, "computer", strlen ("computer")) == 0)
- panel_launcher_create_from_info (panel->toplevel,
- pack_type, pack_index,
- TRUE, /* is_exec? */
- "nautilus computer://", /* exec */
- _("Computer"), /* name */
- _("Browse all local and remote disks and folders accessible
from this computer"), /* comment */
- PANEL_ICON_COMPUTER); /* icon name */
+ create_launcher_from_info (panel->toplevel,
+ pack_type, pack_index,
+ TRUE, /* is_exec? */
+ "nautilus computer://", /* exec */
+ _("Computer"), /* name */
+ _("Browse all local and remote disks and folders accessible from
this computer"), /* comment */
+ PANEL_ICON_COMPUTER); /* icon name */
else if (strncmp (basename, "network", strlen ("network")) == 0)
- panel_launcher_create_from_info (panel->toplevel,
- pack_type, pack_index,
- TRUE, /* is_exec? */
- "nautilus network://", /* exec */
- _("Network"), /* name */
- _("Browse bookmarked and local network locations"), /*
comment */
- PANEL_ICON_NETWORK); /* icon name */
+ create_launcher_from_info (panel->toplevel,
+ pack_type, pack_index,
+ TRUE, /* is_exec? */
+ "nautilus network://", /* exec */
+ _("Network"), /* name */
+ _("Browse bookmarked and local network locations"), /* comment */
+ PANEL_ICON_NETWORK); /* icon name */
else
success = FALSE;
@@ -641,9 +878,9 @@ drop_urilist (PanelWidget *panel,
!strcmp (mime, "application/x-desktop") ||
!strcmp (mime, "application/x-kde-app-info"))) {
if (panel_layout_is_writable ())
- panel_launcher_create (panel->toplevel,
- pack_type, pack_index,
- uri);
+ create_launcher (panel->toplevel,
+ pack_type, pack_index,
+ uri);
else
success = FALSE;
} else if (type != G_FILE_TYPE_DIRECTORY && can_exec) {
@@ -705,13 +942,6 @@ drop_internal_applet (PanelWidget *panel,
} else {
success = FALSE;
}
- } else if (!strcmp(applet_type,"LAUNCHER:ASK")) {
- if (panel_layout_is_writable ()) {
- ask_about_launcher (NULL, panel, pack_type);
- success = TRUE;
- } else {
- success = FALSE;
- }
}
return success;
@@ -865,12 +1095,12 @@ drag_motion_cb (GtkWidget *widget,
}
static gboolean
-drag_drop_cb (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time,
- Launcher *launcher)
+drag_drop_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ guint time,
+ gpointer user_data)
{
GdkAtom ret_atom = NULL;
@@ -883,10 +1113,10 @@ drag_drop_cb (GtkWidget *widget,
}
static void
-drag_leave_cb (GtkWidget *widget,
- GdkDragContext *context,
- guint time,
- Launcher *launcher)
+drag_leave_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ guint time,
+ gpointer user_data)
{
PanelToplevel *toplevel;
@@ -896,7 +1126,6 @@ drag_leave_cb (GtkWidget *widget,
panel_toplevel_queue_auto_hide (toplevel);
}
-
typedef struct
{
PanelWidget *panel;
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 1daae1bd2..6897cadf3 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -16,7 +16,6 @@ gnome-panel/gp-arrow-button.c
gnome-panel/gp-main.c
gnome-panel/gp-properties-dialog.c
gnome-panel/gp-properties-dialog.ui
-gnome-panel/launcher.c
gnome-panel/libpanel-applet-private/gp-applet-frame.c
gnome-panel/libpanel-util/panel-error.c
gnome-panel/libpanel-util/panel-icon-chooser.c
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]