Commit f8b7c5ee authored by Mark McLoughlin's avatar Mark McLoughlin Committed by Mark McLoughlin

impl.

2001-11-19  Mark McLoughlin  <mark@skynet.ie>

        * panel-applet-frame.[ch]:
        (panel_applet_frame_change_background),
        (panel_applet_frame_change_background_pixmap),
        (panel_applet_frame_change_background_colour),
        (panel_applet_frame_clear_background): impl.

        * panel-applet-shell.c:
        (impl_GNOME_PanelAppletShell_changeBackground): impl.
        (panel_applet_shell_class_init): upd.

        * panel-applet.[ch], panel-applet-private.h:
        (panel_applet_set_background_colour),
        (panel_applet_set_background_pixmap),
        (panel_applet_clear_background): impl.
        (panel_applet_class_init): register "change_background"
        signal.

        * panel-marshal.list: add VOID:ENUM,POINTER,STRING.

        * panel.c: (back_change): update for bonobo applets.

        * test-bonobo-applet.c:
        (test_applet_handle_background_change): impl - just print out
        a message for now.
parent 6f0357bb
2001-11-19 Mark McLoughlin <mark@skynet.ie>
* panel-applet-frame.[ch]:
(panel_applet_frame_change_background),
(panel_applet_frame_change_background_pixmap),
(panel_applet_frame_change_background_colour),
(panel_applet_frame_clear_background): impl.
* panel-applet-shell.c:
(impl_GNOME_PanelAppletShell_changeBackground): impl.
(panel_applet_shell_class_init): upd.
* panel-applet.[ch], panel-applet-private.h:
(panel_applet_set_background_colour),
(panel_applet_set_background_pixmap),
(panel_applet_clear_background): impl.
(panel_applet_class_init): register "change_background"
signal.
* panel-marshal.list: add VOID:ENUM,POINTER,STRING.
* panel.c: (back_change): update for bonobo applets.
* test-bonobo-applet.c:
(test_applet_handle_background_change): impl - just print out
a message for now.
2001-11-19 Mark McLoughlin <mark@skynet.ie>
* panel-widget.c (panel_widget_class_init): give proper GType
......
......@@ -125,6 +125,62 @@ panel_applet_frame_change_size (PanelAppletFrame *frame,
CORBA_exception_free (&env);
}
static void
panel_applet_frame_change_background (PanelAppletFrame *frame,
GNOME_PanelBackground *background)
{
CORBA_Environment env;
CORBA_exception_init (&env);
GNOME_PanelAppletShell_changeBackground (frame->priv->applet_shell,
background,
&env);
if (BONOBO_EX (&env))
g_warning (_("Exception from changeBackground: '%s'\n"),
BONOBO_EX_REPOID (&env));
CORBA_exception_free (&env);
}
void
panel_applet_frame_change_background_pixmap (PanelAppletFrame *frame,
gchar *pixmap)
{
GNOME_PanelBackground background;
background._d = GNOME_PIXMAP;
background._u.pixmap = pixmap;
panel_applet_frame_change_background (frame, &background);
}
void
panel_applet_frame_change_background_colour (PanelAppletFrame *frame,
guint16 red,
guint16 green,
guint16 blue)
{
GNOME_PanelBackground background;
background._d = GNOME_COLOUR;
background._u.colour.red = red;
background._u.colour.green = green;
background._u.colour.blue = blue;
panel_applet_frame_change_background (frame, &background);
}
void
panel_applet_frame_clear_background (PanelAppletFrame *frame)
{
GNOME_PanelBackground background;
background._d = GNOME_NONE;
panel_applet_frame_change_background (frame, &background);
}
void
panel_applet_frame_set_info (PanelAppletFrame *frame,
AppletInfo *info)
......
......@@ -58,6 +58,17 @@ void panel_applet_frame_change_orient (PanelAppletFrame *frame,
void panel_applet_frame_change_size (PanelAppletFrame *frame,
PanelSize size);
void panel_applet_frame_change_background_pixmap (PanelAppletFrame *frame,
gchar *pixmap);
void panel_applet_frame_change_background_colour (PanelAppletFrame *frame,
guint16 red,
guint16 green,
guint16 blue);
void panel_applet_frame_clear_background (PanelAppletFrame *frame);
G_END_DECLS
#endif /* __PANEL_APPLET_CONTROL_H__ */
......@@ -20,6 +20,15 @@ void panel_applet_change_orient (PanelApplet *applet,
void panel_applet_change_size (PanelApplet *applet,
const gint size);
void panel_applet_set_background_colour (PanelApplet *applet,
GdkColor *colour);
void panel_applet_set_background_pixmap (PanelApplet *applet,
const gchar *pixmap);
void panel_applet_clear_background (PanelApplet *applet);
G_END_DECLS
#endif /* __PANEL_APPLET_PRIVATE_H__ */
......@@ -19,6 +19,39 @@ struct _PanelAppletShellPrivate {
static GObjectClass *parent_class = NULL;
static void
impl_GNOME_PanelAppletShell_changeBackground (PortableServer_Servant servant,
const GNOME_PanelBackground *background,
CORBA_Environment *ev)
{
PanelAppletShell *shell;
shell = PANEL_APPLET_SHELL (bonobo_object (servant));
switch (background->_d) {
case GNOME_NONE:
panel_applet_clear_background (shell->priv->applet);
break;
case GNOME_COLOUR: {
GdkColor colour;
colour.red = background->_u.colour.red;
colour.green = background->_u.colour.green;
colour.blue = background->_u.colour.blue;
panel_applet_set_background_colour (shell->priv->applet, &colour);
}
break;
case GNOME_PIXMAP:
panel_applet_set_background_pixmap (shell->priv->applet,
background->_u.pixmap);
break;
default:
g_assert_not_reached ();
break;
}
}
static void
impl_GNOME_PanelAppletShell_changeOrientation (PortableServer_Servant servant,
GNOME_PanelOrient orient,
......@@ -63,6 +96,7 @@ panel_applet_shell_class_init (PanelAppletShellClass *klass)
klass->epv.changeOrientation = impl_GNOME_PanelAppletShell_changeOrientation;
klass->epv.changeSize = impl_GNOME_PanelAppletShell_changeSize;
klass->epv.changeBackground = impl_GNOME_PanelAppletShell_changeBackground;
object_class->finalize = panel_applet_shell_finalize;
......
......@@ -32,6 +32,7 @@ static GObjectClass *parent_class;
enum {
CHANGE_ORIENT,
CHANGE_SIZE,
CHANGE_BACKGROUND,
LAST_SIGNAL
};
......@@ -63,6 +64,33 @@ panel_applet_change_size (PanelApplet *applet,
}
}
void
panel_applet_set_background_colour (PanelApplet *applet,
GdkColor *colour)
{
g_signal_emit (G_OBJECT (applet),
panel_applet_signals [CHANGE_BACKGROUND],
0, PANEL_COLOUR_BACKGROUND, colour, NULL);
}
void
panel_applet_set_background_pixmap (PanelApplet *applet,
const gchar *pixmap)
{
g_signal_emit (G_OBJECT (applet),
panel_applet_signals [CHANGE_BACKGROUND],
0, PANEL_PIXMAP_BACKGOUND, NULL, pixmap);
}
void
panel_applet_clear_background (PanelApplet *applet)
{
g_signal_emit (G_OBJECT (applet),
panel_applet_signals [CHANGE_BACKGROUND],
0, PANEL_NO_BACKGROUND, NULL, NULL);
}
void
panel_applet_setup_menu (PanelApplet *applet,
const gchar *xml,
......@@ -188,6 +216,20 @@ panel_applet_class_init (PanelAppletClass *klass,
G_TYPE_NONE,
1,
G_TYPE_INT);
panel_applet_signals [CHANGE_BACKGROUND] =
g_signal_new ("change_background",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (PanelAppletClass, change_background),
NULL,
NULL,
panel_marshal_VOID__ENUM_POINTER_STRING,
G_TYPE_NONE,
3,
PANEL_TYPE_G_NOME__PANEL_BACKGROUND_TYPE,
G_TYPE_POINTER,
G_TYPE_STRING);
}
static void
......
......@@ -27,6 +27,12 @@ typedef GNOME_PanelOrient PanelAppletOrient;
#define PANEL_APPLET_ORIENT_LEFT GNOME_ORIENT_UP
#define PANEL_APPLET_ORIENT_RIGHT GNOME_ORIENT_UP
typedef GNOME_PanelBackgroundType PanelBackgroundType;
#define PANEL_NO_BACKGROUND GNOME_NONE
#define PANEL_COLOUR_BACKGROUND GNOME_COLOUR
#define PANEL_PIXMAP_BACKGOUND GNOME_PIXMAP
#define PANEL_TYPE_APPLET (panel_applet_get_type ())
#define PANEL_APPLET(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PANEL_TYPE_APPLET, PanelApplet))
......@@ -39,7 +45,6 @@ typedef struct _PanelApplet PanelApplet;
typedef struct _PanelAppletClass PanelAppletClass;
typedef struct _PanelAppletPrivate PanelAppletPrivate;
struct _PanelApplet {
GtkEventBox event_box;
......@@ -54,6 +59,11 @@ struct _PanelAppletClass {
void (*change_size) (PanelApplet *applet,
gint size);
void (*change_background) (PanelApplet *applet,
PanelBackgroundType type,
GdkColor colour,
const gchar *pixmap);
};
GType panel_applet_get_type (void) G_GNUC_CONST;
......
VOID:ENUM,POINTER,POINTER
VOID:ENUM,POINTER,STRING
VOID:ENUM
VOID:INT
......@@ -315,19 +315,51 @@ panel_size_change(GtkWidget *widget,
}
void
back_change (AppletInfo *info, PanelWidget *panel)
back_change (AppletInfo *info,
PanelWidget *panel)
{
if (info->type == APPLET_EXTERN)
switch (info->type) {
case APPLET_EXTERN:
extern_handle_back_change ((Extern)info->data, panel);
break;
case APPLET_BONOBO: {
PanelAppletFrame *frame = PANEL_APPLET_FRAME (info->data);
switch (panel->back_type) {
case PANEL_BACK_PIXMAP:
panel_applet_frame_change_background_pixmap (frame,
panel->back_pixmap);
break;
case PANEL_BACK_COLOR:
panel_applet_frame_change_background_colour (frame,
panel->back_color.red,
panel->back_color.green,
panel->back_color.blue);
break;
case PANEL_BACK_NONE:
panel_applet_frame_clear_background (frame);
break;
default:
g_assert_not_reached ();
break;
}
}
break;
default:
break;
}
}
static void
back_change_foreach(GtkWidget *w, gpointer data)
back_change_foreach (GtkWidget *widget,
PanelWidget *panel)
{
AppletInfo *info = gtk_object_get_data(GTK_OBJECT(w), "applet_info");
PanelWidget *panel = data;
AppletInfo *info;
info = gtk_object_get_data (GTK_OBJECT (widget), "applet_info");
back_change(info,panel);
back_change (info, panel);
}
static void
......@@ -336,7 +368,9 @@ panel_back_change(GtkWidget *widget,
char *pixmap,
GdkColor *color)
{
gtk_container_foreach(GTK_CONTAINER(widget),back_change_foreach,widget);
gtk_container_foreach (GTK_CONTAINER (widget),
(GtkCallback) back_change_foreach,
widget);
panels_to_sync = TRUE;
/*update the configuration box if it is displayed*/
......
......@@ -101,6 +101,30 @@ test_applet_handle_size_change (PanelApplet *applet,
}
}
static void
test_applet_handle_background_change (PanelApplet *applet,
PanelBackgroundType type,
GdkColor *colour,
const gchar *pixmap,
GtkLabel *label)
{
switch (type) {
case PANEL_NO_BACKGROUND:
g_message ("Setting background to default");
break;
case PANEL_COLOUR_BACKGROUND:
g_message ("Setting background to #%2x%2x%2x",
colour->red, colour->green, colour->blue);
break;
case PANEL_PIXMAP_BACKGOUND:
g_message ("Setting background to '%s'", pixmap);
break;
default:
g_assert_not_reached ();
break;
}
}
static BonoboObject *
test_applet_new (const gchar *iid)
{
......@@ -126,6 +150,11 @@ test_applet_new (const gchar *iid)
"change_size",
(GCallback) test_applet_handle_size_change,
label);
g_signal_connect (G_OBJECT (applet),
"change_background",
(GCallback) test_applet_handle_background_change,
label);
return BONOBO_OBJECT (panel_applet_get_control (applet));
}
......
......@@ -20,6 +20,15 @@ void panel_applet_change_orient (PanelApplet *applet,
void panel_applet_change_size (PanelApplet *applet,
const gint size);
void panel_applet_set_background_colour (PanelApplet *applet,
GdkColor *colour);
void panel_applet_set_background_pixmap (PanelApplet *applet,
const gchar *pixmap);
void panel_applet_clear_background (PanelApplet *applet);
G_END_DECLS
#endif /* __PANEL_APPLET_PRIVATE_H__ */
......@@ -19,6 +19,39 @@ struct _PanelAppletShellPrivate {
static GObjectClass *parent_class = NULL;
static void
impl_GNOME_PanelAppletShell_changeBackground (PortableServer_Servant servant,
const GNOME_PanelBackground *background,
CORBA_Environment *ev)
{
PanelAppletShell *shell;
shell = PANEL_APPLET_SHELL (bonobo_object (servant));
switch (background->_d) {
case GNOME_NONE:
panel_applet_clear_background (shell->priv->applet);
break;
case GNOME_COLOUR: {
GdkColor colour;
colour.red = background->_u.colour.red;
colour.green = background->_u.colour.green;
colour.blue = background->_u.colour.blue;
panel_applet_set_background_colour (shell->priv->applet, &colour);
}
break;
case GNOME_PIXMAP:
panel_applet_set_background_pixmap (shell->priv->applet,
background->_u.pixmap);
break;
default:
g_assert_not_reached ();
break;
}
}
static void
impl_GNOME_PanelAppletShell_changeOrientation (PortableServer_Servant servant,
GNOME_PanelOrient orient,
......@@ -63,6 +96,7 @@ panel_applet_shell_class_init (PanelAppletShellClass *klass)
klass->epv.changeOrientation = impl_GNOME_PanelAppletShell_changeOrientation;
klass->epv.changeSize = impl_GNOME_PanelAppletShell_changeSize;
klass->epv.changeBackground = impl_GNOME_PanelAppletShell_changeBackground;
object_class->finalize = panel_applet_shell_finalize;
......
......@@ -32,6 +32,7 @@ static GObjectClass *parent_class;
enum {
CHANGE_ORIENT,
CHANGE_SIZE,
CHANGE_BACKGROUND,
LAST_SIGNAL
};
......@@ -63,6 +64,33 @@ panel_applet_change_size (PanelApplet *applet,
}
}
void
panel_applet_set_background_colour (PanelApplet *applet,
GdkColor *colour)
{
g_signal_emit (G_OBJECT (applet),
panel_applet_signals [CHANGE_BACKGROUND],
0, PANEL_COLOUR_BACKGROUND, colour, NULL);
}
void
panel_applet_set_background_pixmap (PanelApplet *applet,
const gchar *pixmap)
{
g_signal_emit (G_OBJECT (applet),
panel_applet_signals [CHANGE_BACKGROUND],
0, PANEL_PIXMAP_BACKGOUND, NULL, pixmap);
}
void
panel_applet_clear_background (PanelApplet *applet)
{
g_signal_emit (G_OBJECT (applet),
panel_applet_signals [CHANGE_BACKGROUND],
0, PANEL_NO_BACKGROUND, NULL, NULL);
}
void
panel_applet_setup_menu (PanelApplet *applet,
const gchar *xml,
......@@ -188,6 +216,20 @@ panel_applet_class_init (PanelAppletClass *klass,
G_TYPE_NONE,
1,
G_TYPE_INT);
panel_applet_signals [CHANGE_BACKGROUND] =
g_signal_new ("change_background",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (PanelAppletClass, change_background),
NULL,
NULL,
panel_marshal_VOID__ENUM_POINTER_STRING,
G_TYPE_NONE,
3,
PANEL_TYPE_G_NOME__PANEL_BACKGROUND_TYPE,
G_TYPE_POINTER,
G_TYPE_STRING);
}
static void
......
......@@ -27,6 +27,12 @@ typedef GNOME_PanelOrient PanelAppletOrient;
#define PANEL_APPLET_ORIENT_LEFT GNOME_ORIENT_UP
#define PANEL_APPLET_ORIENT_RIGHT GNOME_ORIENT_UP
typedef GNOME_PanelBackgroundType PanelBackgroundType;
#define PANEL_NO_BACKGROUND GNOME_NONE
#define PANEL_COLOUR_BACKGROUND GNOME_COLOUR
#define PANEL_PIXMAP_BACKGOUND GNOME_PIXMAP
#define PANEL_TYPE_APPLET (panel_applet_get_type ())
#define PANEL_APPLET(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PANEL_TYPE_APPLET, PanelApplet))
......@@ -39,7 +45,6 @@ typedef struct _PanelApplet PanelApplet;
typedef struct _PanelAppletClass PanelAppletClass;
typedef struct _PanelAppletPrivate PanelAppletPrivate;
struct _PanelApplet {
GtkEventBox event_box;
......@@ -54,6 +59,11 @@ struct _PanelAppletClass {
void (*change_size) (PanelApplet *applet,
gint size);
void (*change_background) (PanelApplet *applet,
PanelBackgroundType type,
GdkColor colour,
const gchar *pixmap);
};
GType panel_applet_get_type (void) G_GNUC_CONST;
......
......@@ -101,6 +101,30 @@ test_applet_handle_size_change (PanelApplet *applet,
}
}
static void
test_applet_handle_background_change (PanelApplet *applet,
PanelBackgroundType type,
GdkColor *colour,
const gchar *pixmap,
GtkLabel *label)
{
switch (type) {
case PANEL_NO_BACKGROUND:
g_message ("Setting background to default");
break;
case PANEL_COLOUR_BACKGROUND:
g_message ("Setting background to #%2x%2x%2x",
colour->red, colour->green, colour->blue);
break;
case PANEL_PIXMAP_BACKGOUND:
g_message ("Setting background to '%s'", pixmap);
break;
default:
g_assert_not_reached ();
break;
}
}
static BonoboObject *
test_applet_new (const gchar *iid)
{
......@@ -126,6 +150,11 @@ test_applet_new (const gchar *iid)
"change_size",
(GCallback) test_applet_handle_size_change,
label);
g_signal_connect (G_OBJECT (applet),
"change_background",
(GCallback) test_applet_handle_background_change,
label);
return BONOBO_OBJECT (panel_applet_get_control (applet));
}
......
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