[Xfce4-commits] <xfce4-panel:devel> * Add plugins using the command line. * Support arguments in plugins.
Nick Schermer
nick at xfce.org
Tue Aug 11 20:22:08 CEST 2009
Updating branch refs/heads/devel
to 416942fab63f48bcd02947ea7bae4add8f4583b5 (commit)
from fa1f1a4b804af51f32ab36beeeb07ac47aac2919 (commit)
commit 416942fab63f48bcd02947ea7bae4add8f4583b5
Author: Nick Schermer <nick at xfce.org>
Date: Mon Jun 16 20:16:42 2008 +0200
* Add plugins using the command line.
* Support arguments in plugins.
Panel-desktop-handler.desktop.in.in | 2 -
libxfce4panel/libxfce4panel.h | 34 +++--
libxfce4panel/xfce-panel-plugin-provider.h | 19 ++--
libxfce4panel/xfce-panel-plugin.c | 73 ++++++++--
libxfce4panel/xfce-panel-plugin.h | 9 +-
panel/main.c | 35 +++--
panel/panel-application.c | 209 +++++++++++++++-------------
panel/panel-application.h | 40 +++---
panel/panel-dbus-client.c | 34 +++++
panel/panel-dbus-client.h | 18 ++-
panel/panel-dbus-service-infos.xml | 13 ++-
panel/panel-dbus-service.c | 29 ++++
panel/panel-module-factory.c | 39 +++---
panel/panel-module-factory.h | 17 ++-
panel/panel-module.c | 15 +-
panel/panel-module.h | 31 ++--
panel/panel-plugin-external.c | 121 ++++++++--------
panel/panel-plugin-external.h | 2 +-
plugins/launcher/launcher-dialog.c | 4 +-
plugins/launcher/launcher-dialog.h | 2 +
plugins/launcher/launcher.c | 35 ++++-
wrapper/main.c | 2 +-
22 files changed, 494 insertions(+), 289 deletions(-)
diff --git a/Panel-desktop-handler.desktop.in.in b/Panel-desktop-handler.desktop.in.in
index d192a90..cfa027d 100644
--- a/Panel-desktop-handler.desktop.in.in
+++ b/Panel-desktop-handler.desktop.in.in
@@ -6,9 +6,7 @@ _GenericName=Create Launcher on Xfce Panel
TryExec=xfce4-panel
Exec=xfce4-panel --add=launcher %F
Icon=application-x-executable
-NoDisplay=true
Terminal=false
StartupNotify=true
Type=Application
-Categories=System;Utility;Core;GTK;Panel;
MimeType=application/x-desktop;
diff --git a/libxfce4panel/libxfce4panel.h b/libxfce4panel/libxfce4panel.h
index 08373e7..d1f7627 100644
--- a/libxfce4panel/libxfce4panel.h
+++ b/libxfce4panel/libxfce4panel.h
@@ -106,15 +106,17 @@ typedef GTypeModule XfcePanelModule;
const gchar *plugin_init_display_name = NULL; \
\
G_MODULE_EXPORT XfcePanelPlugin * \
- xfce_panel_plugin_construct (const gchar *name, \
- const gchar *id, \
- const gchar *display_name, \
- GdkScreen *screen) \
+ xfce_panel_plugin_construct (const gchar *name, \
+ const gchar *id, \
+ const gchar *display_name, \
+ gchar **arguments, \
+ GdkScreen *screen) \
{ \
- XfcePanelPlugin *plugin; \
- extern const gchar *plugin_init_name; \
- extern const gchar *plugin_init_id; \
- extern const gchar *plugin_init_display_name; \
+ XfcePanelPlugin *plugin; \
+ extern const gchar *plugin_init_name; \
+ extern const gchar *plugin_init_id; \
+ extern const gchar *plugin_init_display_name; \
+ extern gchar **plugin_init_arguments; \
\
panel_return_val_if_fail (GDK_IS_SCREEN (screen), NULL); \
panel_return_val_if_fail (name != NULL && id != NULL, NULL); \
@@ -124,13 +126,15 @@ typedef GTypeModule XfcePanelModule;
plugin_init_name = name; \
plugin_init_id = id; \
plugin_init_display_name = display_name; \
+ plugin_init_arguments = arguments; \
\
CODE \
\
plugin = g_object_new (type, \
"name", name, \
"display-name", display_name, \
- "id", id, NULL); \
+ "id", id, \
+ "arguments", arguments, NULL); \
\
return plugin; \
}
@@ -157,10 +161,11 @@ typedef GTypeModule XfcePanelModule;
} \
\
G_MODULE_EXPORT XfcePanelPlugin * \
- xfce_panel_plugin_construct (const gchar *name, \
- const gchar *id, \
- const gchar *display_name, \
- GdkScreen *screen) \
+ xfce_panel_plugin_construct (const gchar *name, \
+ const gchar *id, \
+ const gchar *display_name, \
+ gchar **arguments, \
+ GdkScreen *screen) \
{ \
XfcePanelPlugin *plugin = NULL; \
\
@@ -173,7 +178,8 @@ typedef GTypeModule XfcePanelModule;
plugin = g_object_new (XFCE_TYPE_PANEL_PLUGIN, \
"name", name, \
"display-name", display_name, \
- "id", id, NULL); \
+ "id", id, \
+ "arguments", arguments, NULL); \
\
/* signal to realize the plugin */ \
g_signal_connect_after (G_OBJECT (plugin), "realize", G_CALLBACK (xfce_panel_plugin_realize), NULL); \
diff --git a/libxfce4panel/xfce-panel-plugin-provider.h b/libxfce4panel/xfce-panel-plugin-provider.h
index 689f973..9d430db 100644
--- a/libxfce4panel/xfce-panel-plugin-provider.h
+++ b/libxfce4panel/xfce-panel-plugin-provider.h
@@ -27,11 +27,12 @@ typedef struct _XfcePanelPluginProviderIface XfcePanelPluginProviderIface;
typedef struct _XfcePanelPluginProvider XfcePanelPluginProvider;
typedef enum _XfcePanelPluginMessage XfcePanelPluginMessage;
-typedef XfcePanelPluginProvider *(*PluginConstructFunc) (const gchar *name,
- const gchar *id,
- const gchar *display_name,
- GdkScreen *screen);
-
+typedef XfcePanelPluginProvider *(*PluginConstructFunc) (const gchar *name,
+ const gchar *id,
+ const gchar *display_name,
+ gchar **arguments,
+ GdkScreen *screen);
+
typedef void (*PluginRegisterTypesFunc) (XfcePanelModule *module);
#define XFCE_TYPE_PANEL_PLUGIN_PROVIDER (xfce_panel_plugin_provider_get_type ())
@@ -58,7 +59,7 @@ struct _XfcePanelPluginProviderIface
{
/*< private >*/
GTypeInterface __parent__;
-
+
/*< public >*/
gboolean (*is_external) (void);
const gchar *(*get_name) (XfcePanelPluginProvider *provider);
@@ -83,13 +84,13 @@ const gchar *xfce_panel_plugin_provider_get_id (XfcePanelPluginProv
void xfce_panel_plugin_provider_set_size (XfcePanelPluginProvider *provider,
gint size);
-
+
void xfce_panel_plugin_provider_set_orientation (XfcePanelPluginProvider *provider,
GtkOrientation orientation);
-
+
void xfce_panel_plugin_provider_set_screen_position (XfcePanelPluginProvider *provider,
XfceScreenPosition screen_position);
-
+
void xfce_panel_plugin_provider_set_opacity (XfcePanelPluginProvider *provider,
gdouble opacity);
diff --git a/libxfce4panel/xfce-panel-plugin.c b/libxfce4panel/xfce-panel-plugin.c
index 64554d8..0ef83a9 100644
--- a/libxfce4panel/xfce-panel-plugin.c
+++ b/libxfce4panel/xfce-panel-plugin.c
@@ -74,6 +74,7 @@ enum
PROP_0,
PROP_NAME,
PROP_DISPLAY_NAME,
+ PROP_ARGUMENTS,
PROP_ID
};
@@ -92,16 +93,17 @@ enum
struct _XfcePanelPluginPrivate
{
/* plugin information */
- gchar *name;
- gchar *display_name;
- gchar *id;
- gint size;
- guint expand : 1;
- GtkOrientation orientation;
- XfceScreenPosition screen_position;
+ gchar *name;
+ gchar *display_name;
+ gchar *id;
+ gchar **arguments;
+ gint size;
+ guint expand : 1;
+ GtkOrientation orientation;
+ XfceScreenPosition screen_position;
/* plugin menu */
- GtkWidget *menu;
+ GtkWidget *menu;
};
@@ -111,9 +113,10 @@ static guint plugin_signals[LAST_SIGNAL];
/* external plugin information for during plugin_init */
-const gchar *plugin_init_name = NULL;
-const gchar *plugin_init_id = NULL;
-const gchar *plugin_init_display_name = NULL;
+const gchar *plugin_init_name = NULL;
+const gchar *plugin_init_id = NULL;
+const gchar *plugin_init_display_name = NULL;
+gchar **plugin_init_arguments = NULL;
@@ -321,6 +324,18 @@ xfce_panel_plugin_class_init (XfcePanelPluginClass *klass)
"Unique plugin ID",
NULL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+ /**
+ * XfcePanelPlugin:arguments:
+ *
+ * TODO
+ **/
+ g_object_class_install_property (gobject_class,
+ PROP_ARGUMENTS,
+ g_param_spec_pointer ("arguments",
+ "Arguemnts",
+ "Startup arguments for the plugin",
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
}
@@ -335,6 +350,7 @@ xfce_panel_plugin_init (XfcePanelPlugin *plugin)
plugin->priv->name = NULL;
plugin->priv->display_name = NULL;
plugin->priv->id = NULL;
+ plugin->priv->arguments = NULL;
plugin->priv->size = 0;
plugin->priv->expand = FALSE;
plugin->priv->orientation = GTK_ORIENTATION_HORIZONTAL;
@@ -382,6 +398,10 @@ xfce_panel_plugin_get_property (GObject *object,
g_value_set_static_string (value, plugin->priv->id);
break;
+ case PROP_ARGUMENTS:
+ g_value_set_pointer (value, plugin->priv->arguments);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -424,6 +444,14 @@ xfce_panel_plugin_set_property (GObject *object,
plugin->priv->id = g_value_dup_string (value);
break;
+ case PROP_ARGUMENTS:
+ /* cleanup previous arguments */
+ g_strfreev (plugin->priv->arguments);
+
+ /* set new values */
+ plugin->priv->arguments = g_strdupv (g_value_get_pointer (value));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -459,6 +487,7 @@ xfce_panel_plugin_finalize (GObject *object)
g_free (plugin->priv->name);
g_free (plugin->priv->display_name);
g_free (plugin->priv->id);
+ g_strfreev (plugin->priv->arguments);
(*G_OBJECT_CLASS (xfce_panel_plugin_parent_class)->finalize) (object);
}
@@ -754,6 +783,28 @@ xfce_panel_plugin_get_id (XfcePanelPlugin *plugin)
+gboolean
+xfce_panel_plugin_get_arguments (XfcePanelPlugin *plugin,
+ gchar ***arguments)
+{
+ g_return_val_if_fail (XFCE_IS_PANEL_PLUGIN (plugin), FALSE);
+
+ if (plugin->priv->arguments || plugin_init_arguments)
+ {
+ /* dupplicate the arguments */
+ if (arguments != NULL)
+ *arguments = g_strdupv (plugin->priv->arguments ? plugin->priv->arguments : plugin_init_arguments);
+
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+}
+
+
+
gint
xfce_panel_plugin_get_size (XfcePanelPlugin *plugin)
{
diff --git a/libxfce4panel/xfce-panel-plugin.h b/libxfce4panel/xfce-panel-plugin.h
index d5a9a59..5ab5397 100644
--- a/libxfce4panel/xfce-panel-plugin.h
+++ b/libxfce4panel/xfce-panel-plugin.h
@@ -69,7 +69,7 @@ struct _XfcePanelPlugin
{
/*< private >*/
GtkEventBox __parent__;
-
+
/*< private >*/
XfcePanelPluginPrivate *priv;
};
@@ -83,6 +83,9 @@ const gchar *xfce_panel_plugin_get_display_name (XfcePanelPlugin *plug
const gchar *xfce_panel_plugin_get_id (XfcePanelPlugin *plugin);
+gboolean xfce_panel_plugin_get_arguments (XfcePanelPlugin *plugin,
+ gchar ***arguments);
+
gint xfce_panel_plugin_get_size (XfcePanelPlugin *plugin);
gboolean xfce_panel_plugin_get_expand (XfcePanelPlugin *plugin);
@@ -113,7 +116,7 @@ void xfce_panel_plugin_unblock_menu (XfcePanelPlugin *plug
void xfce_panel_plugin_register_menu (XfcePanelPlugin *plugin,
GtkMenu *menu);
-
+
GtkArrowType xfce_panel_plugin_arrow_type (XfcePanelPlugin *plugin);
void xfce_panel_plugin_position_widget (XfcePanelPlugin *plugin,
@@ -121,7 +124,7 @@ void xfce_panel_plugin_position_widget (XfcePanelPlugin *plug
GtkWidget *attach_widget,
gint *x,
gint *y);
-
+
void xfce_panel_plugin_position_menu (GtkMenu *menu,
gint *x,
gint *y,
diff --git a/panel/main.c b/panel/main.c
index 86617a4..d709246 100644
--- a/panel/main.c
+++ b/panel/main.c
@@ -36,26 +36,30 @@
-static gboolean opt_customize = FALSE;
-static gboolean opt_add = FALSE;
-static gboolean opt_save = FALSE;
-static gboolean opt_restart = FALSE;
-static gboolean opt_quit = FALSE;
-static gboolean opt_version = FALSE;
-static gchar *opt_client_id = NULL;
+static gboolean opt_preferences = FALSE;
+static gboolean opt_add_items = FALSE;
+static gboolean opt_save = FALSE;
+static gchar *opt_add = NULL;
+static gboolean opt_restart = FALSE;
+static gboolean opt_quit = FALSE;
+static gboolean opt_version = FALSE;
+static gchar *opt_client_id = NULL;
+static gchar **arguments = NULL;
/* command line options */
static const GOptionEntry option_entries[] =
{
- { "customize", 'c', 0, G_OPTION_ARG_NONE, &opt_customize, N_("Show the 'Customize Panel' dialog"), NULL },
- { "add", 'a', 0, G_OPTION_ARG_NONE, &opt_add, N_("Show the 'Add New Items' dialog"), NULL },
+ { "preferences", 'p', 0, G_OPTION_ARG_NONE, &opt_preferences, N_("Show the 'Panel Preferences' dialog"), NULL },
+ { "add-items", 'a', 0, G_OPTION_ARG_NONE, &opt_add_items, N_("Show the 'Add New Items' dialog"), NULL },
{ "save", 's', 0, G_OPTION_ARG_NONE, &opt_save, N_("Save the panel configuration"), NULL },
+ { "add", '\0', 0, G_OPTION_ARG_STRING, &opt_add, N_("Add a new plugin to the panel"), N_("PLUGIN NAME") },
{ "restart", 'r', 0, G_OPTION_ARG_NONE, &opt_restart, N_("Restart the running panel instance"), NULL },
{ "quit", 'q', 0, G_OPTION_ARG_NONE, &opt_quit, N_("Quit the running panel instance"), NULL },
{ "version", 'v', 0, G_OPTION_ARG_NONE, &opt_version, N_("Print version information and exit"), NULL },
{ "sm-client-id", '\0', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_STRING, &opt_client_id, NULL, NULL },
+ { G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &arguments, NULL, NULL },
{ NULL }
};
@@ -81,7 +85,7 @@ main (gint argc, gchar **argv)
g_thread_init (NULL);
/* initialize gtk+ */
- if (!gtk_init_with_args (&argc, &argv, "", (GOptionEntry *) option_entries, GETTEXT_PACKAGE, &error))
+ if (!gtk_init_with_args (&argc, &argv, _("[ARGUMENTS...]"), (GOptionEntry *) option_entries, GETTEXT_PACKAGE, &error))
{
/* print an error message */
if (error == NULL)
@@ -114,14 +118,14 @@ main (gint argc, gchar **argv)
return EXIT_SUCCESS;
}
- else if (opt_customize)
+ else if (opt_preferences)
{
/* send a signal to the running instance to show the preferences dialog */
result = panel_dbus_client_display_preferences_dialog (NULL, &error);
goto dbus_return;
}
- else if (opt_add)
+ else if (opt_add_items)
{
/* send a signal to the running instance to show the add items dialog */
result = panel_dbus_client_display_items_dialog (NULL, &error);
@@ -135,6 +139,13 @@ main (gint argc, gchar **argv)
goto dbus_return;
}
+ else if (opt_add)
+ {
+ /* send a add new item signal to the running instance */
+ result = panel_dbus_client_add_new_item (opt_add, arguments, &error);
+
+ goto dbus_return;
+ }
else if (opt_restart || opt_quit)
{
/* send a terminate signal to the running instance */
diff --git a/panel/panel-application.c b/panel/panel-application.c
index 6a0d9da..9e91255 100644
--- a/panel/panel-application.c
+++ b/panel/panel-application.c
@@ -243,7 +243,7 @@ panel_application_load (PanelApplication *application)
{
/* create empty panel window */
window = panel_application_new_window (application, NULL);
-
+
/* TODO add some cruft here */
/* show window */
@@ -302,7 +302,7 @@ panel_application_load_set_property (PanelWindow *window,
/* 0: normal width, 1: full width and 2: span monitors */
if (integer > 1)
panel_window_set_length (window, 100);
-
+
if (integer == 2)
panel_window_set_span_monitors (window, TRUE);
}
@@ -349,23 +349,23 @@ move_handle (GtkWidget *item,
panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (item));
panel_return_if_fail (PANEL_IS_APPLICATION (application));
-
+
/* get a copy of the current event */
event = gtk_get_current_event ();
if (G_LIKELY (event))
{
/* make the window insensitive */
panel_application_windows_sensitive (application, FALSE);
-
+
/* create a target list */
target_list = gtk_target_list_new (drag_targets, G_N_ELEMENTS (drag_targets));
-
+
/* begin a drag */
gtk_drag_begin (item, target_list, GDK_ACTION_MOVE, 1, event);
-
+
/* release the drag list */
gtk_target_list_unref (target_list);
-
+
/* free the event */
gdk_event_free (event);
}
@@ -378,37 +378,38 @@ panel_application_get_unique_id (void)
{
static gint counter = 0;
static gchar id[30];
-
+
/* create a unique if of the current time and counter */
g_snprintf (id, sizeof(id), "%ld%d", time (NULL), counter++);
-
+
return id;
}
static gboolean
-panel_application_insert_plugin (PanelApplication *application,
- PanelWindow *window,
- GdkScreen *screen,
- const gchar *name,
- const gchar *id,
- UseWrapper use_wrapper,
- gint position)
+panel_application_insert_plugin (PanelApplication *application,
+ PanelWindow *window,
+ GdkScreen *screen,
+ const gchar *name,
+ const gchar *id,
+ gchar **arguments,
+ UseWrapper use_wrapper,
+ gint position)
{
GtkWidget *itembar;
gboolean succeed = FALSE;
XfcePanelPluginProvider *provider;
-
+
panel_return_val_if_fail (PANEL_IS_APPLICATION (application), FALSE);
panel_return_val_if_fail (PANEL_IS_WINDOW (window), FALSE);
panel_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE);
panel_return_val_if_fail (name != NULL, FALSE);
-
+
/* create a new unique id if needed */
if (id == NULL)
id = panel_application_get_unique_id ();
-
+
/* create a new panel plugin */
- provider = panel_module_factory_create_plugin (application->factory, screen, name, id, use_wrapper);
+ provider = panel_module_factory_create_plugin (application->factory, screen, name, id, arguments, use_wrapper);
if (G_LIKELY (provider != NULL))
{
@@ -422,21 +423,21 @@ panel_application_insert_plugin (PanelApplication *application,
/* add the item to the panel */
panel_itembar_insert (PANEL_ITEMBAR (itembar), GTK_WIDGET (provider), position);
-
+
/* show the plugin */
gtk_widget_show (GTK_WIDGET (provider));
-
+
xfce_panel_plugin_provider_set_orientation (provider, panel_window_get_orientation (window));
xfce_panel_plugin_provider_set_screen_position (provider, panel_glue_get_screen_position (window));
xfce_panel_plugin_provider_set_size (provider, panel_window_get_size (window));
-
+
/* we've succeeded */
succeed = TRUE;
}
-
+
return succeed;
}
-
+
static void
@@ -520,7 +521,7 @@ panel_application_load_start_element (GMarkupParseContext *context,
if (G_LIKELY (name != NULL))
panel_application_insert_plugin (parser->application, parser->window,
gtk_window_get_screen (GTK_WINDOW (parser->window)),
- name, id, use_wrapper, -1);
+ name, id, NULL, use_wrapper, -1);
}
break;
@@ -737,6 +738,47 @@ panel_application_get (void)
void
+panel_application_save (PanelApplication *application)
+{
+ gchar *filename;
+ gchar *contents;
+ gboolean succeed;
+ GError *error = NULL;
+
+ panel_return_if_fail (PANEL_IS_APPLICATION (application));
+
+ /* get save location */
+ filename = xfce_resource_save_location (XFCE_RESOURCE_CONFIG, PANEL_CONFIG_PATH, TRUE);
+ if (G_LIKELY (filename))
+ {
+ /* get the file xml data */
+ contents = panel_application_save_xml_contents (application);
+
+ /* write the data to the file */
+ succeed = g_file_set_contents (filename, contents, -1, &error);
+ if (G_UNLIKELY (succeed == FALSE))
+ {
+ /* writing failed, print warning */
+ g_critical ("Failed to write panel configuration to \"%s\": %s", filename, error->message);
+
+ /* cleanup */
+ g_error_free (error);
+ }
+
+ /* cleanup */
+ g_free (contents);
+ g_free (filename);
+ }
+ else
+ {
+ /* print warning */
+ g_critical ("Failed to create panel configuration file");
+ }
+}
+
+
+
+void
panel_application_take_dialog (PanelApplication *application,
GtkWindow *dialog)
{
@@ -776,42 +818,21 @@ panel_application_destroy_dialogs (PanelApplication *application)
void
-panel_application_save (PanelApplication *application)
+panel_application_add_new_item (PanelApplication *application,
+ const gchar *plugin_name,
+ gchar **arguments)
{
- gchar *filename;
- gchar *contents;
- gboolean succeed;
- GError *error = NULL;
+ PanelWindow *window;
panel_return_if_fail (PANEL_IS_APPLICATION (application));
+ panel_return_if_fail (plugin_name != NULL);
- /* get save location */
- filename = xfce_resource_save_location (XFCE_RESOURCE_CONFIG, PANEL_CONFIG_PATH, TRUE);
- if (G_LIKELY (filename))
- {
- /* get the file xml data */
- contents = panel_application_save_xml_contents (application);
-
- /* write the data to the file */
- succeed = g_file_set_contents (filename, contents, -1, &error);
- if (G_UNLIKELY (succeed == FALSE))
- {
- /* writing failed, print warning */
- g_critical ("Failed to write panel configuration to \"%s\": %s", filename, error->message);
+ /* TODO fix this */
+ window = application->windows->data;
- /* cleanup */
- g_error_free (error);
- }
-
- /* cleanup */
- g_free (contents);
- g_free (filename);
- }
- else
- {
- /* print warning */
- g_critical ("Failed to create panel configuration file");
- }
+ if (!panel_application_insert_plugin (application, window, gtk_widget_get_screen (GTK_WIDGET (window)),
+ plugin_name, NULL, arguments, FROM_DESKTOP_FILE, -1))
+ g_warning (_("The plugin you want to add is not recognized by the panel."), plugin_name);
}
@@ -833,59 +854,59 @@ panel_application_drag_data_received (GtkWidget *itembar,
GdkScreen *screen;
const gchar *name;
guint old_position;
-
+
panel_return_if_fail (PANEL_IS_ITEMBAR (itembar));
panel_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
panel_return_if_fail (PANEL_IS_WINDOW (window));
-
+
/* get the application */
application = panel_application_get ();
-
+
/* get the drop index on the itembar */
position = panel_itembar_get_drop_index (PANEL_ITEMBAR (itembar), x, y);
-
+
/* get the widget screen */
screen = gtk_widget_get_screen (itembar);
-
+
/* TODO replace with enums */
switch (info)
{
case 0:
/* uri */
break;
-
+
case 1:
if (G_LIKELY (selection_data->length > 0))
{
/* get the name from the selection data */
name = (const gchar *) selection_data->data;
-
+
/* create a new item with a unique id */
- succeed = panel_application_insert_plugin (application, window, screen, name,
- NULL, FROM_DESKTOP_FILE, position);
+ succeed = panel_application_insert_plugin (application, window, screen, name,
+ NULL, NULL, FROM_DESKTOP_FILE, position);
}
break;
-
+
case 2:
/* make the itembar sensitive again */
panel_application_windows_sensitive (application, TRUE);
-
+
/* get the source widget */
provider = gtk_drag_get_source_widget (context);
-
+
/* debug check */
panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider));
-
+
/* check if we move to another itembar */
if (gtk_widget_get_parent (provider) == itembar)
{
/* get the current position on the itembar */
old_position = panel_itembar_get_child_index (PANEL_ITEMBAR (itembar), provider);
-
+
/* decrease the counter if we drop after the current position */
if (position > old_position)
position--;
-
+
/* reorder the child if needed */
if (old_position != position)
panel_itembar_reorder_child (PANEL_ITEMBAR (itembar), provider, position);
@@ -894,32 +915,32 @@ panel_application_drag_data_received (GtkWidget *itembar,
{
/* reparent the widget, this will also call remove and add for the itembar */
gtk_widget_reparent (provider, itembar);
-
+
/* move the item to the correct position on the itembar */
panel_itembar_reorder_child (PANEL_ITEMBAR (itembar), provider, position);
-
+
/* set new panel size */
xfce_panel_plugin_provider_set_size (XFCE_PANEL_PLUGIN_PROVIDER (provider), panel_window_get_size (window));
-
+
/* TODO update more here */
}
-
+
/* everything went fine */
succeed = TRUE;
break;
-
+
default:
panel_assert_not_reached ();
break;
}
-
+
/* save the panel configuration if we succeeded */
if (G_LIKELY (succeed))
panel_application_save (application);
/* release the application */
g_object_unref (G_OBJECT (application));
-
+
/* tell the peer that we handled the drop */
gtk_drag_finish (context, succeed, FALSE, time);
}
@@ -935,20 +956,20 @@ panel_application_drag_drop (GtkWidget *itembar,
PanelWindow *window)
{
GdkAtom target;
-
+
panel_return_val_if_fail (PANEL_IS_ITEMBAR (itembar), FALSE);
panel_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), FALSE);
panel_return_val_if_fail (PANEL_IS_WINDOW (window), FALSE);
-
+
target = gtk_drag_dest_find_target (itembar, context, NULL);
-
+
/* we cannot handle the drag data */
if (G_UNLIKELY (target == GDK_NONE))
return FALSE;
-
+
/* request the drag data */
gtk_drag_get_data (itembar, context, target, time);
-
+
/* we call gtk_drag_finish later */
return TRUE;
}
@@ -985,7 +1006,7 @@ panel_application_new_window (PanelApplication *application,
exo_binding_new (G_OBJECT (window), "orientation", G_OBJECT (itembar), "orientation");
gtk_container_add (GTK_CONTAINER (window), itembar);
gtk_widget_show (itembar);
-
+
/* signals for drag and drop */
g_signal_connect (G_OBJECT (itembar), "drag-data-received", G_CALLBACK (panel_application_drag_data_received), window);
g_signal_connect (G_OBJECT (itembar), "drag-drop", G_CALLBACK (panel_application_drag_drop), window);
@@ -1021,7 +1042,7 @@ panel_application_get_window_index (PanelApplication *application,
{
panel_return_val_if_fail (PANEL_IS_APPLICATION (application), 0);
panel_return_val_if_fail (PANEL_IS_WINDOW (window), 0);
-
+
return g_slist_index (application->windows, window);
}
@@ -1038,24 +1059,24 @@ panel_application_get_window (PanelApplication *application,
-void
+void
panel_application_windows_sensitive (PanelApplication *application,
gboolean sensitive)
{
GtkWidget *itembar;
GSList *li;
-
+
panel_return_if_fail (PANEL_IS_APPLICATION (application));
-
+
/* walk the windows */
for (li = application->windows; li != NULL; li = li->next)
{
/* get the window itembar */
itembar = gtk_bin_get_child (GTK_BIN (li->data));
-
+
/* set sensitivity of the itembar (and the plugins) */
panel_itembar_set_sensitive (PANEL_ITEMBAR (itembar), sensitive);
-
+
/* block autohide for all windows */
if (sensitive)
panel_window_thaw_autohide (PANEL_WINDOW (li->data));
@@ -1066,14 +1087,14 @@ panel_application_windows_sensitive (PanelApplication *application,
-void
+void
panel_application_windows_autohide (PanelApplication *application,
gboolean freeze)
{
GSList *li;
-
+
panel_return_if_fail (PANEL_IS_APPLICATION (application));
-
+
for (li = application->windows; li != NULL; li = li->next)
{
if (freeze)
diff --git a/panel/panel-application.h b/panel/panel-application.h
index 90aafd3..4eceafd 100644
--- a/panel/panel-application.h
+++ b/panel/panel-application.h
@@ -41,29 +41,33 @@ void panel_application_multihead_area (GtkWidget *widget,
PanelApplication *panel_application_get (void);
-void panel_application_save (PanelApplication *application);
+void panel_application_save (PanelApplication *application);
-void panel_application_take_dialog (PanelApplication *application,
- GtkWindow *dialog);
+void panel_application_take_dialog (PanelApplication *application,
+ GtkWindow *dialog);
-void panel_application_destroy_dialogs (PanelApplication *application);
+void panel_application_destroy_dialogs (PanelApplication *application);
-PanelWindow *panel_application_new_window (PanelApplication *application,
- GdkScreen *screen);
-
-gint panel_application_get_n_windows (PanelApplication *application);
+void panel_application_add_new_item (PanelApplication *application,
+ const gchar *plugin_name,
+ gchar **arguments);
-gint panel_application_get_window_index (PanelApplication *application,
- PanelWindow *window);
+PanelWindow *panel_application_new_window (PanelApplication *application,
+ GdkScreen *screen);
-PanelWindow *panel_application_get_window (PanelApplication *application,
- guint idx);
-
-void panel_application_windows_sensitive (PanelApplication *application,
- gboolean sensitive);
-
-void panel_application_windows_autohide (PanelApplication *application,
- gboolean freeze);
+gint panel_application_get_n_windows (PanelApplication *application);
+
+gint panel_application_get_window_index (PanelApplication *application,
+ PanelWindow *window);
+
+PanelWindow *panel_application_get_window (PanelApplication *application,
+ guint idx);
+
+void panel_application_windows_sensitive (PanelApplication *application,
+ gboolean sensitive);
+
+void panel_application_windows_autohide (PanelApplication *application,
+ gboolean freeze);
G_END_DECLS
diff --git a/panel/panel-dbus-client.c b/panel/panel-dbus-client.c
index 132fc9a..426c0a5 100644
--- a/panel/panel-dbus-client.c
+++ b/panel/panel-dbus-client.c
@@ -170,6 +170,40 @@ panel_dbus_client_save (GError **error)
gboolean
+panel_dbus_client_add_new_item (const gchar *plugin_name,
+ gchar **arguments,
+ GError **error)
+{
+ DBusMessage *message;
+ gboolean result;
+ guint length;
+
+ panel_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+ /* arguments length */
+ length = arguments ? g_strv_length (arguments) : 0;
+
+ /* generate the message */
+ message = dbus_message_new_method_call (PANEL_DBUS_SERVICE_INTERFACE, PANEL_DBUS_SERVICE_PATH,
+ PANEL_DBUS_SERVICE_INTERFACE, "AddNewItem");
+ dbus_message_set_auto_start (message, FALSE);
+ dbus_message_append_args (message,
+ DBUS_TYPE_STRING, &plugin_name,
+ DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &arguments, length,
+ DBUS_TYPE_INVALID);
+
+ /* send the message */
+ result = panel_dbus_client_send_message (message, error);
+
+ /* release the message */
+ dbus_message_unref (message);
+
+ return result;
+}
+
+
+
+gboolean
panel_dbus_client_terminate (gboolean restart,
GError **error)
{
diff --git a/panel/panel-dbus-client.h b/panel/panel-dbus-client.h
index a949ba7..ab12d51 100644
--- a/panel/panel-dbus-client.h
+++ b/panel/panel-dbus-client.h
@@ -21,16 +21,20 @@
#include <glib.h>
#include <gdk/gdk.h>
-gboolean panel_dbus_client_display_preferences_dialog (GdkScreen *screen,
- GError **error);
+gboolean panel_dbus_client_display_preferences_dialog (GdkScreen *screen,
+ GError **error);
-gboolean panel_dbus_client_display_items_dialog (GdkScreen *screen,
- GError **error);
+gboolean panel_dbus_client_display_items_dialog (GdkScreen *screen,
+ GError **error);
-gboolean panel_dbus_client_save (GError **error);
+gboolean panel_dbus_client_save (GError **error);
-gboolean panel_dbus_client_terminate (gboolean restart,
- GError **error);
+gboolean panel_dbus_client_add_new_item (const gchar *plugin_name,
+ gchar **arguments,
+ GError **error);
+
+gboolean panel_dbus_client_terminate (gboolean restart,
+ GError **error);
G_END_DECLS
diff --git a/panel/panel-dbus-service-infos.xml b/panel/panel-dbus-service-infos.xml
index d38acf8..ce7805b 100644
--- a/panel/panel-dbus-service-infos.xml
+++ b/panel/panel-dbus-service-infos.xml
@@ -48,7 +48,18 @@
Tells the panel to save its configuration, including all the plugins.
-->
- <method name="Save">
+ <method name="Save" />
+
+ <!--
+ AddNewItem (name : STRING, args : ARRAY OF STRING) : VOID
+
+ plugin-name : The internal name of the plugin the user wants to add.
+ arguments : Optional arguments send with the command line. This
+ could be files or anything else.
+ -->
+ <method name="AddNewItem">
+ <arg name="plugin-name" direction="in" type="s" />
+ <arg name="arguments" direction="in" type="as" />
</method>
<!--
diff --git a/panel/panel-dbus-service.c b/panel/panel-dbus-service.c
index e42df9b..525515f 100644
--- a/panel/panel-dbus-service.c
+++ b/panel/panel-dbus-service.c
@@ -181,6 +181,35 @@ panel_dbus_service_save (PanelDBusService *service,
static gboolean
+panel_dbus_service_add_new_item (PanelDBusService *service,
+ const gchar *plugin_name,
+ gchar **arguments,
+ GError **error)
+{
+ PanelApplication *application;
+
+ panel_return_val_if_fail (PANEL_IS_DBUS_SERVICE (service), FALSE);
+ panel_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+ panel_return_val_if_fail (plugin_name != NULL, FALSE);
+
+ /* get the current application */
+ application = panel_application_get ();
+
+ /* save the configuration */
+ if (arguments && *arguments != NULL)
+ panel_application_add_new_item (application, plugin_name, arguments);
+ else
+ panel_application_add_new_item (application, plugin_name, NULL);
+
+ /* release the application */
+ g_object_unref (G_OBJECT (application));
+
+ return TRUE;
+}
+
+
+
+static gboolean
panel_dbus_service_terminate (PanelDBusService *service,
gboolean restart,
GError **error)
diff --git a/panel/panel-module-factory.c b/panel/panel-module-factory.c
index a8c20c4..96ba071 100644
--- a/panel/panel-module-factory.c
+++ b/panel/panel-module-factory.c
@@ -59,7 +59,7 @@ struct _PanelModuleFactory
/* table of loaded modules */
GHashTable *modules;
-
+
/* if the factory contains the launcher plugin */
guint has_launcher : 1;
};
@@ -103,7 +103,7 @@ panel_module_factory_init (PanelModuleFactory *factory)
{
/* initialize */
factory->has_launcher = FALSE;
-
+
/* create hash table */
factory->modules = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
@@ -187,7 +187,7 @@ panel_module_factory_load_modules (PanelModuleFactory *factory)
/* get the new module internal name */
internal_name = g_strndup (name, p - name);
-
+
/* check if the modules name is already loaded */
if (G_UNLIKELY (g_hash_table_lookup (factory->modules, internal_name) != NULL))
goto already_loaded;
@@ -199,7 +199,7 @@ panel_module_factory_load_modules (PanelModuleFactory *factory)
{
/* add the module to the internal list */
g_hash_table_insert (factory->modules, internal_name, module);
-
+
/* check if this is the launcher */
if (factory->has_launcher == FALSE && exo_str_is_equal (LAUNCHER_PLUGIN_NAME, internal_name))
factory->has_launcher = TRUE;
@@ -207,7 +207,7 @@ panel_module_factory_load_modules (PanelModuleFactory *factory)
else
{
already_loaded:
-
+
/* cleanup */
g_free (internal_name);
}
@@ -215,7 +215,7 @@ panel_module_factory_load_modules (PanelModuleFactory *factory)
/* cleanup */
g_free (filename);
}
-
+
/* close directory */
g_dir_close (dir);
}
@@ -238,17 +238,17 @@ panel_module_factory_modules_cleanup (gpointer key,
PanelModuleFactory *factory = PANEL_MODULE_FACTORY (user_data);
PanelModule *module = PANEL_MODULE (value);
gboolean remove;
-
+
panel_return_val_if_fail (PANEL_IS_MODULE (module), TRUE);
panel_return_val_if_fail (PANEL_IS_MODULE_FACTORY (factory), TRUE);
-
+
/* get whether the module is valid */
remove = !panel_module_is_valid (module);
-
+
/* if we're going to remove this item, check if it's the launcher */
if (remove == TRUE && exo_str_is_equal (LAUNCHER_PLUGIN_NAME, panel_module_get_internal_name (module)))
factory->has_launcher = FALSE;
-
+
return remove;
}
@@ -280,7 +280,7 @@ gboolean
panel_module_factory_has_launcher (PanelModuleFactory *factory)
{
panel_return_val_if_fail (PANEL_IS_MODULE_FACTORY (factory), FALSE);
-
+
return factory->has_launcher;
}
@@ -324,10 +324,10 @@ GList *
panel_module_factory_get_modules (PanelModuleFactory *factory)
{
panel_return_val_if_fail (PANEL_IS_MODULE_FACTORY (factory), NULL);
-
+
/* make sure the hash table is clean */
g_hash_table_foreach_remove (factory->modules, panel_module_factory_modules_cleanup, factory);
-
+
#if GLIB_CHECK_VERSION (2,14,0)
return g_hash_table_get_values (factory->modules);
#else
@@ -343,11 +343,12 @@ panel_module_factory_get_modules (PanelModuleFactory *factory)
XfcePanelPluginProvider *
-panel_module_factory_create_plugin (PanelModuleFactory *factory,
- GdkScreen *screen,
- const gchar *name,
- const gchar *id,
- UseWrapper use_wrapper)
+panel_module_factory_create_plugin (PanelModuleFactory *factory,
+ GdkScreen *screen,
+ const gchar *name,
+ const gchar *id,
+ gchar **arguments,
+ UseWrapper use_wrapper)
{
PanelModule *module;
@@ -367,5 +368,5 @@ panel_module_factory_create_plugin (PanelModuleFactory *factory,
}
/* create the new module */
- return panel_module_create_plugin (module, screen, name, id, use_wrapper);
+ return panel_module_create_plugin (module, screen, name, id, arguments, use_wrapper);
}
diff --git a/panel/panel-module-factory.h b/panel/panel-module-factory.h
index d077d71..5613a60 100644
--- a/panel/panel-module-factory.h
+++ b/panel/panel-module-factory.h
@@ -41,17 +41,18 @@ GType panel_module_factory_get_type (void) G_GNUC_
PanelModuleFactory *panel_module_factory_get (void);
-gboolean panel_module_factory_has_launcher (PanelModuleFactory *factory);
+gboolean panel_module_factory_has_launcher (PanelModuleFactory *factory);
-void panel_module_factory_emit_unique_changed (PanelModule *module);
+void panel_module_factory_emit_unique_changed (PanelModule *module);
-GList *panel_module_factory_get_modules (PanelModuleFactory *factory);
+GList *panel_module_factory_get_modules (PanelModuleFactory *factory);
-XfcePanelPluginProvider *panel_module_factory_create_plugin (PanelModuleFactory *factory,
- GdkScreen *screen,
- const gchar *name,
- const gchar *id,
- UseWrapper use_wrapper);
+XfcePanelPluginProvider *panel_module_factory_create_plugin (PanelModuleFactory *factory,
+ GdkScreen *screen,
+ const gchar *name,
+ const gchar *id,
+ gchar **arguments,
+ UseWrapper use_wrapper);
G_END_DECLS
diff --git a/panel/panel-module.c b/panel/panel-module.c
index 5c3c3c0..618e9bd 100644
--- a/panel/panel-module.c
+++ b/panel/panel-module.c
@@ -319,11 +319,12 @@ panel_module_new_from_desktop_file (const gchar *filename,
XfcePanelPluginProvider *
-panel_module_create_plugin (PanelModule *module,
- GdkScreen *screen,
- const gchar *name,
- const gchar *id,
- UseWrapper use_wrapper)
+panel_module_create_plugin (PanelModule *module,
+ GdkScreen *screen,
+ const gchar *name,
+ const gchar *id,
+ gchar **arguments,
+ UseWrapper use_wrapper)
{
XfcePanelPluginProvider *plugin = NULL;
gboolean external;
@@ -345,7 +346,7 @@ panel_module_create_plugin (PanelModule *module,
if (external)
{
/* create external plugin */
- plugin = panel_plugin_external_new (module, name, id);
+ plugin = panel_plugin_external_new (module, name, id, arguments);
}
else
{
@@ -358,7 +359,7 @@ panel_module_create_plugin (PanelModule *module,
panel_return_val_if_fail (module->construct_func != NULL, NULL);
/* create a new panel plugin */
- plugin = (*module->construct_func) (name, id, module->name, screen);
+ plugin = (*module->construct_func) (name, id, module->name, arguments, screen);
}
else
{
diff --git a/panel/panel-module.h b/panel/panel-module.h
index 091c851..3d79db8 100644
--- a/panel/panel-module.h
+++ b/panel/panel-module.h
@@ -44,28 +44,29 @@ enum _UseWrapper
GType panel_module_get_type (void) G_GNUC_CONST;
-PanelModule *panel_module_new_from_desktop_file (const gchar *filename,
- const gchar *name);
+PanelModule *panel_module_new_from_desktop_file (const gchar *filename,
+ const gchar *name);
-XfcePanelPluginProvider *panel_module_create_plugin (PanelModule *module,
- GdkScreen *screen,
- const gchar *name,
- const gchar *id,
- UseWrapper use_wrapper);
-
-const gchar *panel_module_get_internal_name (PanelModule *module);
+XfcePanelPluginProvider *panel_module_create_plugin (PanelModule *module,
+ GdkScreen *screen,
+ const gchar *name,
+ const gchar *id,
+ gchar **arguments,
+ UseWrapper use_wrapper);
-const gchar *panel_module_get_library_filename (PanelModule *module);
+const gchar *panel_module_get_internal_name (PanelModule *module);
-const gchar *panel_module_get_name (PanelModule *module);
+const gchar *panel_module_get_library_filename (PanelModule *module);
-const gchar *panel_module_get_comment (PanelModule *module);
+const gchar *panel_module_get_name (PanelModule *module);
-const gchar *panel_module_get_icon_name (PanelModule *module);
+const gchar *panel_module_get_comment (PanelModule *module);
-gboolean panel_module_is_valid (PanelModule *module);
+const gchar *panel_module_get_icon_name (PanelModule *module);
-gboolean panel_module_is_usable (PanelModule *module);
+gboolean panel_module_is_valid (PanelModule *module);
+
+gboolean panel_module_is_usable (PanelModule *module);
G_END_DECLS
diff --git a/panel/panel-plugin-external.c b/panel/panel-plugin-external.c
index c7f6398..dd0d6bf 100644
--- a/panel/panel-plugin-external.c
+++ b/panel/panel-plugin-external.c
@@ -64,16 +64,16 @@ struct _PanelPluginExternalClass
struct _PanelPluginExternal
{
GtkSocket __parent__;
-
+
/* plugin information */
gchar *id;
-
+
/* the module */
PanelModule *module;
-
+
/* the plug window id */
GdkNativeWindow plug_window_id;
-
+
/* message queue */
GSList *queue;
};
@@ -105,15 +105,15 @@ panel_plugin_external_class_init (PanelPluginExternalClass *klass)
gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = panel_plugin_external_finalize;
-
+
gtkwidget_class = GTK_WIDGET_CLASS (klass);
gtkwidget_class->realize = panel_plugin_external_realize;
gtkwidget_class->unrealize = panel_plugin_external_unrealize;
gtkwidget_class->client_event = panel_plugin_external_client_event;
-
+
gtksocket_class = GTK_SOCKET_CLASS (klass);
gtksocket_class->plug_removed = panel_plugin_external_plug_removed;
-
+
/* initialize the global message atom */
message_atom = panel_atom_intern ("XFCE_PANEL_PLUGIN");
}
@@ -127,7 +127,7 @@ panel_plugin_external_init (PanelPluginExternal *external)
external->module = NULL;
external->plug_window_id = 0;
external->queue = NULL;
-
+
g_signal_connect (G_OBJECT (external), "notify::sensitive", G_CALLBACK (panel_plugin_external_set_sensitive), NULL);
}
@@ -149,12 +149,12 @@ static void
panel_plugin_external_finalize (GObject *object)
{
PanelPluginExternal *external = PANEL_PLUGIN_EXTERNAL (object);
-
+
panel_return_if_fail (external->queue == NULL);
-
+
/* cleanup */
g_free (external->id);
-
+
/* release the module */
g_object_unref (G_OBJECT (external->module));
@@ -172,13 +172,13 @@ panel_plugin_external_realize (GtkWidget *widget)
GError *error = NULL;
gboolean succeed;
gchar *socket_id;
-
+
/* realize the socket first */
(*GTK_WIDGET_CLASS (panel_plugin_external_parent_class)->realize) (widget);
-
+
/* get the socket id in a string */
socket_id = g_strdup_printf ("%d", gtk_socket_get_id (GTK_SOCKET (widget)));
-
+
/* construct the argv */
argv[0] = LIBEXECDIR "/xfce4-panel-wrapper";
argv[1] = "-n";
@@ -192,19 +192,19 @@ panel_plugin_external_realize (GtkWidget *widget)
argv[9] = "-s";
argv[10] = socket_id;
argv[11] = NULL;
-
+
/* spawn the proccess */
succeed = gdk_spawn_on_screen (gdk_screen_get_default (), NULL, argv, NULL, 0, NULL, NULL, &pid, &error);
-
+
/* cleanup */
g_free (socket_id);
-
+
/* handle problem */
if (G_UNLIKELY (succeed == FALSE))
{
/* show warnings */
g_critical ("Failed to spawn the xfce4-panel-wrapped: %s", error->message);
-
+
/* cleanup */
g_error_free (error);
}
@@ -212,17 +212,17 @@ panel_plugin_external_realize (GtkWidget *widget)
-static void
+static void
panel_plugin_external_unrealize (GtkWidget *widget)
{
PanelPluginExternal *external = PANEL_PLUGIN_EXTERNAL (widget);
-
+
/* send message to quit the wrapper */
panel_plugin_external_send_message (PANEL_PLUGIN_EXTERNAL (external), MESSAGE_QUIT, 0);
-
+
/* don't send or queue messages */
external->plug_window_id = -1;
-
+
return (*GTK_WIDGET_CLASS (panel_plugin_external_parent_class)->unrealize) (widget);
}
@@ -235,57 +235,57 @@ panel_plugin_external_client_event (GtkWidget *widget,
PanelPluginExternal *external = PANEL_PLUGIN_EXTERNAL (widget);
XfcePanelPluginMessage message;
glong value;
-
+
panel_return_val_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (widget), FALSE);
-
+
/* check if this even is for us */
if (G_LIKELY (event->message_type == message_atom))
{
/* get the event message and value */
message = event->data.l[0];
value = event->data.l[1];
-
+
/* handle the message */
switch (message)
{
case MESSAGE_EXPAND_CHANGED:
g_signal_emit_by_name (G_OBJECT (external), "expand-changed", !!(value == 1));
break;
-
+
case MESSAGE_MOVE_ITEM:
g_signal_emit_by_name (G_OBJECT (external), "move-item", 0);
break;
-
+
case MESSAGE_ADD_NEW_ITEMS:
g_signal_emit_by_name (G_OBJECT (external), "add-new-items", 0);
break;
-
+
case MESSAGE_CUSTOMIZE_PANEL:
g_signal_emit_by_name (G_OBJECT (external), "customize-panel", 0);
break;
-
+
case MESSAGE_REMOVE:
/* plugin properly removed, destroy the socket */
gtk_widget_destroy (widget);
break;
-
+
case MESSAGE_SET_PLUG_ID:
/* set the plug window id */
external->plug_window_id = value;
-
+
/* flush the message queue */
panel_plugin_external_flush_queue (external);
break;
-
+
default:
g_message ("The panel received an unkown message: %d", message);
break;
}
-
+
/* we handled the event */
return TRUE;
}
-
+
/* propagate event */
if (GTK_WIDGET_CLASS (panel_plugin_external_parent_class)->client_event)
return (*GTK_WIDGET_CLASS (panel_plugin_external_parent_class)->client_event) (widget, event);
@@ -299,13 +299,13 @@ static gboolean
panel_plugin_external_plug_removed (GtkSocket *socket)
{
PanelPluginExternal *external = PANEL_PLUGIN_EXTERNAL (socket);
-
+
/* don't send or queue messages */
external->plug_window_id = -1;
-
+
/* destroy the socket */
gtk_widget_destroy (GTK_WIDGET (socket));
-
+
if (GTK_SOCKET_CLASS (panel_plugin_external_parent_class)->plug_removed)
return (*GTK_SOCKET_CLASS (panel_plugin_external_parent_class)->plug_removed) (socket);
return FALSE;
@@ -320,9 +320,9 @@ panel_plugin_external_send_message (PanelPluginExternal *external,
{
GdkEventClient event;
QueueData *data;
-
+
panel_return_if_fail (PANEL_IS_PLUGIN_EXTERNAL (external));
-
+
if (G_LIKELY (external->plug_window_id > 0))
{
/* setup the event */
@@ -334,16 +334,16 @@ panel_plugin_external_send_message (PanelPluginExternal *external,
event.data.l[0] = message;
event.data.l[1] = value;
event.data.l[2] = 0;
-
+
/* don't crash on x errors */
gdk_error_trap_push ();
-
+
/* send the event to the wrapper */
gdk_event_send_client_message_for_display (gdk_display_get_default (), (GdkEvent *) &event, external->plug_window_id);
-
+
/* flush the x output buffer */
gdk_flush ();
-
+
/* pop the push */
gdk_error_trap_pop ();
}
@@ -353,7 +353,7 @@ panel_plugin_external_send_message (PanelPluginExternal *external,
data = g_slice_new0 (QueueData);
data->message = message;
data->value = value;
-
+
/* add the message to the list */
external->queue = g_slist_append (external->queue, data);
}
@@ -366,27 +366,27 @@ panel_plugin_external_flush_queue (PanelPluginExternal *external)
{
GSList *li;
QueueData *data;
-
+
panel_return_if_fail (PANEL_IS_PLUGIN_EXTERNAL (external));
panel_return_if_fail (external->plug_window_id != 0);
-
+
if (external->queue != NULL)
{
/* free all message */
for (li = external->queue; li != NULL; li = li->next)
{
data = li->data;
-
+
/* send message */
panel_plugin_external_send_message (external, data->message, data->value);
-
+
/* cleanup */
g_slice_free (QueueData, data);
}
-
+
/* cleanup */
g_slist_free (external->queue);
-
+
/* set to null */
external->queue = NULL;
}
@@ -399,7 +399,7 @@ panel_plugin_external_get_name (XfcePanelPluginProvider *provider)
{
panel_return_val_if_fail (PANEL_IS_PLUGIN_EXTERNAL (provider), NULL);
panel_return_val_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider), NULL);
-
+
return panel_module_get_internal_name (PANEL_PLUGIN_EXTERNAL (provider)->module);
}
@@ -410,7 +410,7 @@ panel_plugin_external_get_id (XfcePanelPluginProvider *provider)
{
panel_return_val_if_fail (PANEL_IS_PLUGIN_EXTERNAL (provider), NULL);
panel_return_val_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider), NULL);
-
+
return PANEL_PLUGIN_EXTERNAL (provider)->id;
}
@@ -450,7 +450,7 @@ static void
panel_plugin_external_set_sensitive (PanelPluginExternal *external)
{
panel_return_if_fail (PANEL_IS_PLUGIN_EXTERNAL (external));
-
+
/* send message */
panel_plugin_external_send_message (external, MESSAGE_SET_SENSITIVE, GTK_WIDGET_IS_SENSITIVE (external) ? 1 : 0);
}
@@ -458,23 +458,24 @@ panel_plugin_external_set_sensitive (PanelPluginExternal *external)
XfcePanelPluginProvider *
-panel_plugin_external_new (PanelModule *module,
- const gchar *name,
- const gchar *id)
+panel_plugin_external_new (PanelModule *module,
+ const gchar *name,
+ const gchar *id,
+ gchar **arguments)
{
PanelPluginExternal *external;
-
+
panel_return_val_if_fail (PANEL_IS_MODULE (module), NULL);
panel_return_val_if_fail (name != NULL, NULL);
panel_return_val_if_fail (id != NULL, NULL);
-
+
/* create new object */
external = g_object_new (PANEL_TYPE_PLUGIN_EXTERNAL, NULL);
-
+
/* set name, id and module */
external->id = g_strdup (id);
external->module = g_object_ref (G_OBJECT (module));
-
+
return XFCE_PANEL_PLUGIN_PROVIDER (external);
}
diff --git a/panel/panel-plugin-external.h b/panel/panel-plugin-external.h
index 6e98064..d98d09a 100644
--- a/panel/panel-plugin-external.h
+++ b/panel/panel-plugin-external.h
@@ -37,7 +37,7 @@ typedef struct _PanelPluginExternal PanelPluginExternal;
GType panel_plugin_external_get_type (void) G_GNUC_CONST;
-XfcePanelPluginProvider *panel_plugin_external_new (PanelModule *module, const gchar *name, const gchar *id);
+XfcePanelPluginProvider *panel_plugin_external_new (PanelModule *module, const gchar *name, const gchar *id, gchar **arguments);
G_END_DECLS
diff --git a/plugins/launcher/launcher-dialog.c b/plugins/launcher/launcher-dialog.c
index d191137..b46b906 100644
--- a/plugins/launcher/launcher-dialog.c
+++ b/plugins/launcher/launcher-dialog.c
@@ -89,8 +89,6 @@ struct _LauncherDialog
**/
static void launcher_dialog_g_list_swap (GList *li_a,
GList *li_b);
-static gboolean launcher_dialog_read_desktop_file (const gchar *file,
- LauncherEntry *entry);
static void launcher_dialog_tree_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
gint x,
@@ -147,7 +145,7 @@ launcher_dialog_g_list_swap (GList *li_a,
}
-static gboolean
+gboolean
launcher_dialog_read_desktop_file (const gchar *path,
LauncherEntry *entry)
{
diff --git a/plugins/launcher/launcher-dialog.h b/plugins/launcher/launcher-dialog.h
index e8f07dd..742a167 100644
--- a/plugins/launcher/launcher-dialog.h
+++ b/plugins/launcher/launcher-dialog.h
@@ -21,6 +21,8 @@
#ifndef __XFCE_PANEL_LAUNCHER_DIALOG_H__
#define __XFCE_PANEL_LAUNCHER_DIALOG_H__
+gboolean launcher_dialog_read_desktop_file (const gchar *path, LauncherEntry *entry) G_GNUC_INTERNAL;
+
void launcher_dialog_show (LauncherPlugin *launcher) G_GNUC_INTERNAL;
#endif /* !__XFCE_PANEL_LAUNCHER_DIALOG_H__ */
diff --git a/plugins/launcher/launcher.c b/plugins/launcher/launcher.c
index ab472a8..ec79dd7 100644
--- a/plugins/launcher/launcher.c
+++ b/plugins/launcher/launcher.c
@@ -616,7 +616,7 @@ launcher_menu_popup (gpointer user_data)
/* popup menu */
gtk_menu_popup (GTK_MENU (launcher->menu), NULL, NULL,
xfce_panel_plugin_position_menu,
- launcher->panel_plugin,
+ launcher->panel_plugin,
1, gtk_get_current_event_time ());
GDK_THREADS_LEAVE ();
@@ -878,9 +878,36 @@ launcher_plugin_new (XfcePanelPlugin *plugin)
/* read the user settings */
launcher_plugin_read (launcher);
- /* add new entry if the list is empty */
+ /* create new launcher */
if (G_UNLIKELY (g_list_length (launcher->entries) == 0))
- launcher->entries = g_list_prepend (launcher->entries, launcher_entry_new ());
+ {
+ gchar **filenames;
+ guint i;
+ LauncherEntry *entry;
+
+ /* check for startup arguments */
+ if (xfce_panel_plugin_get_arguments (plugin, &filenames))
+ {
+ /* try to add the entries to the new launcher */
+ for (i = 0; filenames[i] != NULL; i++)
+ {
+ /* create new entry */
+ entry = launcher_entry_new ();
+
+ if (launcher_dialog_read_desktop_file (filenames[i], entry))
+ launcher->entries = g_list_append (launcher->entries, entry);
+ else
+ launcher_entry_free (entry, NULL);
+ }
+
+ /* cleanup */
+ g_strfreev (filenames);
+ }
+
+ /* add new entry if the list is still empty */
+ if (G_UNLIKELY (g_list_length (launcher->entries) == 0))
+ launcher->entries = g_list_prepend (launcher->entries, launcher_entry_new ());
+ }
/* set the arrow direction */
launcher_plugin_screen_position_changed (launcher);
@@ -1163,7 +1190,7 @@ launcher_plugin_orientation_changed (LauncherPlugin *launcher)
/* reorder the boxes again */
launcher_plugin_pack_buttons (launcher);
-
+
/* update size */
launcher_plugin_set_size (launcher, xfce_panel_plugin_get_size (launcher->panel_plugin));
}
diff --git a/wrapper/main.c b/wrapper/main.c
index fae3542..df61206 100644
--- a/wrapper/main.c
+++ b/wrapper/main.c
@@ -107,7 +107,7 @@ main (gint argc, gchar **argv)
if (g_module_symbol (library, "xfce_panel_plugin_init", (gpointer) &construct_func))
{
/* create the panel plugin */
- provider = (*construct_func) (opt_name, opt_id, NULL, gdk_screen_get_default ());
+ provider = (*construct_func) (opt_name, opt_id, NULL, NULL, gdk_screen_get_default ());
}
else
{
More information about the Xfce4-commits
mailing list