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

extend swallows to make them far more usable then they were until now, now

Tue Jul 14 03:03:30 1998  George Lebl  <jirka@5z.com>

        * swallow.[ch],main.c,panel.c: extend swallows to make them far
          more usable then they were until now, now has the ability to
          launch the app ... and to set the size of the swallow applet
parent b0084d59
Tue Jul 14 03:03:30 1998 George Lebl <jirka@5z.com>
* swallow.[ch],main.c,panel.c: extend swallows to make them far
more usable then they were until now, now has the ability to
launch the app ... and to set the size of the swallow applet
Mon Jul 13 00:34:09 1998 George Lebl <jirka@5z.com>
* panel.c: remove applets from their eventboxes thus destroying
......
Tue Jul 14 03:03:30 1998 George Lebl <jirka@5z.com>
* swallow.[ch],main.c,panel.c: extend swallows to make them far
more usable then they were until now, now has the ability to
launch the app ... and to set the size of the swallow applet
Mon Jul 13 00:34:09 1998 George Lebl <jirka@5z.com>
* panel.c: remove applets from their eventboxes thus destroying
......
......@@ -76,6 +76,8 @@ struct _LoadApplet {
char *id_str;
char *path;
char *params;
int width;
int height;
char *pixmap;
char *tooltip;
int pos;
......@@ -265,7 +267,7 @@ get_def_panel_widget(GtkWidget *panel)
static void
queue_load_applet(char *id_str, char *path, char *params,
queue_load_applet(char *id_str, char *path, char *params, int width, int height,
char *pixmap, char *tooltip,
int pos, PanelWidget *panel, char *cfgpath)
{
......@@ -276,6 +278,8 @@ queue_load_applet(char *id_str, char *path, char *params,
if(path) l->path=g_strdup(path);
else l->path = NULL;
l->params=g_strdup(params);
l->width=width;
l->height=height;
l->pixmap=g_strdup(pixmap);
l->tooltip=g_strdup(tooltip);
l->pos=pos;
......@@ -441,7 +445,7 @@ drawer_realize_cb(GtkWidget *button, Drawer *drawer)
void
load_applet(char *id_str, char *path, char *params,
load_applet(char *id_str, char *path, char *params, int width, int height,
char *pixmap, char *tooltip,
int pos, PanelWidget *panel, char *cfgpath)
{
......@@ -599,12 +603,20 @@ load_applet(char *id_str, char *path, char *params,
} else if(strcmp(id_str,SWALLOW_ID) == 0) {
Swallow *swallow;
swallow = create_swallow_applet(params, SWALLOW_HORIZONTAL);
if(swallow)
register_toy(swallow->table,NULL,swallow,SWALLOW_ID,
NULL, params,pos, panel,NULL,
APPLET_SWALLOW);
swallow = create_swallow_applet(params, width, height,
SWALLOW_HORIZONTAL);
if(!swallow)
return;
register_toy(swallow->table,NULL,swallow,SWALLOW_ID,
path, params,pos, panel,NULL,
APPLET_SWALLOW);
if(path && *path) {
char *s = g_copy_strings("(true; ",path," &)",NULL);
system(s);
g_free(s);
}
} else if(strcmp(id_str,LOGOUT_ID) == 0) {
GtkWidget *logout;
......@@ -623,7 +635,7 @@ load_queued_applets(void)
for(list = load_queue;list!=NULL;list=g_list_next(list)) {
LoadApplet *l=list->data;
load_applet(l->id_str,l->path,l->params,
load_applet(l->id_str,l->path,l->params,l->width,l->height,
l->pixmap,l->tooltip,
l->pos,l->panel,l->cfgpath);
g_free(l->id_str);
......@@ -640,10 +652,10 @@ load_queued_applets(void)
static void
load_default_applets(void)
{
queue_load_applet(MENU_ID, NULL, ".", NULL, NULL,
PANEL_UNKNOWN_APPLET_POSITION, panels->data,NULL);
queue_load_applet(EXTERN_ID, "gen_util_applet", "--clock", NULL, NULL,
PANEL_UNKNOWN_APPLET_POSITION, panels->data,NULL);
queue_load_applet(MENU_ID,NULL,".",0,0,NULL,NULL,
PANEL_UNKNOWN_APPLET_POSITION,panels->data,NULL);
queue_load_applet(EXTERN_ID,"gen_util_applet","--clock",0,0,NULL,NULL,
PANEL_UNKNOWN_APPLET_POSITION,panels->data,NULL);
}
static void
......@@ -662,6 +674,7 @@ init_user_applets(void)
char *applet_pixmap;
char *applet_tooltip;
char *applet_path;
int applet_width,applet_height;
int pos=0,panel_num;
PanelWidget *panel;
......@@ -673,6 +686,8 @@ init_user_applets(void)
applet_params = gnome_config_get_string("parameters=");
applet_pixmap = gnome_config_get_string("pixmap=");
applet_tooltip = gnome_config_get_string("tooltip=");
applet_width = gnome_config_get_int("width=0");
applet_height = gnome_config_get_int("height=0");
g_snprintf(buf,256,"position=%d",
PANEL_UNKNOWN_APPLET_POSITION);
......@@ -699,6 +714,7 @@ init_user_applets(void)
loads*/
g_snprintf(buf,256,"%sApplet_%d/",old_panel_cfg_path,num);
queue_load_applet(applet_name, applet_path, applet_params,
applet_width,applet_height,
applet_pixmap, applet_tooltip,
pos, panel, buf);
......
......@@ -25,7 +25,7 @@ struct _PanelData {
just get the that one*/
PanelWidget * get_def_panel_widget(GtkWidget *panel);
void load_applet(char *id, char *path, char *params,
void load_applet(char *id, char *path, char *params, int width, int height,
char *pixmap, char *tooltip,
int pos, PanelWidget *panel, char *cfgpath);
void orientation_change(int applet_id, PanelWidget *panel);
......
......@@ -22,6 +22,7 @@
#include "main.h"
#include "panel_config_global.h"
#include "menu.h"
#include "swallow.h"
#include "mico-glue.h"
#define SMALL_ICON_SIZE 20
......@@ -58,7 +59,7 @@ struct _MenuFinfo {
/*???? this might be ugly, but I guess we can safely assume that we can only
have one menu open and that nothing weird will happen to the panel that
opened that menu whilethe user is looking over the choices*/
static PanelWidget *current_panel = NULL;
PanelWidget *current_panel = NULL;
/*the most important dialog in the whole application*/
void
......@@ -168,7 +169,8 @@ free_string (GtkWidget *widget, void *data)
static int
add_to_panel (char *applet, char *path, char *arg)
{
load_applet(applet,path,arg,NULL,NULL,PANEL_UNKNOWN_APPLET_POSITION,
load_applet(applet,path,arg,0,0,NULL,NULL,
PANEL_UNKNOWN_APPLET_POSITION,
current_panel,NULL);
return TRUE;
}
......@@ -730,75 +732,6 @@ add_applet_to_panel_data(GtkWidget *widget, gpointer data)
add_to_panel((char *)data, NULL, NULL);
}
#ifdef _SWALLOW_
static int
act_really_add_swallow(GtkWidget *w, gpointer data)
{
GtkWidget *entry = data;
GtkWidget *d = gtk_object_get_user_data(GTK_OBJECT(entry));
gtk_widget_hide(d);
add_to_panel(SWALLOW_ID, NULL, gtk_entry_get_text(GTK_ENTRY(entry)));
return TRUE;
}
static int
really_add_swallow(GtkWidget *d,int button, gpointer data)
{
GtkWidget *entry = data;
gtk_widget_hide(d);
if(button == 0)
add_to_panel(SWALLOW_ID, NULL,
gtk_entry_get_text(GTK_ENTRY(entry)));
return TRUE;
}
static void
add_swallow_to_panel(GtkWidget *widget, gpointer data)
{
static GtkWidget *d=NULL;
if(!d) {
GtkWidget *w;
GtkWidget *box;
d = gnome_dialog_new(_("Create swallow applet"),
GNOME_STOCK_BUTTON_OK,
GNOME_STOCK_BUTTON_CANCEL,
NULL);
box = gtk_hbox_new(FALSE,5);
gtk_widget_show(box);
gtk_box_pack_start(GTK_BOX(GNOME_DIALOG(d)->vbox),box,
TRUE,TRUE,5);
w = gtk_label_new(_("Title of application to swallow"));
gtk_widget_show(w);
gtk_box_pack_start(GTK_BOX(box),w,TRUE,TRUE,5);
w = gtk_entry_new();
gtk_widget_show(w);
gtk_box_pack_start(GTK_BOX(box),w,TRUE,TRUE,5);
gtk_object_set_user_data(GTK_OBJECT(w),d);
gtk_signal_connect(GTK_OBJECT(d),"clicked",
GTK_SIGNAL_FUNC(really_add_swallow),
w);
gtk_signal_connect(GTK_OBJECT(w),"activate",
GTK_SIGNAL_FUNC(act_really_add_swallow),
w);
gnome_dialog_close_hides(GNOME_DIALOG(d),TRUE);
gnome_dialog_set_default(GNOME_DIALOG(d),0);
gtk_widget_grab_focus(w);
}
gtk_widget_show(d);
}
#endif
static GtkWidget *
create_applets_menu(int fake_submenus)
{
......@@ -931,7 +864,7 @@ create_panel_submenu (GtkWidget *app_menu, GtkWidget *applet_menu)
setup_menuitem (menuitem, 0, _("Add swallowed app"));
gtk_menu_append (GTK_MENU (menu), menuitem);
gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
(GtkSignalFunc) add_swallow_to_panel,NULL);
(GtkSignalFunc) ask_about_swallowing,NULL);
#endif
add_menu_separator(menu);
......
......@@ -21,6 +21,7 @@
#include "menu.h"
#include "launcher.h"
#include "drawer.h"
#include "swallow.h"
#include "mulapp.h"
#include "mico-glue.h"
#include "panel_config.h"
......@@ -166,6 +167,14 @@ save_applet_configuration(AppletInfo *info, int *num)
drawer->pixmap);
gnome_config_set_string("config/tooltip",
drawer->tooltip);
} else if(strcmp(info->id_str,SWALLOW_ID) == 0) {
Swallow *swallow = info->data;
gnome_config_set_string("config/parameters",
info->params);
gnome_config_set_string("config/execpath",
info->path);
gnome_config_set_int("config/width",swallow->width);
gnome_config_set_int("config/height",swallow->height);
} else {
if(info->params)
gnome_config_set_string("config/parameters",
......@@ -1153,7 +1162,8 @@ panel_add_main_menu(GtkWidget *w, gpointer data)
{
PanelWidget *panel = get_def_panel_widget(data);
load_applet(MENU_ID,NULL,NULL,NULL,NULL,PANEL_UNKNOWN_APPLET_POSITION,
load_applet(MENU_ID,NULL,NULL,0,0,NULL,NULL,
PANEL_UNKNOWN_APPLET_POSITION,
panel,NULL);
}
......
......@@ -19,6 +19,8 @@
#include "swallow.h"
#include "mico-glue.h"
extern PanelWidget *current_panel;
static int
ignore_x_error(Display* d, XErrorEvent* e)
{
......@@ -97,8 +99,128 @@ socket_realized(GtkWidget *w, gpointer data)
return FALSE;
}
static int
socket_destroyed(GtkWidget *w, gpointer data)
{
Swallow *swallow = data;
g_free(swallow->title);
g_free(swallow);
return FALSE;
}
static void
really_add_swallow(GtkWidget *d,int button, gpointer data)
{
GtkWidget *title_e = gtk_object_get_data(GTK_OBJECT(d),"title_e");
GtkWidget *exec_e = gtk_object_get_data(GTK_OBJECT(d),"exec_e");
GtkWidget *width_s = gtk_object_get_data(GTK_OBJECT(d),"width_s");
GtkWidget *height_s = gtk_object_get_data(GTK_OBJECT(d),"height_s");
if(button!=0) {
gtk_widget_destroy(d);
return;
}
load_applet(SWALLOW_ID,
gtk_entry_get_text(GTK_ENTRY(exec_e)),
gtk_entry_get_text(GTK_ENTRY(title_e)),
gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(width_s)),
gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(height_s)),
NULL,NULL,
PANEL_UNKNOWN_APPLET_POSITION,
current_panel,NULL);
gtk_widget_destroy(d);
}
static void
act_really_add_swallow(GtkWidget *w, gpointer data)
{
GtkWidget *d = data;
/*just call the above handler for the dialog*/
really_add_swallow(d,0,NULL);
}
/*I couldn't resist the naming of this function*/
void
ask_about_swallowing(void)
{
GtkWidget *d;
GtkWidget *title_e;
GtkWidget *exec_e;
GtkWidget *width_s;
GtkWidget *height_s;
GtkWidget *w;
GtkWidget *box;
GtkAdjustment *adj;
d = gnome_dialog_new(_("Create swallow applet"),
GNOME_STOCK_BUTTON_OK,
GNOME_STOCK_BUTTON_CANCEL,
NULL);
box = gtk_hbox_new(FALSE,5);
gtk_box_pack_start(GTK_BOX(GNOME_DIALOG(d)->vbox),box,
TRUE,TRUE,5);
w = gtk_label_new(_("Title of application to swallow"));
gtk_box_pack_start(GTK_BOX(box),w,FALSE,FALSE,0);
w = gnome_entry_new("swallow_title");
gtk_box_pack_start(GTK_BOX(box),w,TRUE,TRUE,0);
title_e = gnome_entry_gtk_entry(GNOME_ENTRY(w));
gtk_signal_connect(GTK_OBJECT(title_e),"activate",
GTK_SIGNAL_FUNC(act_really_add_swallow),d);
box = gtk_hbox_new(FALSE,5);
gtk_box_pack_start(GTK_BOX(GNOME_DIALOG(d)->vbox),box,
TRUE,TRUE,5);
w = gtk_label_new(_("Command (optional)"));
gtk_box_pack_start(GTK_BOX(box),w,FALSE,FALSE,0);
w = gnome_file_entry_new("execute",_("Browse"));
gtk_box_pack_start(GTK_BOX(box),w,TRUE,TRUE,0);
exec_e = gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (w));
gtk_signal_connect(GTK_OBJECT(exec_e),"activate",
GTK_SIGNAL_FUNC(act_really_add_swallow),d);
box = gtk_hbox_new(FALSE,5);
gtk_box_pack_start(GTK_BOX(GNOME_DIALOG(d)->vbox),box,
TRUE,TRUE,5);
w = gtk_label_new(_("Width (optional)"));
gtk_box_pack_start(GTK_BOX(box),w,FALSE,FALSE,0);
adj = (GtkAdjustment *) gtk_adjustment_new (0.0, 0.0, 255.0, 1.0,
5.0, 0.0);
width_s = gtk_spin_button_new(adj,0,0);
gtk_box_pack_start(GTK_BOX(box),width_s,TRUE,TRUE,0);
w = gtk_label_new(_("Height (optional)"));
gtk_box_pack_start(GTK_BOX(box),w,FALSE,FALSE,0);
adj = (GtkAdjustment *) gtk_adjustment_new (0.0, 0.0, 255.0, 1.0,
5.0, 0.0);
height_s = gtk_spin_button_new(adj,0,0);
gtk_box_pack_start(GTK_BOX(box),height_s,TRUE,TRUE,0);
gtk_signal_connect(GTK_OBJECT(d),"clicked",
GTK_SIGNAL_FUNC(really_add_swallow),NULL);
gtk_object_set_data(GTK_OBJECT(d),"title_e",title_e);
gtk_object_set_data(GTK_OBJECT(d),"exec_e",exec_e);
gtk_object_set_data(GTK_OBJECT(d),"width_s",width_s);
gtk_object_set_data(GTK_OBJECT(d),"height_s",height_s);
gnome_dialog_close_hides(GNOME_DIALOG(d),FALSE);
gnome_dialog_set_default(GNOME_DIALOG(d),0);
gtk_widget_grab_focus(title_e);
gtk_widget_show_all(d);
}
Swallow *
create_swallow_applet(char *arguments, SwallowOrient orient)
create_swallow_applet(char *title, int width, int height, SwallowOrient orient)
{
Swallow *swallow;
GtkWidget *w;
......@@ -116,14 +238,17 @@ create_swallow_applet(char *arguments, SwallowOrient orient)
0,0);
w = gtk_frame_new(NULL);
gtk_widget_set_usize(w,48,0);
gtk_frame_set_shadow_type(GTK_FRAME(w),GTK_SHADOW_OUT);
gtk_box_pack_start(GTK_BOX(swallow->handle_n),w,TRUE,TRUE,0);
gtk_widget_show(w);
w = gtk_frame_new(NULL);
gtk_widget_set_usize(w,48,0);
gtk_frame_set_shadow_type(GTK_FRAME(w),GTK_SHADOW_OUT);
gtk_box_pack_start(GTK_BOX(swallow->handle_n),w,TRUE,TRUE,0);
gtk_widget_show(w);
w = gtk_frame_new(NULL);
gtk_widget_set_usize(w,48,0);
gtk_frame_set_shadow_type(GTK_FRAME(w),GTK_SHADOW_OUT);
gtk_box_pack_start(GTK_BOX(swallow->handle_n),w,TRUE,TRUE,0);
gtk_widget_show(w);
......@@ -136,21 +261,28 @@ create_swallow_applet(char *arguments, SwallowOrient orient)
0,0);
w = gtk_frame_new(NULL);
gtk_widget_set_usize(w,0,48);
gtk_frame_set_shadow_type(GTK_FRAME(w),GTK_SHADOW_OUT);
gtk_box_pack_start(GTK_BOX(swallow->handle_w),w,TRUE,TRUE,0);
gtk_widget_show(w);
w = gtk_frame_new(NULL);
gtk_widget_set_usize(w,0,48);
gtk_frame_set_shadow_type(GTK_FRAME(w),GTK_SHADOW_OUT);
gtk_box_pack_start(GTK_BOX(swallow->handle_w),w,TRUE,TRUE,0);
gtk_widget_show(w);
w = gtk_frame_new(NULL);
gtk_widget_set_usize(w,0,48);
gtk_frame_set_shadow_type(GTK_FRAME(w),GTK_SHADOW_OUT);
gtk_box_pack_start(GTK_BOX(swallow->handle_w),w,TRUE,TRUE,0);
gtk_widget_show(w);
swallow->socket=gtk_socket_new();
if(width != 0 || height != 0)
gtk_widget_set_usize(swallow->socket,width,height);
gtk_signal_connect_after(GTK_OBJECT(swallow->socket),"realize",
GTK_SIGNAL_FUNC(socket_realized), NULL);
gtk_signal_connect_after(GTK_OBJECT(swallow->socket),"destroy",
GTK_SIGNAL_FUNC(socket_destroyed), swallow);
gtk_table_attach(GTK_TABLE(swallow->table),swallow->socket,
1,2,1,2,
......@@ -162,10 +294,9 @@ create_swallow_applet(char *arguments, SwallowOrient orient)
gtk_object_set_user_data(GTK_OBJECT(swallow->socket),swallow);
if(arguments)
swallow->title=g_strdup(arguments);
else
swallow->title=NULL;
swallow->title = g_strdup(title);
swallow->width = width;
swallow->height = height;
swallow->wid = -1;
set_swallow_applet_orient(swallow, orient);
......
......@@ -14,13 +14,19 @@ typedef struct {
GtkWidget *handle_w;
GtkWidget *socket;
char *title;
int width;
int height;
guint32 wid;
} Swallow;
Swallow * create_swallow_applet(char *arguments, SwallowOrient orient);
Swallow * create_swallow_applet(char *title, int width, int height,
SwallowOrient orient);
void set_swallow_applet_orient(Swallow *swallow, SwallowOrient orient);
/*I couldn't resist the naming of this function*/
void ask_about_swallowing(void);
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