Browse Source

* Another alternative for the panel customization dialogs

* Add 'Move' menu item for plugins
 * Block autohide now also blocks transparency
Please test.


(Old svn revision: 19067)
upstream/xfce4-panel-4.10.1
Jasper Huijsmans 18 years ago
parent
commit
037d96f4a8
  1. 3
      libxfce4panel/xfce-panel-external-item.c
  2. 15
      libxfce4panel/xfce-panel-external-plugin.c
  3. 8
      libxfce4panel/xfce-panel-internal-plugin.c
  4. 31
      libxfce4panel/xfce-panel-item-iface.c
  5. 2
      libxfce4panel/xfce-panel-item-iface.h
  6. 4
      libxfce4panel/xfce-panel-plugin-iface-private.h
  7. 48
      libxfce4panel/xfce-panel-plugin-iface.c
  8. 3
      libxfce4panel/xfce-panel-plugin-messages.h
  9. 2
      panel/Makefile.am
  10. 12
      panel/panel-app.c
  11. 3
      panel/panel-app.h
  12. 1856
      panel/panel-dialogs.c
  13. 32
      panel/panel-dialogs.h
  14. 13
      panel/panel-dnd.c
  15. 2
      panel/panel-dnd.h
  16. 4
      panel/panel-manager.c
  17. 2
      panel/panel-private.h
  18. 29
      panel/panel-properties.c
  19. 90
      panel/panel.c

3
libxfce4panel/xfce-panel-external-item.c

@ -381,6 +381,9 @@ _item_event_received (XfceExternalPanelItem * item, GdkEventClient * ev)
case XFCE_PANEL_PLUGIN_CUSTOMIZE_ITEMS:
xfce_panel_item_customize_items (XFCE_PANEL_ITEM (item));
break;
case XFCE_PANEL_PLUGIN_MOVE:
xfce_panel_item_move (XFCE_PANEL_ITEM (item));
break;
case XFCE_PANEL_PLUGIN_MENU_DEACTIVATED:
xfce_panel_item_menu_deactivated (XFCE_PANEL_ITEM (item));
break;

15
libxfce4panel/xfce-panel-external-plugin.c

@ -109,6 +109,8 @@ xfce_external_panel_plugin_customize_panel (XfcePanelPlugin * plugin);
static void
xfce_external_panel_plugin_customize_items (XfcePanelPlugin * plugin);
static void xfce_external_panel_plugin_move (XfcePanelPlugin * plugin);
/* properties */
static void xfce_external_panel_plugin_set_name (XfceExternalPanelPlugin *
@ -164,6 +166,7 @@ xfce_external_panel_plugin_interface_init (gpointer g_iface, gpointer data)
iface->set_expand = xfce_external_panel_plugin_set_expand;
iface->customize_panel = xfce_external_panel_plugin_customize_panel;
iface->customize_items = xfce_external_panel_plugin_customize_items;
iface->move = xfce_external_panel_plugin_move;
}
static void
@ -374,6 +377,18 @@ xfce_external_panel_plugin_customize_items (XfcePanelPlugin * plugin)
XFCE_PANEL_PLUGIN_CUSTOMIZE_ITEMS, 0);
}
static void
xfce_external_panel_plugin_move (XfcePanelPlugin * plugin)
{
XfceExternalPanelPluginPrivate *priv;
priv = XFCE_EXTERNAL_PANEL_PLUGIN_GET_PRIVATE (plugin);
xfce_panel_plugin_message_send (GTK_WIDGET (plugin)->window,
priv->socket_id,
XFCE_PANEL_PLUGIN_MOVE, 0);
}
/* item/plugin interaction */
static void

8
libxfce4panel/xfce-panel-internal-plugin.c

@ -114,6 +114,8 @@ static void xfce_internal_panel_plugin_customize_panel (XfcePanelPlugin *
static void xfce_internal_panel_plugin_customize_items (XfcePanelPlugin *
plugin);
static void xfce_internal_panel_plugin_move (XfcePanelPlugin * plugin);
/* properties */
static void xfce_internal_panel_plugin_set_name (XfcePanelPlugin * plugin,
@ -183,6 +185,7 @@ xfce_internal_panel_plugin_init_plugin_interface (gpointer g_iface,
iface->set_expand = xfce_internal_panel_plugin_set_expand;
iface->customize_panel = xfce_internal_panel_plugin_customize_panel;
iface->customize_items = xfce_internal_panel_plugin_customize_items;
iface->move = xfce_internal_panel_plugin_move;
}
static void
@ -516,6 +519,11 @@ xfce_internal_panel_plugin_customize_items (XfcePanelPlugin * plugin)
xfce_panel_item_customize_items (XFCE_PANEL_ITEM (plugin));
}
static void xfce_internal_panel_plugin_move (XfcePanelPlugin * plugin)
{
xfce_panel_item_move (XFCE_PANEL_ITEM (plugin));
}
/* properties */
static void

31
libxfce4panel/xfce-panel-item-iface.c

@ -31,6 +31,7 @@ enum
MENU_DEACTIVATED,
CUSTOMIZE_PANEL,
CUSTOMIZE_ITEMS,
MOVE,
LAST_SIGNAL
};
@ -113,6 +114,21 @@ xfce_panel_item_base_init (gpointer g_class)
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0, NULL);
/**
* XfcePanelItem::move
* @item : #XfcePanelItem
*
* The signal is emitted when a plugin requests the item to be moved.
**/
xfce_panel_item_signals [MOVE] =
g_signal_newv ("move",
XFCE_TYPE_PANEL_ITEM,
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE |
G_SIGNAL_NO_HOOKS,
NULL, NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0, NULL);
initialized = TRUE;
}
}
@ -208,6 +224,21 @@ xfce_panel_item_customize_items (XfcePanelItem *item)
g_signal_emit (item, xfce_panel_item_signals[CUSTOMIZE_ITEMS], 0, NULL);
}
/**
* xfce_panel_item_move
* @item : #XfcePanelItem
*
* Emits the "move" signal on the item. Should only be called by
* item implementations.
**/
void
xfce_panel_item_move (XfcePanelItem *item)
{
g_return_if_fail (XFCE_IS_PANEL_ITEM (item));
g_signal_emit (item, xfce_panel_item_signals[MOVE], 0, NULL);
}
/* properties */
/**

2
libxfce4panel/xfce-panel-item-iface.h

@ -81,6 +81,8 @@ void xfce_panel_item_customize_panel (XfcePanelItem *item);
void xfce_panel_item_customize_items (XfcePanelItem *item);
void xfce_panel_item_move (XfcePanelItem *item);
/* vtable */

4
libxfce4panel/xfce-panel-plugin-iface-private.h

@ -39,6 +39,8 @@ struct _XfcePanelPluginInterface
void (*customize_panel) (XfcePanelPlugin *plugin);
void (*customize_items) (XfcePanelPlugin *plugin);
void (*move) (XfcePanelPlugin *plugin);
};
/* menu */
@ -76,6 +78,8 @@ void xfce_panel_plugin_customize_panel (XfcePanelPlugin *plugin);
void xfce_panel_plugin_customize_items (XfcePanelPlugin *plugin);
void xfce_panel_plugin_move (XfcePanelPlugin *plugin);
G_END_DECLS

48
libxfce4panel/xfce-panel-plugin-iface.c

@ -645,7 +645,19 @@ xfce_panel_plugin_customize_panel (XfcePanelPlugin *plugin)
void
xfce_panel_plugin_customize_items (XfcePanelPlugin *plugin)
{
return XFCE_PANEL_PLUGIN_GET_INTERFACE (plugin)->customize_items (plugin);
XFCE_PANEL_PLUGIN_GET_INTERFACE (plugin)->customize_items (plugin);
}
/**
* xfce_panel_plugin_move
* @plugin : an #XfcePanelPlugin
*
* Ask the panel to start a move operation.
**/
void
xfce_panel_plugin_move (XfcePanelPlugin *plugin)
{
XFCE_PANEL_PLUGIN_GET_INTERFACE (plugin)->move (plugin);
}
/* menu */
@ -752,7 +764,24 @@ xfce_panel_plugin_create_menu (XfcePanelPlugin *plugin,
g_object_set_data (G_OBJECT (plugin), "xfce-panel-plugin-insert-position",
GINT_TO_POINTER (insert_position));
#if 0
/* move / remove */
mi = gtk_image_menu_item_new_with_label (_("Move"));
gtk_widget_show (mi);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
img = gtk_image_new_from_stock (GTK_STOCK_GO_FORWARD, GTK_ICON_SIZE_MENU);
gtk_widget_show (img);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), img);
g_signal_connect_swapped (mi, "activate",
G_CALLBACK (xfce_panel_plugin_move),
plugin);
mi = gtk_separator_menu_item_new();
gtk_widget_show (mi);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
mi = gtk_image_menu_item_new_with_label (_("Remove"));
gtk_widget_show (mi);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
@ -764,13 +793,24 @@ xfce_panel_plugin_create_menu (XfcePanelPlugin *plugin,
g_signal_connect_swapped (mi, "activate",
G_CALLBACK (xfce_panel_plugin_remove_confirm),
plugin);
#endif
/* panel section */
mi = gtk_separator_menu_item_new();
gtk_widget_show (mi);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
mi = gtk_image_menu_item_new_with_label (_("Add New Item"));
gtk_widget_show (mi);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
img = gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_MENU);
gtk_widget_show (img);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), img);
g_signal_connect_swapped (mi, "activate",
G_CALLBACK (xfce_panel_plugin_customize_items),
plugin);
mi = gtk_image_menu_item_new_with_label (_("Customize Panel"));
gtk_widget_show (mi);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
@ -780,7 +820,7 @@ xfce_panel_plugin_create_menu (XfcePanelPlugin *plugin,
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), img);
g_signal_connect_swapped (mi, "activate",
G_CALLBACK (xfce_panel_plugin_customize_items),
G_CALLBACK (xfce_panel_plugin_customize_panel),
plugin);
/* deactivation */

3
libxfce4panel/xfce-panel-plugin-messages.h

@ -41,7 +41,8 @@ typedef enum
XFCE_PANEL_PLUGIN_MENU_DEACTIVATED,
XFCE_PANEL_PLUGIN_POPUP_MENU,
XFCE_PANEL_PLUGIN_CUSTOMIZE_ITEMS,
XFCE_PANEL_PLUGIN_SENSITIVE
XFCE_PANEL_PLUGIN_SENSITIVE,
XFCE_PANEL_PLUGIN_MOVE
}
XfcePanelPluginMessage;

2
panel/Makefile.am

@ -18,6 +18,8 @@ xfce4_panel_SOURCES = \
panel-settings.h \
panel-manager.c \
panel-manager.h \
panel-dialogs.c \
panel-dialogs.h \
panel.c \
panel-private.h \
panel.h

12
panel/panel-app.c

@ -37,6 +37,7 @@
#include "panel-properties.h"
#include "panel-settings.h"
#include "panel-manager.h"
#include "panel-dialogs.h"
#include "panel.h"
#ifndef _
@ -519,13 +520,13 @@ panel_app_queue_save (void)
void
panel_app_customize (void)
{
panel_manager_dialog (panel_app.panel_list, FALSE);
panel_dialog (panel_app.panel_list, FALSE);
}
void
panel_app_customize_items (void)
{
panel_manager_dialog (panel_app.panel_list, TRUE);
panel_dialog (panel_app.panel_list, TRUE);
}
void
@ -759,3 +760,10 @@ panel_app_get_current_panel (void)
return panel_app.current_panel;
}
G_CONST_RETURN GPtrArray *
panel_app_get_panel_list (void)
{
return panel_app.panel_list;
}

3
panel/panel-app.h

@ -83,6 +83,9 @@ void panel_app_unset_current_panel (gpointer *panel);
int panel_app_get_current_panel (void);
/* get panel list */
G_CONST_RETURN GPtrArray *panel_app_get_panel_list (void);
G_END_DECLS
#endif /* _PANEL_APP_H */

1856
panel/panel-dialogs.c

File diff suppressed because it is too large

32
panel/panel-dialogs.h

@ -0,0 +1,32 @@
/* vim: set expandtab ts=8 sw=4: */
/* $Id$
*
* Copyright © 2005 Jasper Huijsmans <jasper@xfce.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _PANEL_DIALOGS_H
#define _PANEL_DIALOGS_H
#include "panel.h"
void panel_dialog (GPtrArray *panels, gboolean show_items);
#endif /* _PANEL_DIALOGS_H */

13
panel/panel-dnd.c

@ -33,7 +33,7 @@
* Licensed under the GNU GPL
*/
static GtkTargetEntry dest_target_list[] =
const static GtkTargetEntry dest_target_list[] =
{
{ "application/x-xfce-panel-plugin-name", 0, TARGET_PLUGIN_NAME },
{ "application/x-xfce-panel-plugin-widget",
@ -126,3 +126,14 @@ panel_dnd_set_widget_data (GtkSelectionData *data, GtkWidget *widget)
gtk_selection_data_set (data, data->target, 32, (guchar *) &n, sizeof (n));
}
void
panel_dnd_begin_drag (GtkWidget *widget)
{
static GtkTargetList *list = NULL;
if (G_UNLIKELY (list == NULL))
list = gtk_target_list_new (widget_target_list, n_widget_targets);
gtk_drag_begin (widget, list, GDK_ACTION_COPY, 1, NULL);
}

2
panel/panel-dnd.h

@ -48,5 +48,7 @@ void panel_dnd_unset_source (GtkWidget *widget);
void panel_dnd_set_widget_data (GtkSelectionData *data, GtkWidget *plugin);
void panel_dnd_begin_drag (GtkWidget *widget);
#endif /* _PANEL_DND_H */

4
panel/panel-manager.c

@ -1988,6 +1988,8 @@ dialog_opened (Panel *panel)
panel_dnd_set_widget_source (priv->itembar);
panel_set_items_sensitive (panel, FALSE);
priv->edit_mode = TRUE;
}
static void
@ -2003,6 +2005,8 @@ dialog_closed (Panel *panel)
panel_dnd_unset_dest (priv->itembar);
panel_dnd_unset_source (priv->itembar);
priv->edit_mode = FALSE;
}
static void

2
panel/panel-private.h

@ -63,6 +63,8 @@ struct _PanelPrivate
int unhide_timeout;
GtkWidget *drag_widget;
gboolean edit_mode;
};
#endif /* _PANEL_PRIVATE_H */

29
panel/panel-properties.c

@ -530,10 +530,13 @@ panel_enter (Panel *panel, GdkEventCrossing * event)
{
panel_app_set_current_panel ((gpointer)panel);
_set_transparent (panel, FALSE);
priv = PANEL_GET_PRIVATE (panel);
if (priv->block_autohide)
return;
_set_transparent (panel, FALSE);
if (!priv->autohide)
return;
@ -558,11 +561,14 @@ panel_leave (Panel *panel, GdkEventCrossing * event)
if (event->detail != GDK_NOTIFY_INFERIOR)
{
_set_transparent (panel, TRUE);
priv = PANEL_GET_PRIVATE (panel);
if (!priv->autohide || priv->block_autohide)
if (priv->block_autohide)
return;
_set_transparent (panel, TRUE);
if (!priv->autohide)
return;
if (priv->unhide_timeout)
@ -703,7 +709,7 @@ void panel_set_autohide (Panel *panel, gboolean autohide)
_set_hidden (panel, TRUE);
/* If autohide is blocked unhide again.
* We use the firt _set_hidden() call to give the user
* We use the first _set_hidden() call to give the user
* some visual feedback. */
if (priv->block_autohide)
{
@ -744,10 +750,13 @@ void panel_unblock_autohide (Panel *panel)
{
priv->block_autohide--;
if (!priv->block_autohide && priv->autohide && !priv->hidden)
_set_hidden (panel, TRUE);
_set_transparent (panel, TRUE);
if (!priv->block_autohide)
{
if (priv->autohide && !priv->hidden)
_set_hidden (panel, TRUE);
_set_transparent (panel, TRUE);
}
}
}

90
panel/panel.c

@ -432,30 +432,39 @@ _panel_drag_begin (GtkWidget *widget, GdkDragContext *drag_context,
int x, y, rootx, rooty, w, h;
GtkWidget *plugin;
GdkPixbuf *pb;
PanelPrivate *priv = PANEL_GET_PRIVATE (panel);
DBG (" + drag begin");
x = y = 0;
gdk_display_get_pointer (gtk_widget_get_display (widget),
NULL, &x, &y, NULL);
gdk_window_get_root_origin (widget->window, &rootx, &rooty);
x -= rootx;
y -= rooty;
plugin = xfce_itembar_get_item_at_point (XFCE_ITEMBAR (widget), x, y);
if (priv->drag_widget)
{
plugin = priv->drag_widget;
}
else
{
x = y = 0;
gdk_display_get_pointer (gtk_widget_get_display (widget),
NULL, &x, &y, NULL);
gdk_window_get_root_origin (widget->window, &rootx, &rooty);
x -= rootx;
y -= rooty;
plugin = xfce_itembar_get_item_at_point (XFCE_ITEMBAR (widget), x, y);
}
if (plugin)
{
PanelPrivate *priv = PANEL_GET_PRIVATE (panel);
GdkDrawable *d = GDK_DRAWABLE (plugin->window);
gdk_drawable_get_size (d, &w, &h);
pb = gdk_pixbuf_get_from_drawable (NULL, d, NULL, 0, 0, 0, 0, w, h);
gtk_drag_source_set_icon_pixbuf (widget, pb);
gtk_drag_set_icon_pixbuf (drag_context, pb, 0, 0);
g_object_unref (pb);
priv->drag_widget = plugin;
}
else
DBG ("No Plugin");
}
static void
@ -465,6 +474,25 @@ _panel_drag_end (GtkWidget *widget, GdkDragContext *drag_context,
PanelPrivate *priv = PANEL_GET_PRIVATE (panel);
priv->drag_widget = NULL;
if (!priv->edit_mode)
{
const GPtrArray *panels = panel_app_get_panel_list ();
int i;
for (i = 0; i < panels->len; ++i)
{
Panel *p = g_ptr_array_index (panels, i);
priv = PANEL_GET_PRIVATE (p);
xfce_itembar_lower_event_window (XFCE_ITEMBAR (priv->itembar));
panel_dnd_unset_dest (priv->itembar);
panel_set_items_sensitive (p, TRUE);
panel_unblock_autohide (p);
}
}
}
static void
@ -541,6 +569,17 @@ _panel_create_menu (Panel *panel)
gtk_widget_show (img);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), img);
g_signal_connect (mi, "activate", G_CALLBACK (panel_app_customize),
NULL);
mi = gtk_image_menu_item_new_with_label (_("Add Items"));
gtk_widget_show (mi);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
img = gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_MENU);
gtk_widget_show (img);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), img);
g_signal_connect (mi, "activate", G_CALLBACK (panel_app_customize_items),
NULL);
@ -671,6 +710,34 @@ _item_expand_changed (GtkWidget *item, gboolean expand, Panel *panel)
xfce_itembar_set_child_expand (XFCE_ITEMBAR (priv->itembar), item, expand);
}
static void
_item_start_move (GtkWidget *item, Panel *panel)
{
const GPtrArray *panels = panel_app_get_panel_list ();
PanelPrivate *priv;
int i;
for (i = 0; i < panels->len; ++i)
{
Panel *p = g_ptr_array_index (panels, i);
priv = PANEL_GET_PRIVATE (p);
panel_set_items_sensitive (p, FALSE);
panel_dnd_set_dest (priv->itembar);
panel_dnd_set_widget_source (priv->itembar);
xfce_itembar_lower_event_window (XFCE_ITEMBAR (priv->itembar));
panel_block_autohide (p);
}
priv = PANEL_GET_PRIVATE (panel);
priv->drag_widget = item;
panel_dnd_begin_drag (priv->itembar);
}
static GtkWidget *
panel_create_item (Panel *panel, const char *name, const char *id)
{
@ -693,6 +760,9 @@ panel_create_item (Panel *panel, const char *name, const char *id)
g_signal_connect (item, "customize-items",
G_CALLBACK (panel_app_customize_items), NULL);
g_signal_connect (item, "move",
G_CALLBACK (_item_start_move), panel);
}
return item;

Loading…
Cancel
Save