Derive ETaskWidget from GtkEventBox instead of GtkFrame so that we can

get button_press events from it.  Also, get the EActivtyHandler to
properly dispatch "Clicked" events when the user clicks on an
ETaskWidget.

svn path=/trunk/; revision=10450
This commit is contained in:
Ettore Perazzoli
2001-06-24 15:25:44 +00:00
parent ea40bb0823
commit 4e1fe266e7
4 changed files with 57 additions and 7 deletions

View File

@ -1,3 +1,14 @@
2001-06-24 Ettore Perazzoli <ettore@ximian.com>
* e-task-widget.h, e-task-widget.c: Changed to derive from
GtkEventBox.
* e-activity-handler.c (task_widget_button_press_event_callback):
New callback for the "button_press_event" signal on the
ETaskWidgets. Dispatch the "Clicked" event through the Bonobo
listener.
(task_widget_new_from_activity_info): Connect here.
2001-06-24 Ettore Perazzoli <ettore@ximian.com>
* evolution-test-component.c: Changed to use the

View File

@ -133,6 +133,37 @@ lookup_activity (GList *list,
return NULL;
}
/* ETaskWidget callbacks. */
static int
task_widget_button_press_event_callback (GtkWidget *widget,
GdkEventButton *button_event,
void *data)
{
CORBA_Environment ev;
ActivityInfo *activity_info;
CORBA_any *null_value;
activity_info = (ActivityInfo *) data;
CORBA_exception_init (&ev);
null_value = CORBA_any__alloc ();
null_value->_type = TC_null;
Bonobo_Listener_event (activity_info->event_listener, "Clicked", null_value, &ev);
if (ev._major != CORBA_NO_EXCEPTION)
g_warning ("EActivityHandler: Cannot report `Clicked' event -- %s",
ev._repo_id);
CORBA_free (null_value);
CORBA_exception_free (&ev);
return TRUE;
}
/* Creating and destroying ActivityInfos. */
@ -184,6 +215,9 @@ task_widget_new_from_activity_info (ActivityInfo *activity_info)
widget = e_task_widget_new (activity_info->icon_pixbuf, activity_info->information);
gtk_widget_show (widget);
gtk_signal_connect (GTK_OBJECT (widget), "button_press_event",
GTK_SIGNAL_FUNC (task_widget_button_press_event_callback), activity_info);
return E_TASK_WIDGET (widget);
}

View File

@ -27,6 +27,7 @@
#include "e-task-widget.h"
#include <gtk/gtkframe.h>
#include <gtk/gtkhbox.h>
#include <gtk/gtklabel.h>
#include <gtk/gtkpixmap.h>
@ -40,8 +41,8 @@
#define SPACING 2
#define PARENT_TYPE (gtk_frame_get_type ())
static GtkFrameClass *parent_class = NULL;
#define PARENT_TYPE (gtk_event_box_get_type ())
static GtkEventBoxClass *parent_class = NULL;
struct _ETaskWidgetPrivate {
GdkPixbuf *icon_pixbuf;
@ -95,6 +96,7 @@ e_task_widget_construct (ETaskWidget *task_widget,
GdkPixmap *pixmap;
GdkBitmap *mask;
GtkWidget *box;
GtkWidget *frame;
g_return_if_fail (task_widget != NULL);
g_return_if_fail (E_IS_TASK_WIDGET (task_widget));
@ -103,10 +105,13 @@ e_task_widget_construct (ETaskWidget *task_widget,
priv = task_widget->priv;
gtk_frame_set_shadow_type (GTK_FRAME (task_widget), GTK_SHADOW_IN);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_container_add (GTK_CONTAINER (task_widget), frame);
gtk_widget_show (frame);
box = gtk_hbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (task_widget), box);
gtk_container_add (GTK_CONTAINER (frame), box);
gtk_widget_show (box);
priv->icon_pixbuf = gdk_pixbuf_ref (icon_pixbuf);

View File

@ -24,7 +24,7 @@
#ifndef _E_TASK_WIDGET_H_
#define _E_TASK_WIDGET_H_
#include <gtk/gtkframe.h>
#include <gtk/gtkeventbox.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#ifdef __cplusplus
@ -44,13 +44,13 @@ typedef struct _ETaskWidgetPrivate ETaskWidgetPrivate;
typedef struct _ETaskWidgetClass ETaskWidgetClass;
struct _ETaskWidget {
GtkFrame parent;
GtkEventBox parent;
ETaskWidgetPrivate *priv;
};
struct _ETaskWidgetClass {
GtkFrameClass parent_class;
GtkEventBoxClass parent_class;
};