Commit 22081781 authored by Jiri (George) Lebl's avatar Jiri (George) Lebl Committed by George Lebl

simple applet widget with a window and an event box so that events get

Sat Feb 21 00:24:30 1998  George Lebl  <jirka@5z.com>

        * applet-widget.[ch]: simple applet widget with a window
          and an event box so that events get trapped by teh applet
          and not partly by the panel.

        * gnome-panel.idl: added a callback for button presses, and

        * panel.c, mico-glue.cc, applet-lib.cc, clock.c: implemented
          (mostly) applet IDs for communication
parent 64a6ef21
Sat Feb 21 00:24:30 1998 George Lebl <jirka@5z.com>
* applet-widget.[ch]: simple applet widget with a window
and an event box so that events get trapped by teh applet
and not partly by the panel.
* gnome-panel.idl: added a callback for button presses, and
* panel.c, mico-glue.cc, applet-lib.cc, clock.c: implemented
(mostly) applet IDs for communication
Wed Feb 18 17:40:39 1998 Miguel de Icaza <miguel@nuclecu.unam.mx>
* mico-glue.cc, mico-glue.h: New files that include all of the
......
Sat Feb 21 00:24:30 1998 George Lebl <jirka@5z.com>
* applet-widget.[ch]: simple applet widget with a window
and an event box so that events get trapped by teh applet
and not partly by the panel.
* gnome-panel.idl: added a callback for button presses, and
* panel.c, mico-glue.cc, applet-lib.cc, clock.c: implemented
(mostly) applet IDs for communication
Wed Feb 18 17:40:39 1998 Miguel de Icaza <miguel@nuclecu.unam.mx>
* mico-glue.cc, mico-glue.h: New files that include all of the
......
......@@ -45,6 +45,9 @@ panel_LDADD = $(GNOME_LIBDIR) $(MICO_LIBS) -lXt $(GNOMEUI_LIBS) $(INTLLIBS)
clock_applet_SOURCES = \
clock.c \
applet-lib.cc \
applet-lib.h \
applet-widget.c \
applet-widget.h \
$(CORBA_SOURCES)
clock_applet_LDADD = $(GNOME_LIBDIR) $(MICO_LIBS) -lXt $(GNOMEUI_LIBS) $(INTLLIBS)
......
#ifndef APPLET_LIB_H
#define APPLET_LIB_H
BEGIN_GNOME_DECLS
char *gnome_panel_prepare_and_transfer (GtkWidget *widget);
char *gnome_panel_prepare_and_transfer (GtkWidget *widget, int *id,
int panel, int pos);
int gnome_panel_applet_init_corba (int *argc, char ***argv);
END_GNOME_DECLS
#endif
#include <gtk/gtk.h>
#include <gnome.h>
#include "applet-widget.h"
static void applet_widget_class_init (AppletWidgetClass *klass);
static void applet_widget_init (AppletWidget *applet_widget);
guint
applet_widget_get_type ()
{
static guint applet_widget_type = 0;
if (!applet_widget_type) {
GtkTypeInfo applet_widget_info = {
"AppletWidget",
sizeof (AppletWidget),
sizeof (AppletWidgetClass),
(GtkClassInitFunc) applet_widget_class_init,
(GtkObjectInitFunc) applet_widget_init,
(GtkArgSetFunc) NULL,
(GtkArgGetFunc) NULL,
};
applet_widget_type = gtk_type_unique (gtk_window_get_type (),
&applet_widget_info);
}
return applet_widget_type;
}
static void
applet_widget_class_init (AppletWidgetClass *class)
{
}
static void
applet_widget_init (AppletWidget *applet_widget)
{
applet_widget->eb = gtk_event_box_new();
gtk_widget_show(applet_widget->eb);
GTK_WINDOW(applet_widget)->type = GTK_WINDOW_POPUP;
gtk_container_add(GTK_CONTAINER(applet_widget),applet_widget->eb);
gtk_window_set_policy (GTK_WINDOW (applet_widget), 1, 1, 1);
}
GtkWidget*
applet_widget_new (void)
{
AppletWidget *applet;
applet = gtk_type_new(applet_widget_get_type());
return GTK_WIDGET(applet);
}
void
applet_widget_add (AppletWidget *applet, GtkWidget *widget)
{
g_return_if_fail(applet != NULL);
g_return_if_fail(widget != NULL);
gtk_container_add(GTK_CONTAINER(applet->eb),widget);
}
void
applet_widget_remove (AppletWidget *applet, GtkWidget *widget)
{
g_return_if_fail(applet != NULL);
g_return_if_fail(widget != NULL);
gtk_container_remove(GTK_CONTAINER(applet->eb),widget);
}
#ifndef __APPLET_WIDGET_H__
#define __APPLET_WIDGET_H__
#include <gtk/gtk.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define APPLET_WIDGET(obj) GTK_CHECK_CAST (obj, applet_widget_get_type (), AppletWidget)
#define APPLET_WIDGET_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, applet_widget_get_type (), AppletWidgetClass)
#define IS_APPLET_WIDGET(obj) GTK_CHECK_TYPE (obj, applet_widget_get_type ())
typedef struct _AppletWidget AppletWidget;
typedef struct _AppletWidgetClass AppletWidgetClass;
struct _AppletWidget
{
GtkWindow window;
GtkWidget *eb;
};
struct _AppletWidgetClass
{
GtkWindowClass parent_class;
};
guint applet_widget_get_type (void);
GtkWidget* applet_widget_new (void);
/*add a widget to the applet*/
void applet_widget_add (AppletWidget *applet,
GtkWidget *widget);
/*remove a widget from the applet*/
void applet_widget_remove (AppletWidget *applet,
GtkWidget *widget);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __APPLET_WIDGET_H__ */
......@@ -20,11 +20,14 @@
#include <gnome.h>
#include <gdk/gdkx.h>
#include <applet-lib.h>
#include <applet-widget.h>
#define CLOCK_DATA "clock_data"
typedef void (*ClockUpdateFunc) (GtkWidget *clock, time_t current_time);
int applet_id=-1; /*this is our id we use to comunicate with the panel*/
typedef struct {
int timeout;
......@@ -81,6 +84,12 @@ computer_clock_update_func(GtkWidget *clock, time_t current_time)
gtk_label_set (GTK_LABEL (cc->time), hour);
}
static gint
testbutton_c(GtkWidget *widget, gpointer data)
{
puts("CLICKED TEST!");
}
static void
create_computer_clock_widget(GtkWidget **clock, ClockUpdateFunc *update_func)
{
......@@ -88,6 +97,7 @@ create_computer_clock_widget(GtkWidget **clock, ClockUpdateFunc *update_func)
GtkWidget *align;
GtkWidget *vbox;
ComputerClock *cc;
GtkWidget *testbutton;
frame = gtk_frame_new(NULL);
gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN);
......@@ -111,6 +121,13 @@ create_computer_clock_widget(GtkWidget **clock, ClockUpdateFunc *update_func)
gtk_widget_show(cc->date);
gtk_widget_show(cc->time);
testbutton = gtk_button_new_with_label("TEST");
gtk_signal_connect(GTK_OBJECT(testbutton), "clicked",
(GtkSignalFunc) testbutton_c,
NULL);
gtk_box_pack_start_defaults(GTK_BOX(vbox), testbutton);
gtk_widget_show(testbutton);
gtk_object_set_user_data(GTK_OBJECT(frame), cc);
gtk_signal_connect(GTK_OBJECT(frame), "destroy",
(GtkSignalFunc) free_data,
......@@ -166,7 +183,7 @@ int
main(int argc, char **argv)
{
GtkWidget *clock;
GtkWidget *window;
GtkWidget *aw;
char *result;
gnome_init("clock_applet", &argc, &argv);
......@@ -176,15 +193,16 @@ main(int argc, char **argv)
exit (1);
}
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_policy (GTK_WINDOW (window), 1, 1, 1);
aw = applet_widget_new ();
clock = create_clock_widget (GTK_WIDGET(window));
clock = create_clock_widget (GTK_WIDGET(aw));
gtk_widget_show(clock);
gtk_container_add (GTK_CONTAINER (window), clock);
gtk_widget_show (window);
applet_widget_add (APPLET_WIDGET (aw), clock);
gtk_widget_show (aw);
result = gnome_panel_prepare_and_transfer(window);
/*FIXME: do session saving, find out panel and pos from the panel
so we can restore them on the next startup*/
result = gnome_panel_prepare_and_transfer(aw,&applet_id,0,0);
printf ("Done\n");
if (result){
printf ("Could not talk to the Panel: %s\n", result);
......
......@@ -4,6 +4,7 @@
#include <gnome.h>
#include "mico-glue.h"
#include "gnome-panel.h"
#include "panel.h"
/* This implements the server-side of the gnome-panel.idl
* specification Currently there is no way to create new CORBA
......@@ -13,10 +14,18 @@
class Panel_impl : virtual public GNOME::Panel_skel {
public:
void reparent_window_id (CORBA::ULong wid){
CORBA::Short reparent_window_id (CORBA::ULong wid,
CORBA::Short panel,
CORBA::Short pos) {
printf ("REPARENT!\n");
::reparent_window_id (wid);
return ::reparent_window_id (wid,panel,pos);
}
CORBA::Short applet_button_press_event (CORBA::Short id,
CORBA::Short button) {
printf ("BUTTON_PRESS_EVENT!\n");
return ::applet_button_press_event (id,button);
}
};
......
......@@ -488,6 +488,16 @@ add_main_menu(GtkWidget *widget, gpointer data)
create_applet("Menu",".",PANEL_UNKNOWN_APPLET_POSITION,1);
}
int
applet_button_press_event(int id, int button)
{
/*send these to the parent of the applet*/
if(button == 2 || button == 3) {
}
return FALSE;
}
struct reparent_struct {
GdkWindow *win;
GdkWindow *target;
......@@ -500,7 +510,7 @@ delayed_reparent_window_id (gpointer data)
int i;
printf ("delayed in\n");
for (i = 0; i < 1; i++){
for (i = 0; i < 200; i++){
gdk_window_reparent(rs->win,rs->target,0,0);
gdk_flush ();
}
......@@ -509,8 +519,8 @@ delayed_reparent_window_id (gpointer data)
return 0;
}
void
reparent_window_id (unsigned long id)
int
reparent_window_id (unsigned long id, int panel, int pos)
{
struct reparent_struct *rs = g_new (struct reparent_struct, 1);
GtkWidget *eb;
......@@ -527,8 +537,7 @@ reparent_window_id (unsigned long id)
gtk_widget_set_usize(eb,w,h);
gtk_widget_show (eb);
panel_widget_add(PANEL_WIDGET(panels->data), eb, 0);
register_toy(eb,NULL,"External",NULL,pos,panel,0,APPLET_EXTERN);
rs->win = win;
rs->target = eb->window;
......@@ -536,6 +545,8 @@ reparent_window_id (unsigned long id)
gtk_idle_add (delayed_reparent_window_id, (gpointer) rs);
printf ("leaving reparent\n");
return /*FIXME: appletid*/0;
}
/*FIXME: add a function that does this, so generalize register_toy for this*/
......@@ -543,11 +554,13 @@ static void
add_reparent(GtkWidget *widget, gpointer data)
{
int id;
int appletid;
puts("** warning this will probably crash when saving session **");
puts("Enter window ID to reparent:");
scanf("%d",&id);
reparent_window_id (id);
(void)reparent_window_id (id,0,0);
}
GtkWidget *
......
......@@ -81,11 +81,15 @@ void panel_quit(void);
void apply_global_config(void);
/*these are in main.c*/
int reparent_window_id (unsigned long id, int panel, int pos);
/*event coming though corba*/
int applet_button_press_event(int id, int button);
/*this is in main.c*/
void load_applet(char *id, char *params, int pos, int panel);
void reparent_window_id (unsigned long id);
END_GNOME_DECLS
#endif
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