[Goodies-commits] r4685 - xfce4-notes-plugin/trunk/panel-plugin
Mike Massonnet
mmassonnet at xfce.org
Tue Apr 29 09:43:39 CEST 2008
Author: mmassonnet
Date: 2008-04-29 07:43:38 +0000 (Tue, 29 Apr 2008)
New Revision: 4685
Modified:
xfce4-notes-plugin/trunk/panel-plugin/notes.h
xfce4-notes-plugin/trunk/panel-plugin/panel-plugin.c
Log:
Add an arrow button (ftm not hideable)
* panel-plugin/notes.h:
- Two new widgets in NotesPlugin struct, a XfceHVBox and XfceArrowButton
* panel-plugin/panel-plugin.c:
- Add arrow button beneath panel button
- Display the menu on toggle
- Attach a callback to "orientation-changed" (NOTE: position-changed may be
better suited but doesn't exist)
Modified: xfce4-notes-plugin/trunk/panel-plugin/notes.h
===================================================================
--- xfce4-notes-plugin/trunk/panel-plugin/notes.h 2008-04-29 03:58:30 UTC (rev 4684)
+++ xfce4-notes-plugin/trunk/panel-plugin/notes.h 2008-04-29 07:43:38 UTC (rev 4685)
@@ -47,8 +47,10 @@
gchar *notes_path;
guint timeout;
+ GtkWidget *box_panel;
GtkWidget *btn_panel;
GtkWidget *icon_panel;
+ GtkWidget *btn_arrow;
GtkWidget *menu;
GtkWidget *icon;
GtkWidget *icon_rev;
Modified: xfce4-notes-plugin/trunk/panel-plugin/panel-plugin.c
===================================================================
--- xfce4-notes-plugin/trunk/panel-plugin/panel-plugin.c 2008-04-29 03:58:30 UTC (rev 4684)
+++ xfce4-notes-plugin/trunk/panel-plugin/panel-plugin.c 2008-04-29 07:43:38 UTC (rev 4685)
@@ -1,8 +1,7 @@
-/* $Id$
- *
+/*
* Notes - panel plugin for Xfce Desktop Environment
- * Copyright (C) 2003 Jakob Henriksson <b0kaj+dev at lysator.liu.se>
- * Copyright (C) 2006 Mike Massonnet <mmassonnet at gmail.com>
+ * Copyright (C) 2003 Jakob Henriksson <b0kaj+dev at lysator.liu.se>
+ * Copyright (C) 2006-2008 Mike Massonnet <mmassonnet at 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
@@ -44,6 +43,8 @@
#endif
static gboolean notes_plugin_set_size (NotesPlugin *notes_plugin,
int size);
+static void notes_plugin_set_orientation (NotesPlugin *notes_plugin,
+ GtkOrientation orientation);
static void notes_plugin_load_data (NotesPlugin *notes_plugin);
static inline void notes_plugin_save_data (NotesPlugin *notes_plugin);
@@ -64,6 +65,8 @@
ThunarVfsPath *event_path,
NotesPlugin *notes_plugin);
#endif
+static gboolean notes_plugin_arrow_pressed (NotesPlugin *notes_plugin,
+ GdkEventButton *event);
static gboolean notes_plugin_button_pressed (NotesPlugin *notes_plugin,
GdkEventButton *event);
static gboolean notes_plugin_button_released (NotesPlugin *notes_plugin,
@@ -123,13 +126,16 @@
notes_plugin->notes_path);
notes_plugin->windows = NULL;
+ notes_plugin->box_panel = GTK_WIDGET (xfce_hvbox_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 0));
notes_plugin->btn_panel = xfce_create_panel_toggle_button ();
notes_plugin->icon_panel = gtk_image_new ();
+ notes_plugin->btn_arrow = GTK_WIDGET (xfce_arrow_button_new (GTK_ARROW_UP));
+ gtk_button_set_relief (GTK_BUTTON (notes_plugin->btn_arrow), GTK_RELIEF_NONE);
- gtk_container_add (GTK_CONTAINER (notes_plugin->btn_panel),
- notes_plugin->icon_panel);
- gtk_container_add (GTK_CONTAINER (panel_plugin),
- notes_plugin->btn_panel);
+ gtk_container_add (GTK_CONTAINER (notes_plugin->btn_panel), notes_plugin->icon_panel);
+ gtk_container_add (GTK_CONTAINER (notes_plugin->box_panel), notes_plugin->btn_panel);
+ gtk_container_add (GTK_CONTAINER (notes_plugin->box_panel), notes_plugin->btn_arrow);
+ gtk_container_add (GTK_CONTAINER (panel_plugin), notes_plugin->box_panel);
#ifdef HAVE_XFCONF
g_signal_connect_swapped (panel_plugin,
@@ -142,6 +148,10 @@
G_CALLBACK (notes_plugin_set_size),
notes_plugin);
g_signal_connect_swapped (panel_plugin,
+ "orientation-changed",
+ G_CALLBACK (notes_plugin_set_orientation),
+ notes_plugin);
+ g_signal_connect_swapped (panel_plugin,
"save",
G_CALLBACK (notes_plugin_save_data),
notes_plugin);
@@ -149,6 +159,10 @@
"free-data",
G_CALLBACK (notes_plugin_free),
notes_plugin);
+ g_signal_connect_swapped (notes_plugin->btn_arrow,
+ "button-press-event",
+ G_CALLBACK (notes_plugin_arrow_pressed),
+ notes_plugin);
g_signal_connect_swapped (notes_plugin->btn_panel,
"button-press-event",
G_CALLBACK (notes_plugin_button_pressed),
@@ -173,12 +187,13 @@
}
#endif
+ notes_plugin_set_selection (notes_plugin);
#ifdef HAVE_XFCONF
xfce_panel_plugin_menu_show_configure (panel_plugin);
#endif
xfce_panel_plugin_add_action_widget (panel_plugin, notes_plugin->btn_panel);
- notes_plugin_set_selection (notes_plugin);
- gtk_widget_show_all (notes_plugin->btn_panel);
+ xfce_panel_plugin_add_action_widget (panel_plugin, notes_plugin->btn_arrow);
+ gtk_widget_show_all (GTK_WIDGET (panel_plugin));
return notes_plugin;
}
@@ -224,6 +239,22 @@
}
static void
+notes_plugin_set_orientation (NotesPlugin *notes_plugin,
+ GtkOrientation orientation)
+{
+ xfce_hvbox_set_orientation (notes_plugin->box_panel, orientation);
+ XfceScreenPosition position = xfce_panel_plugin_get_screen_position (notes_plugin->panel_plugin);
+ if (xfce_screen_position_is_top (position))
+ xfce_arrow_button_set_arrow_type (notes_plugin->btn_arrow, GTK_ARROW_DOWN);
+ else if (xfce_screen_position_is_left (position))
+ xfce_arrow_button_set_arrow_type (notes_plugin->btn_arrow, GTK_ARROW_RIGHT);
+ else if (xfce_screen_position_is_right (position))
+ xfce_arrow_button_set_arrow_type (notes_plugin->btn_arrow, GTK_ARROW_LEFT);
+ else /*if (xfce_screen_position_is_bottom (position))*/
+ xfce_arrow_button_set_arrow_type (notes_plugin->btn_arrow, GTK_ARROW_UP);
+}
+
+static void
notes_plugin_load_data (NotesPlugin *notes_plugin)
{
NotesWindow *notes_window;
@@ -368,6 +399,19 @@
#endif
static gboolean
+notes_plugin_arrow_pressed (NotesPlugin *notes_plugin,
+ GdkEventButton *event)
+{
+ if (G_LIKELY (event->button != 1 || event->state & GDK_CONTROL_MASK))
+ return FALSE;
+
+ notes_plugin_menu_popup (notes_plugin);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (notes_plugin->btn_arrow), TRUE);
+
+ return TRUE;
+}
+
+static gboolean
notes_plugin_button_pressed (NotesPlugin *notes_plugin,
GdkEventButton *event)
{
@@ -445,8 +489,7 @@
{
TRACE ("notes_window (%d): %p", (i-1), notes_window);
GtkWidget *mi_foo = gtk_image_menu_item_new_with_label (notes_window->name);
- GtkWidget *icon = gtk_image_new_from_icon_name ("xfce4-notes-plugin",
- GTK_ICON_SIZE_MENU);
+ GtkWidget *icon = gtk_image_new_from_icon_name ("xfce4-notes-plugin", GTK_ICON_SIZE_MENU);
gtk_widget_set_sensitive (icon, GTK_WIDGET_VISIBLE (notes_window->window));
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi_foo), icon);
@@ -551,6 +594,7 @@
if (G_LIKELY (GTK_IS_MENU (notes_plugin->menu)))
gtk_menu_detach (GTK_MENU (notes_plugin->menu));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (notes_plugin->btn_panel), FALSE);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (notes_plugin->btn_arrow), FALSE);
}
More information about the Goodies-commits
mailing list