More work -mig

This commit is contained in:
Miguel de Icaza 1998-03-01 01:29:42 +00:00
parent 40f47113e0
commit 3d9ea977f0
5 changed files with 110 additions and 42 deletions

View File

@ -55,6 +55,13 @@ shaped_icon_new_from_file (char *file, int extra_events)
GdkImlibImage *im; GdkImlibImage *im;
GdkWindowPrivate *private; GdkWindowPrivate *private;
if (!g_file_exists (file))
return;
im = gdk_imlib_load_image (file);
if (!im)
return NULL;
gtk_widget_push_visual (gdk_imlib_get_visual ()); gtk_widget_push_visual (gdk_imlib_get_visual ());
gtk_widget_push_colormap (gdk_imlib_get_colormap ()); gtk_widget_push_colormap (gdk_imlib_get_colormap ());
@ -65,8 +72,6 @@ shaped_icon_new_from_file (char *file, int extra_events)
gtk_widget_pop_colormap (); gtk_widget_pop_colormap ();
gtk_widget_pop_visual (); gtk_widget_pop_visual ();
im = gdk_imlib_load_image (file);
gtk_widget_set_usize (window, im->rgb_width, im->rgb_height); gtk_widget_set_usize (window, im->rgb_width, im->rgb_height);
gtk_widget_realize (window); gtk_widget_realize (window);
gdk_window_resize (window->window, im->rgb_width, im->rgb_height); gdk_window_resize (window->window, im->rgb_width, im->rgb_height);
@ -163,9 +168,9 @@ dentry_execute (desktop_icon_t *di)
* invocation * invocation
*/ */
if (strcmp (di->dentry->type, "Directory") == 0) if (strcmp (di->dentry->type, "Directory") == 0){
do_cd (di->dentry->exec, cd_exact); new_panel_at (di->dentry->exec);
else } else
gnome_desktop_entry_launch (dentry); gnome_desktop_entry_launch (dentry);
} }
@ -204,10 +209,26 @@ desktop_load_dentry (char *filename)
if (dentry->icon) if (dentry->icon)
window = shaped_icon_new_from_file (dentry->icon, GDK_BUTTON_PRESS_MASK); window = shaped_icon_new_from_file (dentry->icon, GDK_BUTTON_PRESS_MASK);
else {
static char *default_icon_path;
static char exists;
if (!default_icon_path){
default_icon_path = gnome_unconditional_pixmap_file ("launcher-program.xpm");
if (g_file_exists (default_icon_path))
exists = 1;
}
if (exists)
window = shaped_icon_new_from_file (default_icon_path, GDK_BUTTON_PRESS_MASK);
else { else {
window = gtk_window_new (GTK_WINDOW_POPUP); window = gtk_window_new (GTK_WINDOW_POPUP);
gtk_widget_set_usize (window, 20, 20); gtk_widget_set_usize (window, 20, 20);
} }
}
if (!window)
return;
di = xmalloc (sizeof (desktop_icon_t), "desktop_load_entry"); di = xmalloc (sizeof (desktop_icon_t), "desktop_load_entry");
di->dentry = dentry; di->dentry = dentry;
di->widget = window; di->widget = window;
@ -270,6 +291,7 @@ get_desktop_icon (char *pathname)
static void static void
desktop_file_exec (GtkWidget *widget, GdkEventButton *event, desktop_icon_t *di) desktop_file_exec (GtkWidget *widget, GdkEventButton *event, desktop_icon_t *di)
{ {
if (event->type == GDK_2BUTTON_PRESS && event->button == 1)
printf ("YOu just discovered that regex_command ('open') is not being invoked yet\n"); printf ("YOu just discovered that regex_command ('open') is not being invoked yet\n");
} }
@ -335,10 +357,12 @@ desktop_load (char *desktop_dir)
desktop_create_directory_entry (dir_full, full, dent->d_name); desktop_create_directory_entry (dir_full, full, dent->d_name);
free (dir_full); free (dir_full);
} else if (!strstr (dent->d_name, ".desktop")) } else {
if (strstr (dent->d_name, ".desktop"))
desktop_load_dentry (full); desktop_load_dentry (full);
else else
desktop_create_launch_entry (full, dent->d_name); desktop_create_launch_entry (full, dent->d_name);
}
free (full); free (full);
} }

View File

@ -15,7 +15,7 @@ typedef struct {
Widget *other; Widget *other;
} PanelContainer; } PanelContainer;
GList *containers; GList *containers = 0;
int output_lines = 0; int output_lines = 0;
int command_prompt = 1; int command_prompt = 1;
@ -77,6 +77,20 @@ set_current_panel (int index)
current_panel_ptr = p->data; current_panel_ptr = p->data;
} }
void
set_new_current_panel (WPanel *panel)
{
GList *p;
other_panel_ptr = current_panel_ptr;
for (p = containers; p; p = p->next){
if (((PanelContainer *)p->data)->panel == panel){
printf ("Setting current panel to %p\n", p);
current_panel_ptr = p->data;
}
}
}
void void
print_vfs_message (char *msg) print_vfs_message (char *msg)
{ {
@ -172,27 +186,19 @@ GnomeUIInfo gnome_panel_menu [] = {
{ GNOME_APP_UI_ENDOFINFO, 0, 0 } { GNOME_APP_UI_ENDOFINFO, 0, 0 }
}; };
int
dialog_panel_callback (struct Dlg_head *h, int id, int msg)
{
return default_dlg_callback (h, id, msg);
}
void void
gnome_init_panels () gnome_init_panels ()
{ {
containers = g_list_alloc ();
current_panel_ptr = NULL; current_panel_ptr = NULL;
other_panel_ptr = NULL; other_panel_ptr = NULL;
} }
void WPanel *
create_container (char *name) create_container (Dlg_head *h, char *name)
{ {
PanelContainer *container = g_new (PanelContainer, 1); PanelContainer *container = g_new (PanelContainer, 1);
WPanel *panel; WPanel *panel;
GtkWidget *app, *vbox; GtkWidget *app, *vbox;
Dlg_head *h;
int slot; int slot;
container->splitted = 0; container->splitted = 0;
@ -206,7 +212,19 @@ create_container (char *name)
gtk_widget_show (app); gtk_widget_show (app);
panel = panel_new (name); panel = panel_new (name);
/* Ultra nasty hack follows:
* I am setting the panel->widget.wdata value here before the
* panel X stuff gets created in the INIT message section of the
* widget. There I put a pointer to the vbox where the panel
* should pack itself
*/
panel->widget.wdata = (widget_data) vbox;
container->panel = panel; container->panel = panel;
if (!containers){
containers = g_list_alloc ();
containers->data = container;
} else
containers = g_list_append (containers, container); containers = g_list_append (containers, container);
if (!current_panel_ptr){ if (!current_panel_ptr){
@ -214,13 +232,25 @@ create_container (char *name)
} else if (!other_panel_ptr) } else if (!other_panel_ptr)
other_panel_ptr = container; other_panel_ptr = container;
h = create_dlg (0, 0, 24, 80, 0, dialog_panel_callback, "[panel]", "midnight", DLG_NO_TED);
add_widget (h, panel);
bind_gtk_keys (GTK_WIDGET (app), h); bind_gtk_keys (GTK_WIDGET (app), h);
return panel;
}
gtk_object_set_data (GTK_OBJECT (h->wdata), "parent-container", vbox); void
new_panel_at (char *dir)
{
WPanel *panel;
Dlg_head *h = current_panel_ptr->panel->widget.parent;
run_dlg (h); mc_chdir (dir);
panel = create_container (h, "Other");
add_widget (h, panel);
/* Gross hack 2: add_widget should know that the dialog is already
* executing and shold call the init method manually. We do so instead:
*/
panel->widget.callback (h, panel, WIDGET_INIT, 0);
set_new_current_panel (panel);
} }
void void

View File

@ -234,19 +234,28 @@ setup_sigwinch ()
{ {
} }
int
dialog_panel_callback (struct Dlg_head *h, int id, int msg)
{
return default_dlg_callback (h, id, msg);
}
void void
create_panels (void) create_panels (void)
{ {
Dlg_head *h; Dlg_head *h;
WPanel *panel;
start_desktop (); start_desktop ();
cmdline = command_new (0, 0, 0); cmdline = command_new (0, 0, 0);
the_hint = label_new (0, 0, 0, NULL); the_hint = label_new (0, 0, 0, NULL);
gnome_init_panels (); gnome_init_panels ();
create_container ("My Panel");
h = create_dlg (0, 0, 24, 80, 0, dialog_panel_callback, "[panel]", "midnight", DLG_NO_TED);
panel = create_container (h, "My Panel");
add_widget (h, panel);
set_current_panel (0); set_current_panel (0);
run_dlg (h);
} }

View File

@ -675,7 +675,7 @@ void
x_create_panel (Dlg_head *h, widget_data parent, WPanel *panel) x_create_panel (Dlg_head *h, widget_data parent, WPanel *panel)
{ {
g_panel_contents *g = g_new (g_panel_contents, 1); g_panel_contents *g = g_new (g_panel_contents, 1);
GtkWidget *table, *status_line, *filter_w, *statusbar; GtkWidget *table, *status_line, *filter_w, *statusbar, *vbox;
g->table = gtk_table_new (2, 1, 0); g->table = gtk_table_new (2, 1, 0);
gtk_widget_show (g->table); gtk_widget_show (g->table);
@ -711,11 +711,14 @@ x_create_panel (Dlg_head *h, widget_data parent, WPanel *panel)
0, 0, 0); 0, 0, 0);
gtk_widget_show (g->table); gtk_widget_show (g->table);
/* Ultra nasty hack: pull the vbox from wdata */
vbox = GTK_WIDGET (panel->widget.wdata);
panel->widget.wdata = (widget_data) g; panel->widget.wdata = (widget_data) g;
/* Now, insert our table in our parent */ /* Now, insert our table in our parent */
gtk_container_add (GTK_CONTAINER (gtk_object_get_data (GTK_OBJECT (h->wdata), "parent-container")), gtk_container_add (GTK_CONTAINER (vbox), g->table);
g->table);
if (!pixmaps_ready){ if (!pixmaps_ready){
if (!GTK_WIDGET_REALIZED (g->list)) if (!GTK_WIDGET_REALIZED (g->list))

View File

@ -17,4 +17,6 @@ typedef struct {
GtkWidget *status; GtkWidget *status;
} g_panel_contents; } g_panel_contents;
WPanel *create_container (Dlg_head *h, char *str);
#endif /* __GSCREEN_H */ #endif /* __GSCREEN_H */