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

implement the status applet at least in theory, it doesn't have the client

Mon Sep 27 22:54:49 1999  George Lebl  <jirka@5z.com>

        * status.[ch],session.c,menu.c,applet.h: implement the status applet
          at least in theory, it doesn't have the client lib (widget)
          written yet

        * launcher.c: use stock button for error dialog
parent 32741bef
Mon Sep 27 22:54:49 1999 George Lebl <jirka@5z.com>
* status.[ch],session.c,menu.c,applet.h: implement the status applet
at least in theory, it doesn't have the client lib (widget)
written yet
* launcher.c: use stock button for error dialog
1999-09-27 Jacob Berkman <jberkman@andrew.cmu.edu>
* panel_config_global.c (icon_notebook_page): fix the
......
Mon Sep 27 22:54:49 1999 George Lebl <jirka@5z.com>
* status.[ch],session.c,menu.c,applet.h: implement the status applet
at least in theory, it doesn't have the client lib (widget)
written yet
* launcher.c: use stock button for error dialog
1999-09-27 Jacob Berkman <jberkman@andrew.cmu.edu>
* panel_config_global.c (icon_notebook_page): fix the
......
......@@ -14,6 +14,7 @@ BEGIN_GNOME_DECLS
#define EXTERN_ID "Extern"
#define LAUNCHER_ID "Launcher"
#define LOCK_ID "Lock"
#define STATUS_ID "Status"
typedef enum {
APPLET_EXTERN,
......@@ -26,6 +27,7 @@ typedef enum {
APPLET_LAUNCHER,
APPLET_EMPTY,
APPLET_LOCK,
APPLET_STATUS
} AppletType;
typedef struct _AppletUserMenu AppletUserMenu;
......
......@@ -47,7 +47,8 @@ launch (Launcher *launcher, int argc, char *argv[])
dlg = gnome_message_box_new(_("This launch icon does not "
"specify a program to run"),
GNOME_MESSAGE_BOX_ERROR,
_("Close"), NULL);
GNOME_STOCK_BUTTON_CLOSE,
NULL);
gtk_window_set_wmclass(GTK_WINDOW(dlg),
"no_exec_dialog","Panel");
gtk_widget_show_all(dlg);
......
......@@ -1110,6 +1110,22 @@ add_lock_to_panel (GtkWidget *widget, gpointer data)
{
load_lock_applet(current_panel, 0);
}
static void
try_add_status_to_panel (GtkWidget *widget, gpointer data)
{
if(!load_status_applet(current_panel, 0)) {
GtkWidget *mbox;
mbox = gnome_message_box_new(_("You already have a status "
"dock on the panel. You can "
"only have one"),
GNOME_MESSAGE_BOX_INFO,
GNOME_STOCK_BUTTON_CLOSE,
NULL);
gtk_window_set_wmclass(GTK_WINDOW(mbox),
"no_more_status_dialog","Panel");
gtk_widget_show_all(mbox);
}
}
static void
add_applet (GtkWidget *w, char *item_loc)
......@@ -2780,6 +2796,13 @@ make_add_submenu (GtkWidget *menu, int fake_submenus)
gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
GTK_SIGNAL_FUNC(ask_about_swallowing_cb),NULL);
setup_internal_applet_drag(menuitem, "SWALLOW:ASK");
menuitem = gtk_menu_item_new ();
setup_menuitem(menuitem, 0, _("Status dock"));
gtk_menu_append (GTK_MENU (menu), menuitem);
gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
GTK_SIGNAL_FUNC(try_add_status_to_panel),NULL);
setup_internal_applet_drag(menuitem, "STATUS:TRY");
}
void
......
......@@ -163,6 +163,10 @@ orientation_change(AppletInfo *info, PanelWidget *panel)
set_swallow_applet_orient(swallow,SWALLOW_VERTICAL);
else
set_swallow_applet_orient(swallow,SWALLOW_HORIZONTAL);
} else if(info->type == APPLET_STATUS) {
StatusApplet *status = info->data;
status->orient = panel->orient;
status_applet_update(status);
}
}
......@@ -245,6 +249,10 @@ size_change(AppletInfo *info, PanelWidget *panel)
panel_clean_applet(ext->info);
CORBA_exception_free(&ev);
}
} else if(info->type == APPLET_STATUS) {
StatusApplet *status = info->data;
status->orient = panel->orient;
status_applet_update(status);
}
}
......@@ -824,6 +832,8 @@ panel_widget_dnd_drop_internal (GtkWidget *widget,
ask_about_swallowing(panel,pos);
} else if(strcmp(applet_type,"LAUNCHER:ASK")==0) {
ask_about_launcher(NULL,panel,pos);
} else if(strcmp(applet_type,"STATUS:TRY")==0) {
load_status_applet(panel,pos);
}
break;
}
......
......@@ -369,6 +369,9 @@ save_applet_configuration(AppletInfo *info)
case APPLET_LOCK:
gnome_config_set_string("id", LOCK_ID);
break;
case APPLET_STATUS:
gnome_config_set_string("id", STATUS_ID);
break;
default:
g_assert_not_reached();
}
......@@ -841,6 +844,8 @@ init_user_applets(void)
load_logout_applet(panel,pos);
} else if(strcmp(applet_name,LOCK_ID) == 0) {
load_lock_applet(panel,pos);
} else if(strcmp(applet_name,STATUS_ID) == 0) {
load_status_applet(panel,pos);
} else if(strcmp(applet_name,SWALLOW_ID) == 0) {
char *path = gnome_config_get_string("execpath=");
char *params = gnome_config_get_string("parameters=");
......
......@@ -13,30 +13,202 @@
#include "panel-include.h"
#include "gnome-panel.h"
static Status *the_status = NULL; /*"there can only be one" status applet*/
static StatusApplet *the_status = NULL; /*"there can only be one" status applet*/
static GtkWidget *offscreen = NULL; /*offscreen window for putting status
spots if there is no status applet*/
static GSList *spots;
static GtkWidget *fixed = NULL; /*the fixed container in which the docklets reside*/
static GSList *spots = NULL;
static int nspots = 0;
extern GSList *applets;
extern GSList *applets_last;
extern int applet_count;
#define DOCKLET_SPOT 22
void
status_applet_update(StatusApplet *s)
{
GSList *li;
int w,h;
int sz;
int rows;
int i,j;
if(s->orient == PANEL_HORIZONTAL)
GTK_HANDLE_BOX(s->handle)->handle_position = GTK_POS_LEFT;
else
GTK_HANDLE_BOX(s->handle)->handle_position = GTK_POS_TOP;
switch(s->size) {
case SIZE_TINY: sz = 24; break;
case SIZE_STANDARD: sz = 48; break;
case SIZE_LARGE: sz = 64; break;
case SIZE_HUGE: sz = 80; break;
default: sz = 48; break;
}
rows = sz/DOCKLET_SPOT;
if(nspots%rows == 0)
w = DOCKLET_SPOT*(nspots/rows);
else
w = DOCKLET_SPOT*(nspots/rows)+1;
/*make minimum size*/
if(w==0) w = 10;
h = DOCKLET_SPOT*rows;
/*if we are vertical just switch stuff around*/
if(s->orient == PANEL_VERTICAL) {
int t = w;
w = h;
h = t;
}
gtk_widget_set_usize(fixed,w,h);
i = j = 0;
for(li = spots; li; li = li->next) {
StatusSpot *ss = li->data;
gtk_fixed_move(GTK_FIXED(fixed),ss->socket,i,j);
i+=DOCKLET_SPOT;
if(i>=w) {
i = 0;
j+=DOCKLET_SPOT;
}
}
gtk_widget_queue_resize(s->handle);
}
static void
status_socket_destroyed(GtkWidget *w, StatusSpot *ss)
{
status_spot_remove(ss);
}
StatusSpot *
new_status_spot(void)
{
StatusSpot *ss = g_new0(StatusSpot,1);
/*FIXME: get some sort of socket out there! if there is no status applet,
just make an offscreen window for it*/
ss->wid = 0;
spots = g_slist_prepend(spots,ss);
nspots++;
ss->socket = gtk_socket_new();
gtk_widget_set_usize(ss->socket,DOCKLET_SPOT,DOCKLET_SPOT);
if(!the_status && !offscreen) {
offscreen = gtk_window_new(GTK_WINDOW_POPUP);
gtk_widget_set_uposition(offscreen,gdk_screen_width()+10,
gdk_screen_height()+10);
/*it should be null at this point*/
g_assert(!fixed);
fixed = gtk_fixed_new();
gtk_widget_show(fixed);
gtk_container_add(GTK_CONTAINER(offscreen),fixed);
gtk_fixed_put(GTK_FIXED(fixed),ss->socket,0,0);
gtk_widget_show_now(offscreen);
} else {
gtk_fixed_put(GTK_FIXED(fixed),ss->socket,0,0);
status_applet_update(the_status);
}
gtk_widget_show_now(ss->socket);
gtk_signal_connect(GTK_OBJECT(ss->socket),"destroy",
GTK_SIGNAL_FUNC(status_socket_destroyed),
ss);
if(GTK_WIDGET_REALIZED(ss->socket))
g_warning("DEBUG: BLAHBLAHBLAH");
ss->wid = GDK_WINDOW_XWINDOW(ss->socket->window);
return ss;
}
void
status_spot_remove(StatusSpot *ss)
{
/*FIXME: fill in*/
CORBA_Environment ev;
spots = g_slist_remove(spots,ss);
nspots--;
gtk_widget_destroy(ss->socket);
CORBA_exception_init(&ev);
CORBA_Object_release(ss->sspot, &ev);
POA_GNOME_StatusSpot__fini((PortableServer_Servant) ss, &ev);
CORBA_exception_free(&ev);
g_free(ss);
if(the_status) status_applet_update(the_status);
}
void
static int
ignore_1st_click(GtkWidget *widget, GdkEvent *event)
{
GdkEventButton *buttonevent = (GdkEventButton *)event;
if (event->type == GDK_BUTTON_PRESS &&
buttonevent->button == 1) {
return TRUE;
}
if (event->type == GDK_BUTTON_RELEASE &&
buttonevent->button == 1) {
return TRUE;
}
return FALSE;
}
static void
applet_destroy(GtkWidget *w, StatusApplet *s)
{
if(!offscreen) {
offscreen = gtk_window_new(GTK_WINDOW_POPUP);
gtk_widget_set_uposition(offscreen,gdk_screen_width()+10,
gdk_screen_height()+10);
gtk_widget_show_now(offscreen);
}
gtk_widget_reparent(fixed,offscreen);
g_free(s);
the_status = NULL;
}
int
load_status_applet(PanelWidget *panel, int pos)
{
/*FIXME: fill in*/
if(the_status)
return FALSE;
the_status = g_new0(StatusApplet,1);
the_status->frame = gtk_frame_new(NULL);
the_status->orient = panel->orient;
the_status->size = panel->sz;
gtk_frame_set_shadow_type(GTK_FRAME(the_status->frame),
GTK_SHADOW_IN);
the_status->handle = gtk_handle_box_new();
gtk_signal_connect(GTK_OBJECT(the_status->handle), "event",
GTK_SIGNAL_FUNC(ignore_1st_click), NULL);
gtk_container_add(GTK_CONTAINER(the_status->handle),
the_status->frame);
gtk_signal_connect(GTK_OBJECT(the_status->handle), "destroy",
GTK_SIGNAL_FUNC(applet_destroy), the_status);
if(!fixed) {
fixed = gtk_fixed_new();
gtk_container_add(GTK_CONTAINER(the_status->frame),fixed);
} else {
gtk_widget_reparent(fixed,the_status->frame);
}
status_applet_update(the_status);
register_toy(the_status->handle,the_status, panel, pos, APPLET_STATUS);
the_status->info = applets_last->data;
return TRUE;
}
......@@ -3,6 +3,7 @@
#include <gnome.h>
#include "panel.h"
#include "panel-types.h"
#include "panel-widget.h"
#include "gnome-panel.h"
......@@ -13,7 +14,10 @@ BEGIN_GNOME_DECLS
/*XXX we get some sore of conflict if we just use Status*/
typedef struct _StatusApplet StatusApplet;
struct _StatusApplet {
GtkWidget *table;
GtkWidget *frame;
GtkWidget *handle; /*a gtk handlebox but one that doesn't undock*/
PanelOrientation orient;
PanelSizeType size;
AppletInfo *info;
};
......@@ -21,13 +25,17 @@ typedef struct _StatusSpot StatusSpot;
struct _StatusSpot {
POA_GNOME_StatusSpot servant;
GNOME_StatusSpot sspot;
GtkWidget *socket;
gulong wid;
};
StatusSpot *new_status_spot(void);
void status_spot_remove(StatusSpot *ss);
void load_status_applet(PanelWidget *panel, int pos);
/*returns TRUE if it could create an applet, FALSE if one already exists*/
int load_status_applet(PanelWidget *panel, int pos);
void status_applet_update(StatusApplet *s);
END_GNOME_DECLS
......
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