Browse Source

Fix some issues in the remote add plugin code.

Also add a dialog to choose between panels when adding a
remote plugin if there is more then 1 panel.
upstream/xfce4-panel-4.10.1
Nick Schermer 12 years ago
parent
commit
405ff9c0cb
  1. 1
      Panel-desktop-handler.desktop.in.in
  2. 3
      panel/main.c
  3. 26
      panel/panel-application.c
  4. 61
      panel/panel-dialogs.c
  5. 4
      panel/panel-dialogs.h
  6. 12
      panel/panel-module-factory.c
  7. 3
      panel/panel-module-factory.h

1
Panel-desktop-handler.desktop.in.in

@ -7,6 +7,7 @@ TryExec=xfce4-panel
Exec=xfce4-panel --add=launcher %F
Icon=application-x-executable
Terminal=false
Hidden=true
StartupNotify=true
Type=Application
MimeType=application/x-desktop;

3
panel/main.c

@ -141,6 +141,9 @@ main (gint argc, gchar **argv)
}
else if (opt_add)
{
/* stop any running startup notification */
gdk_notify_startup_complete ();
/* send a add new item signal to the running instance */
result = panel_dbus_client_add_new_item (opt_add, arguments, &error);

26
panel/panel-application.c

@ -38,6 +38,7 @@
#include <panel/panel-module-factory.h>
#include <panel/panel-preferences-dialog.h>
#include <panel/panel-item-dialog.h>
#include <panel/panel-dialogs.h>
#include <panel/panel-glue.h>
#define PANEL_CONFIG_PATH "xfce4" G_DIR_SEPARATOR_S "panel" G_DIR_SEPARATOR_S "panels.new.xml"
@ -823,16 +824,31 @@ panel_application_add_new_item (PanelApplication *application,
gchar **arguments)
{
PanelWindow *window;
gint nth = 0;
panel_return_if_fail (PANEL_IS_APPLICATION (application));
panel_return_if_fail (plugin_name != NULL);
panel_return_if_fail (g_slist_length (application->windows) > 0);
/* TODO fix this */
window = application->windows->data;
if (panel_module_factory_has_plugin (application->factory, plugin_name))
{
/* ask the user what panel to use if there is more then one */
if (g_slist_length (application->windows) > 1)
if ((nth = panel_dialogs_choose_panel (application->windows)) == -1)
return;
/* get the window */
window = g_slist_nth_data (application->windows, nth);
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);
/* add the panel to the end of the choosen window */
panel_application_insert_plugin (application, window, gtk_widget_get_screen (GTK_WIDGET (window)),
plugin_name, NULL, arguments, FROM_DESKTOP_FILE, -1);
}
else
{
/* print warning */
g_warning (_("The plugin (%s) you want to add is not recognized by the panel."), plugin_name);
}
}

61
panel/panel-dialogs.c

@ -25,6 +25,7 @@
#include <exo/exo.h>
#include <libxfce4util/libxfce4util.h>
#include <libxfce4panel/libxfce4panel.h>
#include <panel/panel-private.h>
#include <panel/panel-dialogs.h>
@ -62,3 +63,63 @@ panel_dialogs_show_about (void)
"logo-icon-name", PACKAGE_NAME,
NULL);
}
gint
panel_dialogs_choose_panel (GSList *windows)
{
GtkWidget *dialog;
GtkWidget *vbox;
GtkWidget *label;
GtkWidget *combo;
gint i, response = -1;
gchar *name;
GSList *li;
panel_return_val_if_fail (GTK_IS_WINDOW (windows->data), -1);
/* setup the dialog */
dialog = gtk_dialog_new_with_buttons (_("Add New Item"), GTK_WINDOW (windows->data),
GTK_DIALOG_NO_SEPARATOR,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_ADD, GTK_RESPONSE_OK, NULL);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_ADD);
gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
/* create widgets */
vbox = gtk_vbox_new (FALSE, 6);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), vbox, FALSE, FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
gtk_widget_show (vbox);
label = gtk_label_new (_("Please choose a panel for the new plugin:"));
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
combo = gtk_combo_box_new_text ();
gtk_box_pack_start (GTK_BOX (vbox), combo, FALSE, FALSE, 0);
gtk_widget_show (combo);
/* insert the panels */
for (li = windows, i = 1; li != NULL; li = li->next, i++)
{
/* add panel name to the combo box */
name = g_strdup_printf (_("Panel %d"), i);
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), name);
g_free (name);
}
/* select first panel */
gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
/* run the dialog */
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
response = gtk_combo_box_get_active (GTK_COMBO_BOX (combo));
/* destroy the dialog */
gtk_widget_destroy (dialog);
return response;
}

4
panel/panel-dialogs.h

@ -22,7 +22,9 @@
G_BEGIN_DECLS
void panel_dialogs_show_about (void);
void panel_dialogs_show_about (void);
gint panel_dialogs_choose_panel (GSList *windows);
G_END_DECLS

12
panel/panel-module-factory.c

@ -342,6 +342,18 @@ panel_module_factory_get_modules (PanelModuleFactory *factory)
gboolean
panel_module_factory_has_plugin (PanelModuleFactory *factory,
const gchar *name)
{
panel_return_val_if_fail (PANEL_IS_MODULE_FACTORY (factory), FALSE);
panel_return_val_if_fail (name != NULL, FALSE);
return !!(g_hash_table_lookup (factory->modules, name) != NULL);
}
XfcePanelPluginProvider *
panel_module_factory_create_plugin (PanelModuleFactory *factory,
GdkScreen *screen,

3
panel/panel-module-factory.h

@ -47,6 +47,9 @@ void panel_module_factory_emit_unique_changed (PanelModule
GList *panel_module_factory_get_modules (PanelModuleFactory *factory);
gboolean panel_module_factory_has_plugin (PanelModuleFactory *factory,
const gchar *name);
XfcePanelPluginProvider *panel_module_factory_create_plugin (PanelModuleFactory *factory,
GdkScreen *screen,
const gchar *name,

Loading…
Cancel
Save