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

few cleanups, made orientation change work for menus

Wed Mar 04 01:09:53 1998  George Lebl  <jirka@5z.com>

        * panel-widget.[ch],main.c,panel.[ch]: few cleanups, made
          orientation change work for menus
parent 72ac98f3
Wed Mar 04 01:09:53 1998 George Lebl <jirka@5z.com>
* panel-widget.[ch],main.c,panel.[ch]: few cleanups, made
orientation change work for menus
1998-03-04 Raja R Harinath <harinath@cs.umn.edu>
Move gnome-panel.idl and applet-{lib,widget}.* to libapplet.
......
Wed Mar 04 01:09:53 1998 George Lebl <jirka@5z.com>
* panel-widget.[ch],main.c,panel.[ch]: few cleanups, made
orientation change work for menus
1998-03-04 Raja R Harinath <harinath@cs.umn.edu>
Move gnome-panel.idl and applet-{lib,widget}.* to libapplet.
......
......@@ -187,50 +187,44 @@ create_empty_drawer_applet(GtkWidget *window, DrawerOrient orient)
}
/*FIXME: change orientation!*/
#if 0
static void
set_orientation(GtkWidget *window, Menu *menu)
void
set_drawer_applet_orient(Drawer *drawer, DrawerOrient orient)
{
GtkWidget *pixmap;
char *pixmap_name;
if(!menu || !menu->path)
return;
g_return_if_fail(drawer!=NULL);
if (strcmp (menu->path, ".") == 0)
switch (menu->orient) {
case MENU_DOWN:
pixmap_name = gnome_unconditional_pixmap_file(
"gnome-menu-down.xpm");
break;
case MENU_UP:
pixmap_name = gnome_unconditional_pixmap_file(
"gnome-menu-up.xpm");
break;
case MENU_RIGHT:
pixmap_name = gnome_unconditional_pixmap_file(
"gnome-menu-right.xpm");
break;
case MENU_LEFT:
pixmap_name = gnome_unconditional_pixmap_file(
"gnome-menu-left.xpm");
break;
}
else
/*FIXME: these guys need arrows as well*/
pixmap_name = gnome_unconditional_pixmap_file ("panel-folder.xpm");
drawer->orient = orient;
switch (drawer->orient) {
case DRAWER_DOWN:
pixmap_name = gnome_unconditional_pixmap_file(
"gnome-menu-down.xpm");
break;
case DRAWER_UP:
pixmap_name = gnome_unconditional_pixmap_file(
"gnome-menu-up.xpm");
break;
case DRAWER_RIGHT:
pixmap_name = gnome_unconditional_pixmap_file(
"gnome-menu-right.xpm");
break;
case DRAWER_LEFT:
pixmap_name = gnome_unconditional_pixmap_file(
"gnome-menu-left.xpm");
break;
}
pixmap=GTK_BUTTON(menu->button)->child;
gtk_container_remove(GTK_CONTAINER(menu->button),pixmap);
pixmap=GTK_BUTTON(drawer->button)->child;
gtk_container_remove(GTK_CONTAINER(drawer->button),pixmap);
gtk_widget_destroy(pixmap);
/*make the pixmap*/
pixmap = gnome_pixmap_new_from_file (pixmap_name);
gtk_container_add (GTK_CONTAINER(menu->button), pixmap);
gtk_container_add (GTK_CONTAINER(drawer->button), pixmap);
gtk_widget_show (pixmap);
g_free(pixmap_name);
}
#endif
......@@ -19,6 +19,8 @@ typedef struct {
Drawer * create_drawer_applet(GtkWidget *window, GtkWidget * drawer_panel,
DrawerOrient orient);
void set_drawer_applet_orient(Drawer *drawer, DrawerOrient orient);
Drawer * create_empty_drawer_applet(GtkWidget *window, DrawerOrient orient);
END_GNOME_DECLS
......
......@@ -48,8 +48,9 @@ load_applet(char *id, char *params, int pos, int panel)
params,MENU_UP);
register_toy(menu->button,menu->menu,MENU_ID,params,pos,
register_toy(menu->button,menu->menu,menu,MENU_ID,params,pos,
panel,APPLET_HAS_PROPERTIES,APPLET_MENU);
printf("[load:menu:%ld]\n",(long)menu);
} else if(strcmp(id,DRAWER_ID) == 0) {
Drawer *drawer;
PanelWidget *parent;
......@@ -92,8 +93,9 @@ load_applet(char *id, char *params, int pos, int panel)
g_return_if_fail(drawer != NULL);
register_toy(drawer->button,drawer->drawer,DRAWER_ID,params,
pos, panel,APPLET_HAS_PROPERTIES,APPLET_MENU);
register_toy(drawer->button,drawer->drawer,drawer,DRAWER_ID,
params, pos, panel,
APPLET_HAS_PROPERTIES,APPLET_MENU);
}
}
......@@ -155,6 +157,82 @@ panel_realize(GtkWidget *widget, gpointer data)
change_window_cursor(widget->window, GDK_ARROW);
}
static void
orient_change_foreach(gpointer data, gpointer user_data)
{
AppletInfo *info = gtk_object_get_user_data(GTK_OBJECT(data));
PanelWidget *panel = user_data;
if(info->type == APPLET_EXTERN) {
/*FIXME: call corba*/
} else if(info->type == APPLET_MENU) {
Menu *menu = info->data;
MenuOrient orient;
printf("[orient:menu:%ld]\n",(long)menu);
switch(panel->snapped) {
case PANEL_FREE:
case PANEL_DRAWER:
orient = (panel->orient==PANEL_VERTICAL)?
MENU_RIGHT:MENU_UP;
break;
case PANEL_TOP:
orient = MENU_DOWN;
break;
case PANEL_BOTTOM:
orient = MENU_UP;
break;
case PANEL_LEFT:
orient = MENU_RIGHT;
break;
case PANEL_RIGHT:
orient = MENU_LEFT;
break;
}
set_menu_applet_orient(menu,orient);
} else if(info->type == APPLET_DRAWER) {
Drawer *drawer = info->data;
DrawerOrient orient;
switch(panel->snapped) {
case PANEL_FREE:
case PANEL_DRAWER:
orient = (panel->orient==PANEL_VERTICAL)?
DRAWER_RIGHT:DRAWER_UP;
break;
case PANEL_TOP:
orient = DRAWER_DOWN;
break;
case PANEL_BOTTOM:
orient = DRAWER_UP;
break;
case PANEL_LEFT:
orient = DRAWER_RIGHT;
break;
case PANEL_RIGHT:
orient = DRAWER_LEFT;
break;
}
set_drawer_applet_orient(drawer,orient);
panel_widget_foreach(PANEL_WIDGET(info->assoc),
orient_change_foreach,
(gpointer)info->assoc);
}
}
static int
panel_orient_change(GtkWidget *widget,
PanelOrientation orient,
PanelSnapped snapped,
gpointer data)
{
puts("PANEL_ORIENT_CHANGE");
panel_widget_foreach(PANEL_WIDGET(widget),orient_change_foreach,
(gpointer)widget);
}
static int
panel_button_press(GtkWidget *widget, GdkEventButton *event, gpointer data)
{
......@@ -232,6 +310,10 @@ init_user_panels(void)
if(!root_menu) init_main_menu(panel);
panel_menu = create_panel_root_menu(PANEL_WIDGET(panel));
gtk_signal_connect(GTK_OBJECT(panel),
"orient_change",
GTK_SIGNAL_FUNC(panel_orient_change),
NULL);
gtk_signal_connect(GTK_OBJECT(panel),
"button_press_event",
GTK_SIGNAL_FUNC(panel_button_press),
......
......@@ -13,7 +13,7 @@
#include <unistd.h>
#include <dirent.h>
#include <string.h>
#include "gnome.h"
#include <gnome.h>
#include "panel-widget.h"
#include "panel.h"
#include "panel_config_global.h"
......@@ -579,7 +579,7 @@ create_panel_menu (GtkWidget *window, char *menudir, int main_menu,
else
/*FIXME: these guys need arrows as well*/
pixmap_name = gnome_unconditional_pixmap_file ("panel-folder.xpm");
menu->orient = orient;
/* main button */
......@@ -676,6 +676,7 @@ create_menu_applet(GtkWidget *window, char *arguments, MenuOrient orient)
main_menu = (strcmp (arguments, ".") == 0);
menu = create_panel_menu (window, this_menu, main_menu, orient);
menu->path=g_strdup(arguments);
gtk_object_set_user_data(GTK_OBJECT(menu->button),menu);
......@@ -696,14 +697,16 @@ set_show_small_icons(gpointer data, gpointer user_data)
gtk_widget_hide(w);
}
static void
set_orientation(GtkWidget *window, Menu *menu)
void
set_menu_applet_orient(Menu *menu, MenuOrient orient)
{
GtkWidget *pixmap;
char *pixmap_name;
if(!menu || !menu->path)
return;
g_return_if_fail(menu!=NULL);
//g_return_if_fail(menu->path!=NULL);
menu->orient = orient;
if (strcmp (menu->path, ".") == 0)
switch (menu->orient) {
......
......@@ -22,6 +22,8 @@ GtkWidget * init_main_menu(GtkWidget *window);
Menu * create_menu_applet(GtkWidget *window ,char *arguments,
MenuOrient orient);
void set_menu_applet_orient(Menu *menu, MenuOrient orient);
/*used in foreach to set unset visibility of small_icons*/
void set_show_small_icons(gpointer data, gpointer user_data);
......
......@@ -1701,6 +1701,22 @@ panel_widget_change_params(PanelWidget *panel,
panel_widget_pop_down(panel);
}
void
panel_widget_change_orient(PanelWidget *panel,
PanelOrientation orient)
{
panel_widget_change_params(panel,
orient,
panel->snapped,
panel->mode,
panel->state,
panel->step_size,
panel->minimized_size,
panel->minimize_delay,
panel->drawer_drop_zone_pos);
}
void
panel_widget_restore_state(PanelWidget *panel)
{
......
......@@ -178,6 +178,10 @@ void panel_widget_change_params (PanelWidget *panel,
DrawerDropZonePos
drop_zone_pos);
/*changing parameters (orient only)*/
void panel_widget_change_orient (PanelWidget *panel,
PanelOrientation orient);
#ifdef __cplusplus
}
#endif /* __cplusplus */
......
......@@ -585,7 +585,7 @@ reserve_applet_spot (const char * ior, const char *path, int panel, int pos)
/*we save the ior in the id field of the appletinfo and the
path in the params field*/
register_toy(eb,NULL,g_strdup(ior),g_strdup(path),pos,panel,0,APPLET_EXTERN);
register_toy(eb,NULL,NULL,g_strdup(ior),g_strdup(path),pos,panel,0,APPLET_EXTERN);
for(i=0,list=applets;list!=NULL;list=g_list_next(list))
i++;
......@@ -672,6 +672,7 @@ set_tooltip(GtkWidget *applet, char *tooltip)
void
register_toy(GtkWidget *applet,
GtkWidget * assoc,
gpointer data,
char *id,
char *params,
int pos,
......@@ -694,12 +695,13 @@ register_toy(GtkWidget *applet,
info = g_new(AppletInfo,1);
info->flags = flags;
info->widget = eventbox;
info->type = type;
info->widget = eventbox;
info->assoc = assoc;
info->data = data;
info->id = g_strdup(id);
info->params = g_strdup(params);
info->flags = flags;
gtk_object_set_user_data(GTK_OBJECT(eventbox),info);
......
......@@ -41,8 +41,7 @@ typedef enum {
typedef enum {
APPLET_EXTERN,
APPLET_DRAWER,
APPLET_MENU,
APPLET_LAUNCHER
APPLET_MENU
} AppletType;
typedef enum {
......@@ -78,6 +77,7 @@ void create_applet_menu(void);
void register_toy(GtkWidget *applet,
GtkWidget *assoc,
gpointer data,
char *id,
char *params,
int pos,
......
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