Commit b53ace68 authored by Padraig O'Briain's avatar Padraig O'Briain

panel-applet-frame.[ch] Add action signal move-focus_out_of_panel to move

* panel-applet-frame.[ch]
Add action signal move-focus_out_of_panel to move focus from applet to
next or previous object on panel. Currently Tab and Shift+Tab are the
keys which do this.

* foobar-widget.[ch]
Add action signal focus_panel to support moving focus to the panel

* panel.c:
Remove unused argument PanelData specified for panel_event()
Set focus on panel if button release happens in panel and panel is
not focus widget.
parent 60dfe917
2002-02-06 Padraig O'Briain <padraig.obriain@sun.com>
* panel-applet-frame.[ch]
Add action signal move-focus_out_of_panel to move focus from applet to
next or previous object on panel. Currently Tab and Shift+Tab are the
keys which do this.
* foobar-widget.[ch]
Add action signal focus_panel to support moving focus to the panel
* panel.c:
Remove unused argument PanelData specified for panel_event()
Set focus on panel if button release happens in panel and panel is
not focus widget.
2002-02-06 Mark McLoughlin <mark@skynet.ie>
* gnome-run.c:
......@@ -50,7 +65,7 @@ Tue Feb 05 17:48:58 2002 George Lebl <jirka@5z.com>
2002-02-04 Padraig O'Briain <padraig.obriain@sun.com>
* panel.c: Correct popping up of panel's context meny using keyboard.
* panel.c: Correct popping up of panel's context menu using keyboard.
2002-02-04 Padraig O'Briain <padraig.obriain@sun.com>
......
......@@ -20,6 +20,7 @@
#define WNCK_I_KNOW_THIS_IS_UNSTABLE
#include <libwnck/libwnck.h>
#include <gconf/gconf-client.h>
#include <gdk/gdkkeysyms.h>
#include "foobar-widget.h"
......@@ -35,6 +36,7 @@
#include "gnome-run.h"
#include "multiscreen-stuff.h"
#include "panel-gconf.h"
#include "panel-marshal.h"
#define ICON_SIZE 20
......@@ -53,6 +55,7 @@ static gboolean foobar_leave_notify (GtkWidget *widget,
GdkEventCrossing *event);
static gboolean foobar_enter_notify (GtkWidget *widget,
GdkEventCrossing *event);
static void foobar_widget_focus_panel (FoobarWidget *foo);
static void append_task_menu (FoobarWidget *foo, GtkMenuShell *menu_bar);
static void setup_task_menu (FoobarWidget *foo);
......@@ -60,6 +63,13 @@ static GList *foobars = NULL;
static GtkWindowClass *foobar_widget_parent_class = NULL;
enum {
FOCUS_PANEL_SIGNAL,
WIDGET_LAST_SIGNAL
};
static guint foobar_widget_signals[WIDGET_LAST_SIGNAL] = { 0 };
GType
foobar_widget_get_type (void)
{
......@@ -91,6 +101,7 @@ foobar_widget_class_init (FoobarWidgetClass *klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
GtkBindingSet *binding_set;
object_class->destroy = foobar_widget_destroy;
......@@ -99,6 +110,8 @@ foobar_widget_class_init (FoobarWidgetClass *klass)
widget_class->enter_notify_event = foobar_enter_notify;
widget_class->leave_notify_event = foobar_leave_notify;
klass->focus_panel = foobar_widget_focus_panel;
gtk_rc_parse_string ("style \"panel-foobar-menubar-style\"\n"
"{\n"
"GtkMenuBar::shadow-type = none\n"
......@@ -106,6 +119,28 @@ foobar_widget_class_init (FoobarWidgetClass *klass)
"}\n"
"widget \"*.panel-foobar-menubar\" style \"panel-foobar-menubar-style\"");
foobar_widget_signals[FOCUS_PANEL_SIGNAL] =
g_signal_new ("focus_panel",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (FoobarWidgetClass, focus_panel), NULL,
NULL,
panel_marshal_VOID__VOID,
G_TYPE_NONE,
0);
binding_set = gtk_binding_set_by_class (object_class);
gtk_binding_entry_add_signal (binding_set,
GDK_Tab, GDK_CONTROL_MASK,
"focus_panel", 0);
gtk_binding_entry_add_signal (binding_set,
GDK_KP_Tab, GDK_CONTROL_MASK,
"focus_panel", 0);
gtk_binding_entry_add_signal (binding_set,
GDK_ISO_Left_Tab, GDK_CONTROL_MASK,
"focus_panel", 0);
}
static GtkWidget *
......@@ -1345,3 +1380,11 @@ foobar_widget_redo_window(FoobarWidget *foo)
gtk_widget_map(widget);
}
static void
foobar_widget_focus_panel (FoobarWidget *foobar)
{
panel_widget_focus (PANEL_WIDGET (foobar->panel));
}
......@@ -56,6 +56,8 @@ struct _FoobarWidget
struct _FoobarWidgetClass
{
GtkWindowClass panel_class;
void (*focus_panel) (FoobarWidget *foo);
};
GType foobar_widget_get_type (void) G_GNUC_CONST;
......
......@@ -29,11 +29,13 @@
#include <gconf/gconf.h>
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#include <gdk/gdkkeysyms.h>
#include "panel-applet-frame.h"
#include "panel-gconf.h"
#include "session.h"
#include "applet.h"
#include "panel-marshal.h"
#undef PANEL_APPLET_FRAME_DEBUG
......@@ -44,10 +46,23 @@ struct _PanelAppletFramePrivate {
AppletInfo *applet_info;
gchar *iid;
gboolean moving_focus_out;
};
static void panel_applet_frame_move_focus_out_of_applet (PanelAppletFrame *frame,
GtkDirectionType dir);
static gboolean panel_applet_focus (GtkWidget *widget,
GtkDirectionType dir);
static GObjectClass *parent_class;
enum {
MOVE_FOCUS_OUT_OF_APPLET,
LAST_SIGNAL
};
static guint panel_applet_frame_signals [LAST_SIGNAL];
void
panel_applet_frame_save_to_gconf (PanelAppletFrame *frame,
const char *gconf_key)
......@@ -312,15 +327,54 @@ panel_applet_frame_finalize (GObject *object)
parent_class->finalize (object);
}
static void
add_tab_bindings (GtkBindingSet *binding_set,
GdkModifierType modifiers,
GtkDirectionType direction)
{
gtk_binding_entry_add_signal (binding_set, GDK_Tab, modifiers,
"move_focus_out_of_applet", 1,
GTK_TYPE_DIRECTION_TYPE, direction);
gtk_binding_entry_add_signal (binding_set, GDK_KP_Tab, modifiers,
"move_focus_out_of_applet", 1,
GTK_TYPE_DIRECTION_TYPE, direction);
gtk_binding_entry_add_signal (binding_set, GDK_ISO_Left_Tab, modifiers,
"move_focus_out_of_applet", 1,
GTK_TYPE_DIRECTION_TYPE, direction);
}
static void
panel_applet_frame_class_init (PanelAppletFrameClass *klass,
gpointer dummy)
{
GObjectClass *gobject_class = (GObjectClass *) klass;
GtkObjectClass *object_class = (GtkObjectClass *) klass;
GtkWidgetClass *widget_class = (GtkWidgetClass *) klass;
GtkBindingSet *binding_set;
parent_class = g_type_class_peek_parent (klass);
gobject_class->finalize = panel_applet_frame_finalize;
widget_class->focus = panel_applet_focus;
klass->move_focus_out_of_applet = panel_applet_frame_move_focus_out_of_applet;
panel_applet_frame_signals [MOVE_FOCUS_OUT_OF_APPLET] =
g_signal_new ("move_focus_out_of_applet",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (PanelAppletFrameClass, move_focus_out_of_applet),
NULL,
NULL,
panel_marshal_VOID__ENUM,
G_TYPE_NONE,
1,
GTK_TYPE_DIRECTION_TYPE);
binding_set = gtk_binding_set_by_class (object_class);
add_tab_bindings (binding_set, 0, GTK_DIR_TAB_FORWARD);
add_tab_bindings (binding_set, GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD);
}
static void
......@@ -332,6 +386,7 @@ panel_applet_frame_instance_init (PanelAppletFrame *frame,
frame->priv->applet_shell = CORBA_OBJECT_NIL;
frame->priv->property_bag = CORBA_OBJECT_NIL;
frame->priv->applet_info = NULL;
frame->priv->moving_focus_out = FALSE;
}
GType
......@@ -460,3 +515,33 @@ panel_applet_frame_new (const char *iid,
return GTK_WIDGET (frame);
}
static void
panel_applet_frame_move_focus_out_of_applet (PanelAppletFrame *frame,
GtkDirectionType dir)
{
GtkWidget *toplevel;
frame->priv->moving_focus_out = TRUE;
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (frame));
g_return_if_fail (toplevel);
gtk_widget_child_focus (toplevel, dir);
frame->priv->moving_focus_out = FALSE;
}
static gboolean
panel_applet_focus (GtkWidget *widget,
GtkDirectionType dir)
{
PanelAppletFrame *frame;
g_return_val_if_fail (PANEL_IS_APPLET_FRAME (widget), FALSE);
frame = PANEL_APPLET_FRAME (widget);
if (frame->priv->moving_focus_out) {
return FALSE;
} else {
return GTK_WIDGET_CLASS (parent_class)->focus (widget, dir);
}
}
......@@ -51,6 +51,9 @@ struct _PanelAppletFrame{
struct _PanelAppletFrameClass {
GtkEventBoxClass event_box_class;
void (* move_focus_out_of_applet) (PanelAppletFrame *frame,
GtkDirectionType direction);
};
GType panel_applet_frame_get_type (void) G_GNUC_CONST;
......
......@@ -794,8 +794,26 @@ panel_popup_menu (GtkWidget *widget, gpointer data)
return panel_do_popup_menu (panel, basep, widget, 3, GDK_CURRENT_TIME);
}
static gboolean pointer_in_widget (GtkWidget *widget, GdkEventButton *event)
{
int x, y;
int wx, wy;
int width, height;
x = (int) event->x_root;
y = (int) event->y_root;
gdk_window_get_origin (widget->window, &wx, &wy);
width = widget->allocation.width;
height = widget->allocation.height;
if ((x < wx || x >= wx + width) ||
(y < wy || y >= wy + height))
return FALSE;
else
return TRUE;
}
static gboolean
panel_event(GtkWidget *widget, GdkEvent *event, PanelData *pd)
panel_event(GtkWidget *widget, GdkEvent *event)
{
PanelWidget *panel = NULL;
BasePWidget *basep = NULL;
......@@ -828,22 +846,24 @@ panel_event(GtkWidget *widget, GdkEvent *event, PanelData *pd)
case GDK_BUTTON_RELEASE:
bevent = (GdkEventButton *) event;
if(panel_dragged) {
if (!basep)
return TRUE;
basep_widget_set_pos(basep,
(gint16)bevent->x_root,
(gint16)bevent->y_root);
basep->autohide_inhibit = FALSE;
basep_widget_queue_autohide(BASEP_WIDGET(widget));
gdk_pointer_ungrab(bevent->time);
gtk_grab_remove(widget);
panel_dragged = FALSE;
panel_dragged_timeout = -1;
panel_been_moved = FALSE;
if (basep) {
basep_widget_set_pos(basep,
(gint16)bevent->x_root,
(gint16)bevent->y_root);
basep->autohide_inhibit = FALSE;
basep_widget_queue_autohide(BASEP_WIDGET(widget));
gdk_pointer_ungrab(bevent->time);
gtk_grab_remove(widget);
panel_dragged = FALSE;
panel_dragged_timeout = -1;
panel_been_moved = FALSE;
}
if (pointer_in_widget (basep->panel, bevent) &&
!gtk_widget_is_focus (basep->panel))
panel_widget_focus (panel);
return TRUE;
}
break;
case GDK_MOTION_NOTIFY:
if (panel_dragged) {
......@@ -1736,7 +1756,7 @@ panel_setup(GtkWidget *panelw)
0, NULL, 0, 0);
g_signal_connect (G_OBJECT (panelw), "event",
G_CALLBACK (panel_event), pd);
G_CALLBACK (panel_event), NULL);
g_signal_connect (G_OBJECT (panel), "popup_menu",
G_CALLBACK (panel_popup_menu), panelw);
g_signal_connect (G_OBJECT (panel), "event",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment