Commit a2b2165d authored by Alberts Muktupāvels's avatar Alberts Muktupāvels

panel: remove old launcher object

Existing launcher objects will be turned into applets.
parent d1344d2c
Pipeline #170398 passed with stages
in 12 minutes and 52 seconds
......@@ -16,7 +16,6 @@ gsettings_SCHEMAS = \
org.gnome.gnome-panel.applet.clock.gschema.xml \
org.gnome.gnome-panel.applet.initial-settings.gschema.xml \
org.gnome.gnome-panel.gschema.xml \
org.gnome.gnome-panel.launcher.gschema.xml \
org.gnome.gnome-panel.object.gschema.xml \
org.gnome.gnome-panel.toplevel.gschema.xml \
$(NULL)
......
<schemalist gettext-domain="gnome-panel">
<schema id="org.gnome.gnome-panel.launcher">
<key name="location" type="s">
<default>''</default>
<summary>Launcher location</summary>
<description>The location of the .desktop file describing the launcher. This key is only relevant if the object_type key is "launcher-object".</description>
</key>
</schema>
</schemalist>
......@@ -33,7 +33,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 \
......@@ -47,7 +46,6 @@ panel_sources = \
panel-force-quit.c \
panel-lockdown.c \
panel-addto-dialog.c \
panel-ditem-editor.c \
panel-layout.c \
panel-object-loader.c \
panel-applet-info.c
......@@ -61,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 \
......@@ -77,7 +74,6 @@ panel_headers = \
panel-force-quit.h \
panel-lockdown.h \
panel-addto-dialog.h \
panel-ditem-editor.h \
panel-icon-names.h \
panel-layout.h \
panel-object-loader.h \
......
......@@ -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)
{
......
......@@ -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);
......
......@@ -25,7 +25,6 @@ struct _ButtonWidgetPrivate {
int size;
guint activatable : 1;
guint dnd_highlight : 1;
};
static void button_widget_icon_theme_changed (ButtonWidget *button);
......@@ -34,7 +33,6 @@ static void button_widget_reload_pixbuf (ButtonWidget *button);
enum {
PROP_0,
PROP_ACTIVATABLE,
PROP_DND_HIGHLIGHT,
PROP_ORIENTATION,
PROP_ICON_NAME
};
......@@ -213,9 +211,6 @@ button_widget_get_property (GObject *object,
case PROP_ACTIVATABLE:
g_value_set_boolean (value, button->priv->activatable);
break;
case PROP_DND_HIGHLIGHT:
g_value_set_boolean (value, button->priv->dnd_highlight);
break;
case PROP_ORIENTATION:
g_value_set_enum (value, button->priv->orientation);
break;
......@@ -242,9 +237,6 @@ button_widget_set_property (GObject *object,
case PROP_ACTIVATABLE:
button_widget_set_activatable (button, g_value_get_boolean (value));
break;
case PROP_DND_HIGHLIGHT:
button_widget_set_dnd_highlight (button, g_value_get_boolean (value));
break;
case PROP_ORIENTATION:
button_widget_set_orientation (button, g_value_get_enum (value));
break;
......@@ -313,15 +305,6 @@ button_widget_draw (GtkWidget *widget,
context = gtk_widget_get_style_context (widget);
if (button_widget->priv->dnd_highlight) {
cairo_save (cr);
cairo_set_line_width (cr, 1);
cairo_set_source_rgb (cr, 0., 0., 0.);
cairo_rectangle (cr, 0.5, 0.5, width - 1, height - 1);
cairo_stroke (cr);
cairo_restore (cr);
}
if (gtk_widget_has_focus (widget)) {
gtk_style_context_save (context);
gtk_style_context_set_state (context, state_flags);
......@@ -525,15 +508,14 @@ button_widget_init (ButtonWidget *button)
button->priv->pixbuf_hc = NULL;
button->priv->filename = NULL;
button->priv->orientation = PANEL_ORIENTATION_TOP;
context = gtk_widget_get_style_context (GTK_WIDGET (button));
gtk_style_context_add_class (context, GTK_STYLE_CLASS_HORIZONTAL);
button->priv->size = 0;
button->priv->activatable = FALSE;
button->priv->dnd_highlight = FALSE;
}
static void
......@@ -568,15 +550,6 @@ button_widget_class_init (ButtonWidgetClass *klass)
TRUE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
g_object_class_install_property (
gobject_class,
PROP_DND_HIGHLIGHT,
g_param_spec_boolean ("dnd-highlight",
"Drag and drop Highlight",
"Whether or not to highlight the icon during drag and drop",
FALSE,
G_PARAM_READWRITE));
g_object_class_install_property (
gobject_class,
PROP_ORIENTATION,
......@@ -605,21 +578,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)
......@@ -687,48 +645,3 @@ 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)
{
g_return_if_fail (BUTTON_IS_WIDGET (button));
dnd_highlight = dnd_highlight != FALSE;
if (button->priv->dnd_highlight == dnd_highlight)
return;
button->priv->dnd_highlight = dnd_highlight;
gtk_widget_queue_draw (GTK_WIDGET (button));
g_object_notify (G_OBJECT (button), "dnd-highlight");
}
GtkIconTheme *
button_widget_get_icon_theme (ButtonWidget *button)
{
g_return_val_if_fail (BUTTON_IS_WIDGET (button), NULL);
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);
}
......@@ -27,19 +27,12 @@ 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
......
/*
* GNOME panel launcher module.
* (C) 1997,1998,1999,2000 The Free Software Foundation
* (C) 2000, 2001 Eazel, Inc.
* (C) 2002 Sun Microsystems Inc
*
* Authors: Miguel de Icaza
* Federico Mena
* George Lebl <jirka@5z.com>
* Mark McLoughlin <mark@skynet.ie>
* CORBAized by George Lebl
* de-CORBAized by George Lebl
*/
#include <config.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <dirent.h>
#include <string.h>
#include <glib/gi18n.h>
#include <gio/gio.h>
#include <gdk/gdkx.h>
#include <libpanel-util/panel-error.h>
#include <libpanel-util/panel-glib.h>
#include <libpanel-util/panel-keyfile.h>
#include <libpanel-util/panel-launch.h>
#include <libpanel-util/panel-show.h>
#include "launcher.h"
#include "button-widget.h"
#include "panel-util.h"
#include "panel-toplevel.h"
#include "panel-a11y.h"
#include "panel-multiscreen.h"
#include "panel-layout.h"
#include "panel-lockdown.h"
#include "panel-ditem-editor.h"
#include "panel-icon-names.h"
#include "panel-schemas.h"
/* zoom factor, steps and delay if composited (factor must be odd) */
#define ZOOM_FACTOR 5
#define ZOOM_STEPS 14
#define ZOOM_DELAY 10
typedef struct {
int size;
int size_start;
int size_end;
PanelOrientation orientation;
double opacity;
GdkPixbuf *pixbuf;
guint timeout_id;
} CompositedZoomData;
static gboolean
zoom_timeout (GtkWidget *window)
{
gtk_widget_queue_draw (window);
return TRUE;
}
static gboolean
idle_destroy (gpointer data)
{
gtk_widget_destroy (GTK_WIDGET (data));
return FALSE;
}
static gboolean
zoom_draw (GtkWidget *widget,
cairo_t *cr,
gpointer user_data)
{
CompositedZoomData *zoom;
zoom = user_data;
if (zoom->size >= zoom->size_end) {
if (zoom->timeout_id)
g_source_remove (zoom->timeout_id);
zoom->timeout_id = 0;
gtk_widget_hide (widget);
g_idle_add (idle_destroy, widget);
g_object_unref (zoom->pixbuf);
zoom->pixbuf = NULL;
g_slice_free (CompositedZoomData, zoom);
} else {
GdkPixbuf *scaled;
int width, height;
int x = 0, y = 0;
gtk_window_get_size (GTK_WINDOW (widget), &width, &height);
zoom->size += MAX ((zoom->size_end - zoom->size_start) / ZOOM_STEPS, 1);
zoom->opacity -= 1.0 / ((double) ZOOM_STEPS + 1);
scaled = gdk_pixbuf_scale_simple (zoom->pixbuf,
zoom->size, zoom->size,
GDK_INTERP_BILINEAR);
switch (zoom->orientation) {
case PANEL_ORIENTATION_TOP:
x = (width - gdk_pixbuf_get_width (scaled)) / 2;
y = 0;
break;
case PANEL_ORIENTATION_RIGHT:
x = width - gdk_pixbuf_get_width (scaled);
y = (height - gdk_pixbuf_get_height (scaled)) / 2;
break;
case PANEL_ORIENTATION_BOTTOM:
x = (width - gdk_pixbuf_get_width (scaled)) / 2;
y = height - gdk_pixbuf_get_height (scaled);
break;
case PANEL_ORIENTATION_LEFT:
x = 0;
y = (height - gdk_pixbuf_get_height (scaled)) / 2;
break;
default:
break;
}
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
cairo_set_source_rgba (cr, 0, 0, 0, 0.0);
cairo_rectangle (cr, 0, 0, width, height);
cairo_fill (cr);
gdk_cairo_set_source_pixbuf (cr, scaled, x, y);
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
cairo_paint_with_alpha (cr, MAX (zoom->opacity, 0));
g_object_unref (scaled);
}
return FALSE;
}
static void
draw_zoom_animation_composited (GdkScreen *gscreen,
int x, int y, int w, int h,
GdkPixbuf *pixbuf,
PanelOrientation orientation)
{
GtkWidget *win;
CompositedZoomData *zoom;
int wx = 0, wy = 0;
w += 2;
h += 2;
zoom = g_slice_new (CompositedZoomData);
zoom->size = MIN (w,h);
zoom->size_start = zoom->size;
zoom->size_end = zoom->size * ZOOM_FACTOR;
zoom->orientation = orientation;
zoom->opacity = 1.0;
zoom->pixbuf = g_object_ref (pixbuf);
zoom->timeout_id = 0;
win = gtk_window_new (GTK_WINDOW_POPUP);
gtk_window_set_screen (GTK_WINDOW (win), gscreen);
gtk_window_set_keep_above (GTK_WINDOW (win), TRUE);
gtk_window_set_decorated (GTK_WINDOW (win), FALSE);
gtk_widget_set_app_paintable(win, TRUE);
gtk_widget_set_visual (win, gdk_screen_get_rgba_visual (gscreen));
gtk_window_set_gravity (GTK_WINDOW (win), GDK_GRAVITY_STATIC);
gtk_window_set_default_size (GTK_WINDOW (win),
w * ZOOM_FACTOR, h * ZOOM_FACTOR);
switch (zoom->orientation) {
case PANEL_ORIENTATION_TOP:
wx = x - w * (ZOOM_FACTOR / 2);
wy = y;
break;
case PANEL_ORIENTATION_RIGHT:
wx = x - w * (ZOOM_FACTOR - 1);
wy = y - h * (ZOOM_FACTOR / 2);
break;
case PANEL_ORIENTATION_BOTTOM:
wx = x - w * (ZOOM_FACTOR / 2);
wy = y - h * (ZOOM_FACTOR - 1);
break;
case PANEL_ORIENTATION_LEFT:
wx = x;
wy = y - h * (ZOOM_FACTOR / 2);
break;
default:
break;
}
gtk_window_move (GTK_WINDOW (win), wx, wy);
g_signal_connect (G_OBJECT (win), "draw",
G_CALLBACK (zoom_draw), zoom);
/* see doc for gtk_widget_set_app_paintable() */
gtk_widget_realize (win);
gtk_widget_show (win);
zoom->timeout_id = g_timeout_add (ZOOM_DELAY,
(GSourceFunc) zoom_timeout,
win);
}
static GdkScreen *
launcher_get_screen (Launcher *launcher)
{
PanelWidget *panel_widget;
g_return_val_if_fail (launcher != NULL, NULL);
g_return_val_if_fail (launcher->info != NULL, NULL);
g_return_val_if_fail (launcher->info->widget != NULL, NULL);
panel_widget = PANEL_WIDGET (gtk_widget_get_parent (launcher->info->widget));
return gtk_window_get_screen (GTK_WINDOW (panel_widget->toplevel));
}
static void
launcher_widget_open_dialog_destroyed (GtkWidget *dialog,
Launcher *launcher)
{
g_return_if_fail (launcher->error_dialogs != NULL);
launcher->error_dialogs = g_slist_remove (launcher->error_dialogs, dialog);
}
static void
launcher_widget_destroy_open_dialogs (Launcher *launcher)
{
GSList *l, *list;
list = launcher->error_dialogs;
launcher->error_dialogs = NULL;
for (l = list; l; l = l->next) {
g_signal_handlers_disconnect_by_func (G_OBJECT (l->data),
G_CALLBACK (launcher_widget_open_dialog_destroyed),
launcher);
gtk_widget_destroy (l->data);
}
g_slist_free (list);
}
static void
launcher_register_error_dialog (Launcher *launcher,
GtkWidget *dialog)
{
launcher->error_dialogs = g_slist_append (launcher->error_dialogs,
dialog);
g_signal_connect (dialog, "destroy",
G_CALLBACK (launcher_widget_open_dialog_destroyed),
launcher);
}
static void
launcher_do_zoom_animation (GtkWidget *widget)
{
GdkScreen *screen;
GtkSettings *settings;
gboolean enable_animations;
ButtonWidget *button_widget;
GdkPixbuf *pixbuf;
PanelOrientation orientation;
gint x, y;
GtkAllocation allocation;
screen = gtk_widget_get_screen (widget);
settings = gtk_widget_get_settings (widget);
enable_animations = TRUE;
g_object_get (settings,
"gtk-enable-animations", &enable_animations,
NULL);
if (!enable_animations || !gdk_screen_is_composited (screen))
return;
button_widget = BUTTON_WIDGET (widget);
pixbuf = button_widget_get_pixbuf (button_widget);
orientation = button_widget_get_orientation (button_widget);
if (!pixbuf)
return;
gdk_window_get_origin (gtk_widget_get_window (widget), &x, &y);
gtk_widget_get_allocation (widget, &allocation);
if (!gtk_widget_get_has_window (widget)) {
x += allocation.x;
y += allocation.y;
}
draw_zoom_animation_composited (screen, x, y,
allocation.width, allocation.height,
pixbuf, orientation);
g_object_unref (pixbuf);
}
static void
launch_url (Launcher *launcher)
{
char *url;
GdkScreen *screen;
g_return_if_fail (launcher != NULL);
g_return_if_fail (launcher->key_file != NULL);
/* FIXME panel_ditem_launch() should be enough for this! */
url = panel_key_file_get_string (launcher->key_file, "URL");
screen = launcher_get_screen (launcher);
if (!url || *url == 0) {
GtkWidget *error_dialog;
error_dialog = panel_error_dialog (NULL, screen,
"no_url_dialog", TRUE,
_("Could not show this URL"),
_("No URL was specified."));
launcher_register_error_dialog (launcher, error_dialog);
g_free (url);
return;
}
panel_show_uri (screen, url, gtk_get_current_event_time (), NULL);
g_free (url);
}
void
launcher_launch (Launcher *launcher,
GtkWidget *widget)
{
char *type;
g_return_if_fail (launcher != NULL);
g_return_if_fail (launcher->key_file != NULL);
launcher_do_zoom_animation (widget);
type = panel_key_file_get_string (launcher->key_file, "Type");
if (type && !strcmp (type, "Link"))
launch_url (launcher);
else {
GError *error = NULL;
panel_launch_key_file (launcher->key_file, NULL,
launcher_get_screen (launcher), &error);
if (error) {
GtkWidget *error_dialog;
error_dialog = panel_error_dialog (
NULL,