[Xfce4-commits] <thunar:jannis/new-shortcuts-pane> Implement basic keyboard navigation and focus movement.
Jannis Pohlmann
noreply at xfce.org
Mon Jun 6 17:54:01 CEST 2011
Updating branch refs/heads/jannis/new-shortcuts-pane
to 9009fe85f7f254b7e34570e52aaa6a948b74f18b (commit)
from 3d34ec850c15d8f17fab0b6ade07b026cfc4f260 (commit)
commit 9009fe85f7f254b7e34570e52aaa6a948b74f18b
Author: Jannis Pohlmann <jannis at xfce.org>
Date: Mon Jun 6 17:51:40 2011 +0200
Implement basic keyboard navigation and focus movement.
thunar/thunar-shortcut-row.c | 167 ++++++++++++++++++++++++++++++++++++++----
1 files changed, 151 insertions(+), 16 deletions(-)
diff --git a/thunar/thunar-shortcut-row.c b/thunar/thunar-shortcut-row.c
index be538b8..da3d312 100644
--- a/thunar/thunar-shortcut-row.c
+++ b/thunar/thunar-shortcut-row.c
@@ -45,21 +45,29 @@ enum
-static void thunar_shortcut_row_constructed (GObject *object);
-static void thunar_shortcut_row_dispose (GObject *object);
-static void thunar_shortcut_row_finalize (GObject *object);
-static void thunar_shortcut_row_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static void thunar_shortcut_row_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void thunar_shortcut_row_icon_changed (ThunarShortcutRow *row);
-static void thunar_shortcut_row_label_changed (ThunarShortcutRow *row);
-static void thunar_shortcut_row_file_changed (ThunarShortcutRow *row);
-static void thunar_shortcut_row_volume_changed (ThunarShortcutRow *row);
+static void thunar_shortcut_row_constructed (GObject *object);
+static void thunar_shortcut_row_dispose (GObject *object);
+static void thunar_shortcut_row_finalize (GObject *object);
+static void thunar_shortcut_row_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void thunar_shortcut_row_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static gboolean thunar_shortcut_row_expose_event (GtkWidget *widget,
+ GdkEventExpose *event);
+static gboolean thunar_shortcut_row_focus (GtkWidget *widget,
+ GtkDirectionType direction);
+static gboolean thunar_shortcut_row_focus_in_event (GtkWidget *widget,
+ GdkEventFocus *event);
+static gboolean thunar_shortcut_row_focus_out_event (GtkWidget *widget,
+ GdkEventFocus *event);
+static void thunar_shortcut_row_icon_changed (ThunarShortcutRow *row);
+static void thunar_shortcut_row_label_changed (ThunarShortcutRow *row);
+static void thunar_shortcut_row_file_changed (ThunarShortcutRow *row);
+static void thunar_shortcut_row_volume_changed (ThunarShortcutRow *row);
@@ -94,7 +102,8 @@ G_DEFINE_TYPE (ThunarShortcutRow, thunar_shortcut_row, GTK_TYPE_EVENT_BOX)
static void
thunar_shortcut_row_class_init (ThunarShortcutRowClass *klass)
{
- GObjectClass *gobject_class;
+ GtkWidgetClass *gtkwidget_class;
+ GObjectClass *gobject_class;
/* determine the parent type class */
thunar_shortcut_row_parent_class = g_type_class_peek_parent (klass);
@@ -106,6 +115,12 @@ thunar_shortcut_row_class_init (ThunarShortcutRowClass *klass)
gobject_class->get_property = thunar_shortcut_row_get_property;
gobject_class->set_property = thunar_shortcut_row_set_property;
+ gtkwidget_class = GTK_WIDGET_CLASS (klass);
+ gtkwidget_class->expose_event = thunar_shortcut_row_expose_event;
+ gtkwidget_class->focus = thunar_shortcut_row_focus;
+ gtkwidget_class->focus_in_event = thunar_shortcut_row_focus_in_event;
+ gtkwidget_class->focus_out_event = thunar_shortcut_row_focus_out_event;
+
g_object_class_install_property (gobject_class, PROP_ICON,
g_param_spec_object ("icon",
"icon",
@@ -302,6 +317,126 @@ thunar_shortcut_row_set_property (GObject *object,
+static gboolean
+thunar_shortcut_row_expose_event (GtkWidget *widget,
+ GdkEventExpose *event)
+{
+ GtkStateType state;
+ GList *children;
+ GList *lp;
+
+ _thunar_return_val_if_fail (THUNAR_IS_SHORTCUT_ROW (widget), FALSE);
+
+ /* determine the widget state */
+ state = gtk_widget_get_state (widget);
+
+ /* paint a flat box that gives the row the same look as a
+ * tree view row */
+ gtk_paint_flat_box (gtk_widget_get_style (widget),
+ event->window,
+ state,
+ GTK_SHADOW_NONE,
+ &event->area,
+ widget,
+ "cell_even_middle",
+ event->area.x,
+ event->area.y,
+ event->area.width,
+ event->area.height);
+
+ /* propagate the expose event to all children */
+ children = gtk_container_get_children (GTK_CONTAINER (widget));
+ for (lp = children; lp != NULL; lp = lp->next)
+ gtk_container_propagate_expose (GTK_CONTAINER (widget), lp->data, event);
+ g_list_free (children);
+
+ return FALSE;
+}
+
+
+
+static gboolean
+thunar_shortcut_row_focus (GtkWidget *widget,
+ GtkDirectionType direction)
+{
+ ThunarShortcutRow *row = THUNAR_SHORTCUT_ROW (widget);
+
+ _thunar_return_val_if_fail (THUNAR_IS_SHORTCUT_ROW (widget), FALSE);
+
+ switch (direction)
+ {
+ case GTK_DIR_TAB_FORWARD:
+ case GTK_DIR_TAB_BACKWARD:
+ return FALSE;
+
+ case GTK_DIR_UP:
+ if (gtk_widget_is_focus (widget) || gtk_widget_is_focus (row->action_button))
+ {
+ return FALSE;
+ }
+ else
+ {
+ gtk_widget_grab_focus (widget);
+ return TRUE;
+ }
+
+ case GTK_DIR_DOWN:
+ if (gtk_widget_is_focus (widget) || gtk_widget_is_focus (row->action_button))
+ {
+ return FALSE;
+ }
+ else
+ {
+ gtk_widget_grab_focus (widget);
+ return TRUE;
+ }
+
+ case GTK_DIR_LEFT:
+ gtk_widget_grab_focus (widget);
+ return TRUE;
+
+ case GTK_DIR_RIGHT:
+ if (gtk_widget_get_visible (row->action_button))
+ {
+ gtk_widget_grab_focus (row->action_button);
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+
+ default:
+ return FALSE;
+ }
+}
+
+
+
+static gboolean
+thunar_shortcut_row_focus_in_event (GtkWidget *widget,
+ GdkEventFocus *event)
+{
+ _thunar_return_val_if_fail (THUNAR_IS_SHORTCUT_ROW (widget), FALSE);
+
+ gtk_widget_set_state (widget, GTK_STATE_SELECTED);
+ return TRUE;
+}
+
+
+
+static gboolean
+thunar_shortcut_row_focus_out_event (GtkWidget *widget,
+ GdkEventFocus *event)
+{
+ _thunar_return_val_if_fail (THUNAR_IS_SHORTCUT_ROW (widget), FALSE);
+
+ gtk_widget_set_state (widget, GTK_STATE_NORMAL);
+ return TRUE;
+}
+
+
+
static void
thunar_shortcut_row_icon_changed (ThunarShortcutRow *row)
{
More information about the Xfce4-commits
mailing list