[Xfce4-commits] <xfce4-panel:devel> * Remove struts point the the TODO list. Structs are per-window, so we can't make then application wide, tho there is some room for improvement. * Add a changed property to the itembar and update the preferences dialog store when the itembar changes.
Nick Schermer
nick at xfce.org
Tue Aug 11 20:26:23 CEST 2009
Updating branch refs/heads/devel
to 18e547a4faec5ef6a076b2895d5735f07dee3683 (commit)
from 5dd9ca60e2eb7bd7237683b63063d81be924dd3f (commit)
commit 18e547a4faec5ef6a076b2895d5735f07dee3683
Author: Nick Schermer <nick at xfce.org>
Date: Wed Dec 10 21:16:47 2008 +0100
* Remove struts point the the TODO list. Structs are per-window,
so we can't make then application wide, tho there is some room
for improvement.
* Add a changed property to the itembar and update the preferences
dialog store when the itembar changes.
TODO | 1 -
panel/panel-application.c | 15 ++++++++----
panel/panel-itembar.c | 43 +++++++++++++++++++++++++++++++++++++-
panel/panel-preferences-dialog.c | 39 ++++++++++++++++++++++++++++------
panel/panel-window.c | 17 +++++---------
5 files changed, 90 insertions(+), 25 deletions(-)
diff --git a/TODO b/TODO
index 28f9861..ade1dda 100644
--- a/TODO
+++ b/TODO
@@ -17,7 +17,6 @@ Libxfce4panel
Panel
-----
- Stack panels on screen edges.
- - Make struts application wide, ie. set 1 strut for each screen.
- Support for remote plugins.
Plugins
diff --git a/panel/panel-application.c b/panel/panel-application.c
index e5df4d6..7e5e103 100644
--- a/panel/panel-application.c
+++ b/panel/panel-application.c
@@ -83,6 +83,11 @@ static gboolean panel_application_drag_drop (GtkWidget *i
PanelWindow *window);
+enum
+{
+ PROP_0,
+ PROP_ITEMS_CHANGED
+};
struct _PanelApplicationClass
{
@@ -296,15 +301,15 @@ panel_application_load (PanelApplication *application)
static void
-panel_application_plugin_move_end (GtkWidget *item,
- GdkDragContext *context,
- PanelApplication *application)
+panel_application_plugin_move_drag_end (GtkWidget *item,
+ GdkDragContext *context,
+ PanelApplication *application)
{
panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (item));
panel_return_if_fail (PANEL_IS_APPLICATION (application));
/* disconnect this signal */
- g_signal_handlers_disconnect_by_func (G_OBJECT (item), G_CALLBACK (panel_application_plugin_move_end), application);
+ g_signal_handlers_disconnect_by_func (G_OBJECT (item), G_CALLBACK (panel_application_plugin_move_drag_end), application);
/* make the window insensitive */
panel_application_windows_sensitive (application, TRUE);
@@ -342,7 +347,7 @@ panel_application_plugin_move (GtkWidget *item,
gtk_target_list_unref (target_list);
/* signal to make the window sensitive again on a drag end */
- g_signal_connect (G_OBJECT (item), "drag-end", G_CALLBACK (panel_application_plugin_move_end), application);
+ g_signal_connect (G_OBJECT (item), "drag-end", G_CALLBACK (panel_application_plugin_move_drag_end), application);
}
diff --git a/panel/panel-itembar.c b/panel/panel-itembar.c
index ce6c89f..35238b1 100644
--- a/panel/panel-itembar.c
+++ b/panel/panel-itembar.c
@@ -40,6 +40,10 @@ static void panel_itembar_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
+static void panel_itembar_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
static void panel_itembar_finalize (GObject *object);
static void panel_itembar_realize (GtkWidget *widget);
static void panel_itembar_unrealize (GtkWidget *widget);
@@ -105,7 +109,8 @@ struct _PanelItembarChild
enum
{
PROP_0,
- PROP_HORIZONTAL
+ PROP_HORIZONTAL,
+ PROP_CHANGED
};
@@ -132,6 +137,7 @@ panel_itembar_class_init (PanelItembarClass *klass)
gobject_class = G_OBJECT_CLASS (klass);
gobject_class->set_property = panel_itembar_set_property;
+ gobject_class->get_property = panel_itembar_get_property;
gobject_class->finalize = panel_itembar_finalize;
gtkwidget_class = GTK_WIDGET_CLASS (klass);
@@ -158,6 +164,12 @@ panel_itembar_class_init (PanelItembarClass *klass)
g_param_spec_boolean ("horizontal", NULL, NULL,
TRUE,
EXO_PARAM_WRITABLE));
+
+ g_object_class_install_property (gobject_class,
+ PROP_CHANGED,
+ g_param_spec_boolean ("changed", NULL, NULL,
+ FALSE,
+ EXO_PARAM_READABLE));
}
@@ -210,6 +222,26 @@ panel_itembar_set_property (GObject *object,
static void
+panel_itembar_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (prop_id)
+ {
+ case PROP_CHANGED:
+ g_value_set_boolean (value, TRUE);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+
+
+static void
panel_itembar_finalize (GObject *object)
{
panel_return_if_fail (PANEL_ITEMBAR (object)->children == NULL);
@@ -661,6 +693,9 @@ panel_itembar_remove (GtkContainer *container,
/* queue a resize if needed */
if (G_LIKELY (was_visible))
gtk_widget_queue_resize (GTK_WIDGET (container));
+
+ /* tell the consumers that we have changed the items */
+ g_object_notify (G_OBJECT (itembar), "changed");
/* done */
break;
@@ -773,6 +808,9 @@ panel_itembar_insert (PanelItembar *itembar,
/* resize the itembar */
gtk_widget_queue_resize (GTK_WIDGET (itembar));
+
+ /* tell the consumers that we have changed the items */
+ g_object_notify (G_OBJECT (itembar), "changed");
}
@@ -804,6 +842,9 @@ panel_itembar_reorder_child (PanelItembar *itembar,
/* reallocate the itembar */
gtk_widget_queue_resize (GTK_WIDGET (itembar));
+
+ /* tell the consumers that we have changed the items */
+ g_object_notify (G_OBJECT (itembar), "changed");
/* we're done */
break;
diff --git a/panel/panel-preferences-dialog.c b/panel/panel-preferences-dialog.c
index 5998954..41e7b39 100644
--- a/panel/panel-preferences-dialog.c
+++ b/panel/panel-preferences-dialog.c
@@ -97,6 +97,8 @@ struct _PanelPreferencesDialog
/* store for the items list */
GtkListStore *store;
+
+ gulong changed_handler_id;
};
@@ -215,6 +217,14 @@ static void
panel_preferences_dialog_finalize (GObject *object)
{
PanelPreferencesDialog *dialog = PANEL_PREFERENCES_DIALOG (object);
+ GtkWidget *itembar;
+
+ /* disconnect changed signal */
+ if (dialog->changed_handler_id != 0)
+ {
+ itembar = gtk_bin_get_child (GTK_BIN (dialog->active));
+ g_signal_handler_disconnect (G_OBJECT (itembar), dialog->changed_handler_id);
+ }
/* thaw all autohide blocks */
panel_application_windows_autohide (dialog->application, FALSE);
@@ -316,14 +326,28 @@ static void
panel_preferences_dialog_panel_combobox_changed (GtkComboBox *combobox,
PanelPreferencesDialog *dialog)
{
- gint nth;
+ gint nth;
+ GtkWidget *itembar;
panel_return_if_fail (GTK_IS_COMBO_BOX (combobox));
panel_return_if_fail (PANEL_IS_PREFERENCES_DIALOG (dialog));
+
+ /* disconnect signal we used to monitor changes in the itembar */
+ if (dialog->changed_handler_id != 0)
+ {
+ itembar = gtk_bin_get_child (GTK_BIN (dialog->active));
+ g_signal_handler_disconnect (G_OBJECT (itembar), dialog->changed_handler_id);
+ }
/* set the selected window */
nth = gtk_combo_box_get_active (combobox);
dialog->active = panel_application_get_window (dialog->application, nth);
+
+
+ itembar = gtk_bin_get_child (GTK_BIN (dialog->active));
+ dialog->changed_handler_id = g_signal_connect_swapped (G_OBJECT (itembar), "notify::changed",
+ G_CALLBACK (panel_preferences_dialog_item_store_rebuild),
+ dialog);
/* rebind the dialog bindings */
panel_preferences_dialog_bindings_update (dialog);
@@ -543,11 +567,16 @@ panel_preferences_dialog_item_move (GtkWidget *button,
if (G_LIKELY (position != -1))
{
+ /* block the changed signal */
+ g_signal_handler_block (G_OBJECT (itembar), dialog->changed_handler_id);
+
/* move the item on the panel */
panel_itembar_reorder_child (PANEL_ITEMBAR (itembar),
GTK_WIDGET (provider),
position + direction);
+ /* unblock the changed signal */
+ g_signal_handler_unblock (G_OBJECT (itembar), dialog->changed_handler_id);
/* most the item up or down in the list */
if (direction == 1)
@@ -591,14 +620,13 @@ panel_preferences_dialog_item_remove (GtkWidget *button,
PanelPreferencesDialog *dialog)
{
XfcePanelPluginProvider *provider;
- GtkTreeIter iter;
GtkWidget *widget, *toplevel;
PanelModule *module;
panel_return_if_fail (PANEL_IS_PREFERENCES_DIALOG (dialog));
/* get the selected item in the treeview */
- provider = panel_preferences_dialog_item_get_selected (dialog, &iter);
+ provider = panel_preferences_dialog_item_get_selected (dialog, NULL);
if (G_LIKELY (provider != NULL))
{
/* get the panel module of the provider */
@@ -617,12 +645,9 @@ panel_preferences_dialog_item_remove (GtkWidget *button,
{
/* hide the dialog */
gtk_widget_hide (widget);
-
+
/* send signal */
xfce_panel_plugin_provider_emit_signal (provider, PROVIDER_SIGNAL_REMOVE_PLUGIN);
-
- /* remove from treeview */
- gtk_list_store_remove (dialog->store, &iter);
}
/* destroy */
diff --git a/panel/panel-window.c b/panel/panel-window.c
index 15f0ee9..cdfec36 100644
--- a/panel/panel-window.c
+++ b/panel/panel-window.c
@@ -238,12 +238,6 @@ panel_window_class_init (PanelWindowClass *klass)
gtkwidget_class->size_allocate = panel_window_size_allocate;
gtkwidget_class->screen_changed = panel_window_screen_changed;
- /**
- * PanelWindow::orientation:
- *
- * The orientation of the panel window. This is used to sync the
- * panel orientation with that of the itembar, using exo bindings.
- **/
g_object_class_install_property (gobject_class,
PROP_HORIZONTAL,
g_param_spec_boolean ("horizontal", NULL, NULL,
@@ -1698,6 +1692,8 @@ panel_window_struts_update (PanelWindow *window,
panel_return_if_fail (GDK_IS_WINDOW (GTK_WIDGET (window)->window));
panel_return_if_fail (N_STRUTS == 12);
panel_return_if_fail (cardinal_atom != GDK_NONE);
+ panel_return_if_fail (net_wm_strut_atom != GDK_NONE);
+ panel_return_if_fail (net_wm_strut_partial_atom != GDK_NONE);
if (G_UNLIKELY (window->struts_possible == -1))
{
@@ -1720,8 +1716,6 @@ panel_window_struts_update (PanelWindow *window,
struts[STRUT_TOP] = y + height;
struts[STRUT_TOP_START_X] = x;
struts[STRUT_TOP_END_X] = x + width;
-
-
}
else if (snap_edge_is_bottom (window->snap_edge))
{
@@ -1770,9 +1764,10 @@ panel_window_struts_update (PanelWindow *window,
gdk_property_change (GTK_WIDGET (window)->window, net_wm_strut_partial_atom,
cardinal_atom, 32, GDK_PROP_MODE_REPLACE, (guchar *) &struts, 12);
- /* set the wm strut */
- gdk_property_change (GTK_WIDGET (window)->window, net_wm_strut_atom,
- cardinal_atom, 32, GDK_PROP_MODE_REPLACE, (guchar *) &struts, 4);
+ /* set the wm strut (old window managers) */
+ /* gdk_property_change (GTK_WIDGET (window)->window, net_wm_strut_atom,
+ * cardinal_atom, 32, GDK_PROP_MODE_REPLACE, (guchar *) &struts, 4);
+ */
/* release the trap push */
gdk_error_trap_pop ();
More information about the Xfce4-commits
mailing list