[Xfce4-commits] <xfce4-panel:devel> * Previous commit but with all files...
Nick Schermer
nick at xfce.org
Tue Aug 11 20:22:11 CEST 2009
Updating branch refs/heads/devel
to 0409f765d19fdfc5c518f71ea3e6f40e4a103f91 (commit)
from a9178371a3927c015a78bd6b89b62d52fe94c4b0 (commit)
commit 0409f765d19fdfc5c518f71ea3e6f40e4a103f91
Author: Nick Schermer <nick at xfce.org>
Date: Tue Jun 17 21:24:02 2008 +0200
* Previous commit but with all files...
configure.in.in | 7 ++--
libxfce4panel/Makefile.am | 6 +++
panel/panel-application.c | 18 +++++++++-
panel/panel-application.h | 3 ++
panel/panel-dialogs.c | 41 +++++++++++++++++++---
panel/panel-dialogs.h | 3 +-
panel/panel-preferences-dialog.c | 63 +++++++++++++++++++++------------
panel/panel-window.c | 70 ++++++++++++++++++++++++++------------
panel/panel-window.h | 7 +++-
9 files changed, 160 insertions(+), 58 deletions(-)
diff --git a/configure.in.in b/configure.in.in
index ab83630..83337a6 100644
--- a/configure.in.in
+++ b/configure.in.in
@@ -11,9 +11,9 @@ dnl *** Version information ***
dnl ***************************
m4_define([libxfce4panel_verinfo], [3:0:1])
m4_define([xfce4_panel_version_major], [4])
-m4_define([xfce4_panel_version_minor], [5])
-m4_define([xfce4_panel_version_micro], [1])
-m4_define([xfce4_panel_version_nano], [0]) dnl leave this empty to have no nano version
+m4_define([xfce4_panel_version_minor], [7])
+m4_define([xfce4_panel_version_micro], [0])
+m4_define([xfce4_panel_version_nano], []) dnl leave this empty to have no nano version
m4_define([xfce4_panel_version_build], [r at REVISION@])
m4_define([xfce4_panel_version_tag], [svn])
m4_define([xfce4_panel_version], [xfce4_panel_version_major().xfce4_panel_version_minor().xfce4_panel_version_micro()ifelse(xfce4_panel_version_nano(), [], [], [.xfce4_panel_version_nano()])ifelse(xfce4_panel_version_tag(), [svn], [xfce4_panel_version_tag()-xfce4_panel_version_build()], [xfce4_panel_version_tag()])])
@@ -234,6 +234,7 @@ AC_SUBST([PLATFORM_LDFLAGS])
AC_OUTPUT([
Makefile
libxfce4panel/Makefile
+libxfce4panel/libxfce4panel-1.0.pc
panel/Makefile
wrapper/Makefile
plugins/Makefile
diff --git a/libxfce4panel/Makefile.am b/libxfce4panel/Makefile.am
index f17503b..05620c2 100644
--- a/libxfce4panel/Makefile.am
+++ b/libxfce4panel/Makefile.am
@@ -49,4 +49,10 @@ libxfce4panel_la_LIBADD = \
$(GTK_LIBS) \
$(LIBXFCE4UTIL_LIBS)
+#
+# Pkg-config file
+#
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = libxfce4panel-1.0.pc
+
# vi:set ts=8 sw=8 noet ai nocindent syntax=automake:
diff --git a/panel/panel-application.c b/panel/panel-application.c
index b478d7c..519d7dd 100644
--- a/panel/panel-application.c
+++ b/panel/panel-application.c
@@ -834,7 +834,7 @@ panel_application_add_new_item (PanelApplication *application,
{
/* 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)
+ if ((nth = panel_dialogs_choose_panel (application)) == -1)
return;
/* get the window */
@@ -1076,6 +1076,22 @@ panel_application_get_window (PanelApplication *application,
void
+panel_application_window_select (PanelApplication *application,
+ PanelWindow *window)
+{
+ GSList *li;
+
+ panel_return_if_fail (PANEL_IS_APPLICATION (application));
+ panel_return_if_fail (window == NULL || PANEL_IS_WINDOW (window));
+
+ /* update state for all windows */
+ for (li = application->windows; li != NULL; li = li->next)
+ panel_window_set_selected (PANEL_WINDOW (li->data), !!(li->data == window));
+}
+
+
+
+void
panel_application_windows_sensitive (PanelApplication *application,
gboolean sensitive)
{
diff --git a/panel/panel-application.h b/panel/panel-application.h
index 4eceafd..3f9832b 100644
--- a/panel/panel-application.h
+++ b/panel/panel-application.h
@@ -63,6 +63,9 @@ gint panel_application_get_window_index (PanelApplication *applic
PanelWindow *panel_application_get_window (PanelApplication *application,
guint idx);
+void panel_application_window_select (PanelApplication *application,
+ PanelWindow *window);
+
void panel_application_windows_sensitive (PanelApplication *application,
gboolean sensitive);
diff --git a/panel/panel-dialogs.c b/panel/panel-dialogs.c
index b9f93a7..8cffde5 100644
--- a/panel/panel-dialogs.c
+++ b/panel/panel-dialogs.c
@@ -29,6 +29,7 @@
#include <panel/panel-private.h>
#include <panel/panel-dialogs.h>
+#include <panel/panel-application.h>
void
panel_dialogs_show_about (void)
@@ -66,8 +67,33 @@ panel_dialogs_show_about (void)
+static void
+panel_dialogs_choose_panel_combo_changed (GtkComboBox *combo,
+ PanelApplication *application)
+{
+ PanelWindow *window = NULL;
+ gint active;
+
+ panel_return_if_fail (PANEL_IS_APPLICATION (application));
+ panel_return_if_fail (GTK_IS_COMBO_BOX (combo));
+
+ /* get the selected item */
+ active = gtk_combo_box_get_active (combo);
+
+ if (G_LIKELY (active != -1))
+ {
+ /* get the window */
+ window = panel_application_get_window (application, active);
+
+ /* select the window */
+ panel_application_window_select (application, window);
+ }
+}
+
+
+
gint
-panel_dialogs_choose_panel (GSList *windows)
+panel_dialogs_choose_panel (PanelApplication *application)
{
GtkWidget *dialog;
GtkWidget *vbox;
@@ -75,12 +101,11 @@ panel_dialogs_choose_panel (GSList *windows)
GtkWidget *combo;
gint i, response = -1;
gchar *name;
- GSList *li;
- panel_return_val_if_fail (GTK_IS_WINDOW (windows->data), -1);
+ panel_return_val_if_fail (PANEL_IS_APPLICATION (application), -1);
/* setup the dialog */
- dialog = gtk_dialog_new_with_buttons (_("Add New Item"), GTK_WINDOW (windows->data),
+ dialog = gtk_dialog_new_with_buttons (_("Add New Item"), NULL,
GTK_DIALOG_NO_SEPARATOR,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_ADD, GTK_RESPONSE_OK, NULL);
@@ -103,15 +128,16 @@ panel_dialogs_choose_panel (GSList *windows)
gtk_widget_show (combo);
/* insert the panels */
- for (li = windows, i = 1; li != NULL; li = li->next, i++)
+ for (i = 0; i < panel_application_get_n_windows (application); i++)
{
/* add panel name to the combo box */
- name = g_strdup_printf (_("Panel %d"), i);
+ name = g_strdup_printf (_("Panel %d"), i + 1);
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), name);
g_free (name);
}
/* select first panel */
+ g_signal_connect (G_OBJECT (combo), "changed", G_CALLBACK (panel_dialogs_choose_panel_combo_changed), application);
gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
/* run the dialog */
@@ -121,5 +147,8 @@ panel_dialogs_choose_panel (GSList *windows)
/* destroy the dialog */
gtk_widget_destroy (dialog);
+ /* remove the panel selection */
+ panel_application_window_select (application, NULL);
+
return response;
}
diff --git a/panel/panel-dialogs.h b/panel/panel-dialogs.h
index 722de42..53cd278 100644
--- a/panel/panel-dialogs.h
+++ b/panel/panel-dialogs.h
@@ -19,12 +19,13 @@
#define __PANEL_DIALOGS_H__
#include <gtk/gtk.h>
+#include <panel/panel-application.h>
G_BEGIN_DECLS
void panel_dialogs_show_about (void);
-gint panel_dialogs_choose_panel (GSList *windows);
+gint panel_dialogs_choose_panel (PanelApplication *application);
G_END_DECLS
diff --git a/panel/panel-preferences-dialog.c b/panel/panel-preferences-dialog.c
index 5c304e5..6f7ce74 100644
--- a/panel/panel-preferences-dialog.c
+++ b/panel/panel-preferences-dialog.c
@@ -68,6 +68,9 @@ struct _PanelPreferencesDialog
/* panel selector widget */
GtkWidget *selector;
+ /* remove button */
+ GtkWidget *remove_button;
+
/* save timeout id */
guint save_timeout_id;
};
@@ -168,7 +171,7 @@ panel_preferences_dialog_class_init (PanelPreferencesDialogClass *klass)
g_param_spec_int ("leave-opacity", "leave-opacity", "leave-opacity",
0, 100, 0,
EXO_PARAM_READWRITE));
-
+
g_object_class_install_property (gobject_class,
PROP_SPAN_MONITORS,
g_param_spec_boolean ("span-monitors", "span-monitors", "span-monitors",
@@ -246,11 +249,12 @@ panel_preferences_dialog_init (PanelPreferencesDialog *dialog)
g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (panel_preferences_dialog_add_window), dialog);
gtk_widget_show (button);
- button = gtk_button_new ();
+ button = dialog->remove_button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
image = gtk_image_new_from_stock (GTK_STOCK_REMOVE, GTK_ICON_SIZE_BUTTON);
gtk_button_set_image (GTK_BUTTON (button), image);
g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (panel_preferences_dialog_remove_window), dialog);
+ gtk_widget_set_sensitive (button, panel_application_get_n_windows (dialog->application) > 1);
gtk_widget_show (button);
notebook = gtk_notebook_new ();
@@ -453,7 +457,7 @@ panel_preferences_dialog_init (PanelPreferencesDialog *dialog)
gtk_widget_show (scale);
g_object_unref (G_OBJECT (sg));
-
+
/* multi screen tab */
notebook_vbox = gtk_vbox_new (FALSE, BORDER);
gtk_container_set_border_width (GTK_CONTAINER (notebook_vbox), BORDER);
@@ -461,7 +465,7 @@ panel_preferences_dialog_init (PanelPreferencesDialog *dialog)
label = gtk_label_new (_("Multi Screen"));
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), notebook_vbox, label);
-
+
button = gtk_check_button_new_with_mnemonic (_("Span Monitors"));
gtk_box_pack_start (GTK_BOX (notebook_vbox), button, FALSE, FALSE, 0);
exo_mutual_binding_new (G_OBJECT (dialog), "span-monitors", G_OBJECT (button), "active");
@@ -526,7 +530,7 @@ panel_preferences_dialog_get_property (GObject *object,
case PROP_LEAVE_OPACITY:
g_value_set_int (value, panel_window_get_leave_opacity (window));
break;
-
+
case PROP_SPAN_MONITORS:
g_value_set_boolean (value, panel_window_get_span_monitors (window));
break;
@@ -588,7 +592,7 @@ panel_preferences_dialog_set_property (GObject *object,
case PROP_LEAVE_OPACITY:
panel_window_set_leave_opacity (window, g_value_get_int (value));
break;
-
+
case PROP_SPAN_MONITORS:
panel_window_set_span_monitors (window, g_value_get_boolean (value));
break;
@@ -602,7 +606,7 @@ panel_preferences_dialog_set_property (GObject *object,
dialog->save_timeout_id = g_timeout_add_full (G_PRIORITY_DEFAULT_IDLE, 1000,
panel_preferences_dialog_save_timeout, dialog,
panel_preferences_dialog_save_timeout_destroyed);
-
+
/* don't leave the window */
gtk_window_present (GTK_WINDOW (dialog));
}
@@ -623,7 +627,7 @@ panel_preferences_dialog_finalize (GObject *object)
/* save */
panel_application_save (dialog->application);
}
-
+
/* thaw all autohide blocks */
panel_application_windows_autohide (dialog->application, FALSE);
@@ -665,24 +669,27 @@ panel_preferences_dialog_response (GtkDialog *dialog,
{
GError *error = NULL;
GdkScreen *screen;
-
+
if (response_id == GTK_RESPONSE_HELP)
{
/* get the dialog screen */
screen = gtk_widget_get_screen (GTK_WIDGET (dialog));
-
+
/* open the help url */
if (exo_url_show_on_screen (PREFERENCES_HELP_URL, NULL, screen, &error) == FALSE)
{
/* show error */
g_warning ("Failed to open help: %s", error->message);
-
+
/* cleanup */
g_error_free (error);
}
}
else
{
+ /* deselect all windows */
+ panel_application_window_select (PANEL_PREFERENCES_DIALOG (dialog)->application, NULL);
+
/* destroy the dialog */
gtk_widget_destroy (GTK_WIDGET (dialog));
}
@@ -693,16 +700,18 @@ panel_preferences_dialog_response (GtkDialog *dialog,
static void
panel_preferences_dialog_rebuild_selector (PanelPreferencesDialog *dialog)
{
- GtkComboBox *combo = GTK_COMBO_BOX (dialog->selector);
- gint n, n_items;
- gchar *name;
+ GtkComboBox *combo = GTK_COMBO_BOX (dialog->selector);
+ gint n, n_items;
+ gchar *name;
+ GtkTreeModel *model;
/* block signal */
g_signal_handlers_block_by_func (G_OBJECT (combo), panel_preferences_dialog_set_window, dialog);
- /* empty the xombo box */
- while (gtk_combo_box_get_active (combo) != -1)
- gtk_combo_box_remove_text (combo, 0);
+ /* empty the combo box */
+ model = gtk_combo_box_get_model (combo);
+ if (GTK_IS_LIST_STORE (model))
+ gtk_list_store_clear (GTK_LIST_STORE (model));
/* add new names */
n_items = panel_application_get_n_windows (dialog->application);
@@ -737,6 +746,9 @@ panel_preferences_dialog_set_window (PanelPreferencesDialog *dialog)
for (n = 0; n < nspecs; n++)
g_object_notify (G_OBJECT (dialog), specs[n]->name);
g_free (specs);
+
+ /* update selection state */
+ panel_application_window_select (dialog->application, dialog->active);
}
@@ -750,13 +762,16 @@ panel_preferences_dialog_add_window (GtkWidget *widget,
/* create new window */
window = panel_application_new_window (dialog->application, gtk_widget_get_screen (widget));
-
+
/* block autohide */
panel_window_freeze_autohide (window);
/* rebuild the selector */
panel_preferences_dialog_rebuild_selector (dialog);
+ /* set the sensitivity of the remove button */
+ gtk_widget_set_sensitive (dialog->remove_button, panel_application_get_n_windows (dialog->application) > 1);
+
/* select new panel */
active = panel_application_get_n_windows (dialog->application) - 1;
gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->selector), active);
@@ -786,9 +801,11 @@ panel_preferences_dialog_remove_window (GtkWidget *widget,
/* rebuild the selector */
panel_preferences_dialog_rebuild_selector (dialog);
- /* select active if there are any windows */
- if (panel_application_get_n_windows (dialog->application) > 0)
- gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->selector), MAX (0, active - 1));
+ /* set the sensitivity of the remove button */
+ gtk_widget_set_sensitive (widget, panel_application_get_n_windows (dialog->application) > 1);
+
+ /* select new active window */
+ gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->selector), MAX (0, active - 1));
}
}
@@ -814,13 +831,13 @@ panel_preferences_dialog_show (PanelWindow *active)
/* focus the window */
gtk_window_present (GTK_WINDOW (dialog));
}
-
+
/* get the active window index */
if (G_LIKELY (active))
idx = panel_application_get_window_index (dialog->application, active);
else
idx = 0;
-
+
/* select the active window in the dialog */
gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->selector), idx);
}
diff --git a/panel/panel-window.c b/panel/panel-window.c
index 02a0ca3..8a77e92 100644
--- a/panel/panel-window.c
+++ b/panel/panel-window.c
@@ -56,17 +56,14 @@ static gboolean panel_window_leave_notify_event (GtkWidget *widget, GdkEventCros
static void panel_window_size_request (GtkWidget *widget, GtkRequisition *requisition);
static void panel_window_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
static void panel_window_screen_changed (GtkWidget *widget, GdkScreen *previous_screen);
-static void panel_window_paint_handle (PanelWindow *window, gboolean start, cairo_t *rc);
-static void panel_window_paint_border (PanelWindow *window, cairo_t *rc);
+static void panel_window_paint_handle (PanelWindow *window, gboolean start, GtkStateType state, cairo_t *rc);
+static void panel_window_paint_border (PanelWindow *window, GtkStateType state, cairo_t *rc);
static void panel_window_calculate_position (PanelWindow *window, gint width, gint height, gint *x, gint *y);
static void panel_window_working_area (PanelWindow *window, gint root_x, gint root_y, GdkRectangle *dest);
static gboolean panel_window_struts_are_possible (PanelWindow *window, gint x, gint y, gint width, gint height);
static void panel_window_struts_update (PanelWindow *window, gint x, gint y, gint width, gint height);
static void panel_window_set_colormap (PanelWindow *window);
-static void
-panel_window_get_position (PanelWindow *window,
- gint *root_x,
- gint *root_y);
+static void panel_window_get_position (PanelWindow *window, gint *root_x, gint *root_y);
enum
{
@@ -144,6 +141,9 @@ struct _PanelWindow
/* whether the panel is locked */
guint locked : 1;
+ /* when the panel is 'selected' */
+ guint selected : 1;
+
/* panel orientation */
guint horizontal;
@@ -256,6 +256,7 @@ panel_window_init (PanelWindow *window)
window->autohide_status = DISABLED;
window->autohide_block = 0;
window->autohide_window = NULL;
+ window->selected = FALSE;
/* set additional events we want to have */
gtk_widget_add_events (GTK_WIDGET (window), GDK_BUTTON_PRESS_MASK);
@@ -334,23 +335,28 @@ static gboolean
panel_window_expose_event (GtkWidget *widget,
GdkEventExpose *event)
{
- PanelWindow *window = PANEL_WINDOW (widget);
- cairo_t *cr;
- GdkColor *color;
+ PanelWindow *window = PANEL_WINDOW (widget);
+ cairo_t *cr;
+ GdkColor *color;
+ GtkStateType state = GTK_STATE_NORMAL;
if (GTK_WIDGET_DRAWABLE (widget))
{
/* create cairo context */
cr = gdk_cairo_create (widget->window);
- if (window->is_composited
- && window->background_alpha < 1.00)
+ /* use another state when the panel is selected */
+ if (G_UNLIKELY (window->selected))
+ state = GTK_STATE_SELECTED;
+
+ if (window->selected ||
+ (window->is_composited && window->background_alpha < 1.00))
{
/* get the background gdk color */
- color = &(widget->style->bg[GTK_WIDGET_STATE (widget)]);
+ color = &(widget->style->bg[state]);
/* set the cairo source color */
- _set_source_rgba (cr, color, window->background_alpha);
+ _set_source_rgba (cr, color, window->selected ? 1.00 : window->background_alpha);
/* create retangle */
cairo_rectangle (cr, event->area.x, event->area.y,
@@ -366,12 +372,12 @@ panel_window_expose_event (GtkWidget *widget,
/* paint handles */
if (window->locked == FALSE)
{
- panel_window_paint_handle (window, TRUE, cr);
- panel_window_paint_handle (window, FALSE, cr);
+ panel_window_paint_handle (window, TRUE, state, cr);
+ panel_window_paint_handle (window, FALSE, state, cr);
}
/* paint the panel border */
- panel_window_paint_border (window, cr);
+ panel_window_paint_border (window, state, cr);
/* destroy cairo context */
cairo_destroy (cr);
@@ -998,6 +1004,7 @@ panel_window_screen_changed (GtkWidget *widget,
static void
panel_window_paint_handle (PanelWindow *window,
gboolean start,
+ GtkStateType state,
cairo_t *cr)
{
GtkWidget *widget = GTK_WIDGET (window);
@@ -1039,9 +1046,9 @@ panel_window_paint_handle (PanelWindow *window,
{
/* get the color for the job */
if (i == 2)
- color = &(widget->style->light[GTK_WIDGET_STATE (widget)]);
+ color = &(widget->style->light[state]);
else
- color = &(widget->style->dark[GTK_WIDGET_STATE (widget)]);
+ color = &(widget->style->dark[state]);
/* set source color */
_set_source_rgba (cr, color, alpha);
@@ -1059,8 +1066,9 @@ panel_window_paint_handle (PanelWindow *window,
static void
-panel_window_paint_border (PanelWindow *window,
- cairo_t *cr)
+panel_window_paint_border (PanelWindow *window,
+ GtkStateType state,
+ cairo_t *cr)
{
GtkWidget *widget = GTK_WIDGET (window);
GtkAllocation *alloc = &(widget->allocation);
@@ -1071,7 +1079,7 @@ panel_window_paint_border (PanelWindow *window,
cairo_set_line_width (cr, 1.0);
/* dark color */
- color = &(widget->style->dark[GTK_WIDGET_STATE (widget)]);
+ color = &(widget->style->dark[state]);
_set_source_rgba (cr, color, alpha);
/* set start position to bottom left */
@@ -1087,7 +1095,7 @@ panel_window_paint_border (PanelWindow *window,
cairo_stroke (cr);
/* light color */
- color = &(widget->style->light[GTK_WIDGET_STATE (widget)]);
+ color = &(widget->style->light[state]);
_set_source_rgba (cr, color, alpha);
/* set start position to bottom left */
@@ -1542,6 +1550,24 @@ panel_window_is_composited (PanelWindow *window)
+void
+panel_window_set_selected (PanelWindow *window,
+ gboolean selected)
+{
+ panel_return_if_fail (PANEL_IS_WINDOW (window));
+
+ if (G_UNLIKELY (window->selected != selected))
+ {
+ /* set new value */
+ window->selected = selected;
+
+ /* queue a redraw */
+ gtk_widget_queue_draw (GTK_WIDGET (window));
+ }
+}
+
+
+
PanelWindowSnapEdge
panel_window_get_snap_edge (PanelWindow *window)
{
diff --git a/panel/panel-window.h b/panel/panel-window.h
index f62aa24..f5d5736 100644
--- a/panel/panel-window.h
+++ b/panel/panel-window.h
@@ -75,6 +75,9 @@ GtkWidget *panel_window_new (void);
gboolean panel_window_is_composited (PanelWindow *window);
+void panel_window_set_selected (PanelWindow *window,
+ gboolean selected);
+
PanelWindowSnapEdge panel_window_get_snap_edge (PanelWindow *window);
void panel_window_set_snap_edge (PanelWindow *window,
PanelWindowSnapEdge snap_edge);
@@ -106,7 +109,7 @@ void panel_window_set_yoffset (PanelWindow *wi
gboolean panel_window_get_autohide (PanelWindow *window);
void panel_window_set_autohide (PanelWindow *window,
gboolean autohide);
-
+
void panel_window_freeze_autohide (PanelWindow *window);
void panel_window_thaw_autohide (PanelWindow *window);
@@ -121,7 +124,7 @@ void panel_window_set_enter_opacity (PanelWindow *wi
gint panel_window_get_leave_opacity (PanelWindow *window);
void panel_window_set_leave_opacity (PanelWindow *window,
gint opacity);
-
+
gboolean panel_window_get_span_monitors (PanelWindow *window);
void panel_window_set_span_monitors (PanelWindow *window,
gboolean span_monitors);
More information about the Xfce4-commits
mailing list