Browse Source

Add vertical panel option by Botsie. Now this is a cool feature.

(Old svn revision: 3317)
upstream/xfce4-panel-4.10.1
Jasper Huijsmans 21 years ago
parent
commit
780e286f60
  1. 8
      TODO
  2. 9
      panel/callbacks.c
  3. 2
      panel/callbacks.h
  4. 132
      panel/central.c
  5. 66
      panel/dialogs.c
  6. 5
      panel/global.h
  7. 117
      panel/xfce.c

8
TODO

@ -3,7 +3,7 @@ TODO list for xfce4
Major features for 4.0
----------------------
* port clock widget In progress (zeDek)
* port clock widget Mostly done (zeDek)
* unify panel controls Done
(make everything a module)
* improve module configuration
@ -13,13 +13,17 @@ Major features for 4.0
(pass xmlNodePtr to module)
* improve global configuration
- add stay-on-top option Done
- split up dialog In progress
- split up dialog Mostly done
- port to new xfce-wide system
* write API docs for plugin writers
* write user docs
* provide good default configuration
* allow different positions for
popup button in all sizes Done
* Update popup positioning function to
new account for panel orientation
* Idem for panel positioning and style
settings.
Nice to have for 4.0
--------------------

9
panel/callbacks.c

@ -57,6 +57,15 @@ gboolean panel_destroy_cb(GtkWidget * window, GdkEvent * ev, gpointer data)
return TRUE;
}
gboolean main_frame_destroy_cb(GtkWidget * frame, GdkEvent * ev, gpointer data)
{
side_panel_cleanup(LEFT);
central_panel_cleanup();
side_panel_cleanup(RIGHT);
return TRUE;
}
void iconify_cb(void)
{
hide_current_popup_menu();

2
panel/callbacks.h

@ -27,6 +27,8 @@ gboolean panel_delete_cb(GtkWidget * window, GdkEvent * ev, gpointer data);
gboolean panel_destroy_cb(GtkWidget * window, GdkEvent * ev, gpointer data);
gboolean main_frame_destroy_cb(GtkWidget * frame, GdkEvent * ev, gpointer data);
void iconify_cb(void);
/* central panel */

132
panel/central.c

@ -183,15 +183,20 @@ void screen_button_pack(ScreenButton * sb, GtkWidget * table)
{
int pos = sb->index;
if (pos % 2 == 0 || settings.size <= SMALL)
{
gtk_table_attach(GTK_TABLE(table), sb->frame, pos, pos + 1, 0, 1,
GTK_EXPAND, GTK_EXPAND, 0, 0);
}
else
{
gtk_table_attach(GTK_TABLE(table), sb->frame, pos - 1, pos, 1, 2,
if (settings.orientation == VERTICAL) {
gtk_table_attach(GTK_TABLE(table), sb->frame, 0, 1, pos, pos + 1,
GTK_EXPAND, GTK_EXPAND, 0, 0);
} else {
if (pos % 2 == 0 || settings.size <= SMALL)
{
gtk_table_attach(GTK_TABLE(table), sb->frame, pos, pos + 1, 0, 1,
GTK_EXPAND, GTK_EXPAND, 0, 0);
}
else
{
gtk_table_attach(GTK_TABLE(table), sb->frame, pos - 1, pos, 1, 2,
GTK_EXPAND, GTK_EXPAND, 0, 0);
}
}
}
@ -267,21 +272,39 @@ static void add_mini_table(int side, GtkBox * hbox)
if (settings.size > SMALL)
{
gtk_table_attach(GTK_TABLE(mini_tables[side]), minibuttons[first],
0, 1, 0, 1, GTK_SHRINK, GTK_EXPAND, 0, 0);
gtk_table_attach(GTK_TABLE(mini_tables[side]), minibuttons[first + 1],
0, 1, 1, 2, GTK_SHRINK, GTK_EXPAND, 0, 0);
if (settings.orientation == VERTICAL) {
gtk_table_attach(GTK_TABLE(mini_tables[side]), minibuttons[first],
0, 1, 0, 1, GTK_SHRINK, GTK_EXPAND, 0, 0);
gtk_table_attach(GTK_TABLE(mini_tables[side]),
minibuttons[first + 1],
1, 2, 0, 1, GTK_SHRINK, GTK_EXPAND, 0, 0);
} else {
gtk_table_attach(GTK_TABLE(mini_tables[side]), minibuttons[first],
0, 1, 0, 1, GTK_SHRINK, GTK_EXPAND, 0, 0);
gtk_table_attach(GTK_TABLE(mini_tables[side]),
minibuttons[first + 1],
0, 1, 1, 2, GTK_SHRINK, GTK_EXPAND, 0, 0);
}
gtk_box_pack_start(hbox, mini_tables[side], TRUE, TRUE, 0);
gtk_box_pack_start(hbox, mini_tables[side], TRUE, TRUE, 0);
}
else
{
gtk_table_attach(GTK_TABLE(mini_tables[side]), minibuttons[first],
0, 1, 0, 1, GTK_SHRINK, GTK_EXPAND, 0, 0);
gtk_table_attach(GTK_TABLE(mini_tables[side]), minibuttons[first + 1],
1, 2, 0, 1, GTK_SHRINK, GTK_EXPAND, 0, 0);
if (settings.orientation == VERTICAL) {
gtk_table_attach(GTK_TABLE(mini_tables[side]), minibuttons[first],
0, 1, 0, 1, GTK_SHRINK, GTK_EXPAND, 0, 0);
gtk_table_attach(GTK_TABLE(mini_tables[side]),
minibuttons[first + 1],
0, 1, 1, 2, GTK_SHRINK, GTK_EXPAND, 0, 0);
} else {
gtk_table_attach(GTK_TABLE(mini_tables[side]), minibuttons[first],
0, 1, 0, 1, GTK_SHRINK, GTK_EXPAND, 0, 0);
gtk_table_attach(GTK_TABLE(mini_tables[side]),
minibuttons[first + 1],
1, 2, 0, 1, GTK_SHRINK, GTK_EXPAND, 0, 0);
}
gtk_box_pack_start(hbox, mini_tables[side], TRUE, TRUE, 0);
gtk_box_pack_start(hbox, mini_tables[side], TRUE, TRUE, 0);
}
}
@ -290,7 +313,11 @@ static void add_desktop_table(GtkBox * hbox)
GtkWidget *table;
int i;
table = gtk_table_new(2, NBSCREENS, FALSE);
if (settings.orientation == VERTICAL) {
table = gtk_table_new(NBSCREENS, 2, FALSE);
} else {
table = gtk_table_new(2, NBSCREENS, FALSE);
}
if(settings.show_desktop_buttons)
gtk_widget_show(table);
@ -399,6 +426,10 @@ static void reorder_minitable(int side, int size)
/* when size == SMALL put second button in second column first row
* otherwise put second button in first column second row */
/* Botsie: I didn't understand the bit above -- but in vertical mode
* we do the exact opposite */
for(child = GTK_TABLE(table)->children;
child && child->data; child = child->next)
{
@ -410,13 +441,23 @@ static void reorder_minitable(int side, int size)
if(size == SMALL || size == TINY)
{
hpos = 1;
vpos = 0;
if (settings.orientation == VERTICAL) {
hpos = 0;
vpos = 1;
} else {
hpos = 1;
vpos = 0;
}
}
else
{
hpos = 0;
vpos = 1;
if (settings.orientation == VERTICAL) {
hpos = 1;
vpos = 0;
} else {
hpos = 0;
vpos = 1;
}
}
tc->left_attach = hpos;
@ -451,30 +492,35 @@ static void reorder_desktop_table(int size)
break;
}
if((i % 2) == 0)
{
if(size <= SMALL)
{
hpos = i;
vpos = 0;
}
else
{
hpos = i / 2;
vpos = 0;
}
}
else
{
if(size <= SMALL)
if (settings.orientation == VERTICAL) {
hpos = 0;
vpos = i;
} else {
if((i % 2) == 0)
{
hpos = i;
vpos = 0;
if(size <= SMALL)
{
hpos = i;
vpos = 0;
}
else
{
hpos = i / 2;
vpos = 0;
}
}
else
{
hpos = (i - 1) / 2;
vpos = 1;
if(size <= SMALL)
{
hpos = i;
vpos = 0;
}
else
{
hpos = (i - 1) / 2;
vpos = 1;
}
}
}

66
panel/dialogs.c

@ -107,6 +107,7 @@ void set_transient_for_dialog(GtkWidget * window)
* popup size: option menu
* popup position: option menu
* style: option menu (should be radio buttons according to GNOME HIG)
* panel orientation: option menu
* icon theme: option menu
* left : spinbutton
* right: spinbutton
@ -122,6 +123,7 @@ static GtkWidget *size_menu;
static GtkWidget *popup_menu;
static GtkWidget *orientation_menu;
static GtkWidget *style_menu;
static GtkWidget *panel_orientation_menu;
static GtkWidget *theme_menu;
static GtkWidget *left_spin;
static GtkWidget *right_spin;
@ -157,6 +159,7 @@ static void create_backup(void)
backup.popup_size = settings.popup_size;
backup.popup_position = settings.popup_position;
backup.style = settings.style;
backup.orientation = settings.orientation;
backup.theme = g_strdup(settings.theme);
backup.num_left = settings.num_left;
backup.num_right = settings.num_right;
@ -174,8 +177,11 @@ static void restore_backup(void)
gtk_option_menu_set_history(GTK_OPTION_MENU(size_menu), backup.size);
gtk_option_menu_set_history(GTK_OPTION_MENU(popup_menu), backup.popup_size);
/*
* This is not working properly just yet.
gtk_option_menu_set_history(GTK_OPTION_MENU(orientation_menu),
backup.popup_position);
backup.orientation); */
gtk_option_menu_set_history(GTK_OPTION_MENU(style_menu), backup.style);
gtk_option_menu_set_history(GTK_OPTION_MENU(theme_menu),
backup_theme_index);
@ -402,6 +408,47 @@ static void add_style_menu(GtkWidget * option_menu, int style)
gtk_widget_set_sensitive(option_menu, FALSE);
}
/*
* Panel Orientation
*/
static void panel_orientation_changed(GtkOptionMenu * menu)
{
int n = gtk_option_menu_get_history(menu);
if(n == settings.orientation)
return;
panel_set_orientation(n);
panel_reorient();
// gtk_widget_set_sensitive(revert, TRUE);
}
static void add_panel_orientation_menu(GtkWidget * option_menu, int orientation)
{
GtkWidget *menu = gtk_menu_new();
GtkWidget *item;
item = gtk_menu_item_new_with_label(_("Horizontal"));
gtk_widget_show(item);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
item = gtk_menu_item_new_with_label(_("Vertical"));
gtk_widget_show(item);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
gtk_option_menu_set_menu(GTK_OPTION_MENU(option_menu), menu);
gtk_option_menu_set_history(GTK_OPTION_MENU(option_menu), orientation);
g_signal_connect(option_menu, "changed",
G_CALLBACK(panel_orientation_changed), NULL);
}
/* popup orientation
*/
static void orientation_changed(GtkOptionMenu * menu)
@ -602,6 +649,23 @@ static void add_style_box(GtkBox * box)
add_style_menu(style_menu, settings.style);
gtk_box_pack_start(GTK_BOX(hbox), style_menu, TRUE, TRUE, 0);
/* panel orientation */
hbox = gtk_hbox_new(FALSE, 4);
gtk_widget_show(hbox);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
label = gtk_label_new(_("Panel Orientation:"));
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
gtk_widget_show(label);
gtk_size_group_add_widget(sg, label);
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
panel_orientation_menu = gtk_option_menu_new();
gtk_widget_show(panel_orientation_menu);
add_panel_orientation_menu(panel_orientation_menu, settings.orientation);
gtk_box_pack_start(GTK_BOX(hbox), panel_orientation_menu, TRUE, TRUE, 0);
/* popup orientation */
hbox = gtk_hbox_new(FALSE, 4);
gtk_widget_show(hbox);

5
panel/global.h

@ -67,6 +67,10 @@ enum
enum
{ OLD_STYLE, NEW_STYLE };
/* panel orientation */
enum
{ HORIZONTAL, VERTICAL };
/* Panel sizes
* -----------
* settings.size is a symbolic size given by an enum. The actual sizes
@ -121,6 +125,7 @@ struct _Settings
int popup_position;
int style;
int orientation;
char *theme;
gboolean on_top;

117
panel/xfce.c

@ -57,13 +57,16 @@ int screen_button_width[] = { 30, 40, 80, 80 };
/* Panel framework
* ---------------
* - window
* - hbox
* - hbox : left panel
* - frame
* - hbox : central panel
* - hbox : right panel
* - frame
* - hbox
* - hbox : left panel
* - frame
* - hbox : central panel
* - hbox : right panel
*/
GtkWidget *toplevel = NULL;
GtkWidget *main_frame = NULL;
GtkWidget *main_hbox = NULL;
GtkWidget *left_hbox = NULL;
GtkWidget *right_hbox = NULL;
GtkWidget *central_frame = NULL;
@ -95,27 +98,33 @@ static GtkWidget *create_panel_window(void)
return w;
}
void panel_init(void)
void panel_contents_init()
{
GtkWidget *window;
GtkWidget *frame;
GtkWidget *hbox;
toplevel = create_panel_window();
main_frame = gtk_frame_new(NULL);
gtk_frame_set_shadow_type(GTK_FRAME(main_frame), GTK_SHADOW_OUT);
gtk_container_set_border_width(GTK_CONTAINER(main_frame), 0);
gtk_widget_show(main_frame);
frame = gtk_frame_new(NULL);
gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_OUT);
gtk_container_set_border_width(GTK_CONTAINER(frame), 0);
gtk_widget_show(frame);
gtk_container_add(GTK_CONTAINER(toplevel), frame);
g_signal_connect(main_frame, "destroy-event",
G_CALLBACK(main_frame_destroy_cb), NULL);
gtk_container_add(GTK_CONTAINER(toplevel), main_frame);
hbox = gtk_hbox_new(FALSE, 0);
gtk_widget_show(hbox);
gtk_container_add(GTK_CONTAINER(frame), hbox);
if (settings.orientation == VERTICAL) {
main_hbox = gtk_vbox_new(FALSE, 0);
} else {
main_hbox = gtk_hbox_new(FALSE, 0);
}
gtk_widget_show(main_hbox);
gtk_container_add(GTK_CONTAINER(main_frame), main_hbox);
left_hbox = gtk_hbox_new(FALSE, 0);
if (settings.orientation == VERTICAL) {
left_hbox = gtk_vbox_new(FALSE, 0);
} else {
left_hbox = gtk_hbox_new(FALSE, 0);
}
gtk_widget_show(left_hbox);
gtk_container_add(GTK_CONTAINER(hbox), left_hbox);
gtk_container_add(GTK_CONTAINER(main_hbox), left_hbox);
central_frame = gtk_frame_new(NULL);
if(settings.style == OLD_STYLE)
@ -124,17 +133,32 @@ void panel_init(void)
if (settings.show_central)
gtk_widget_show(central_frame);
gtk_container_add(GTK_CONTAINER(hbox), central_frame);
gtk_container_add(GTK_CONTAINER(main_hbox), central_frame);
central_hbox = gtk_hbox_new(FALSE, 0);
if (settings.orientation == VERTICAL) {
central_hbox = gtk_vbox_new(FALSE, 0);
} else {
central_hbox = gtk_hbox_new(FALSE, 0);
}
gtk_widget_show(central_hbox);
gtk_container_add(GTK_CONTAINER(central_frame), central_hbox);
right_hbox = gtk_hbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(hbox), right_hbox);
if (settings.orientation == VERTICAL) {
right_hbox = gtk_vbox_new(FALSE, 0);
} else {
right_hbox = gtk_hbox_new(FALSE, 0);
}
gtk_container_add(GTK_CONTAINER(main_hbox), right_hbox);
gtk_widget_show(right_hbox);
}
void panel_init(void)
{
toplevel = create_panel_window();
panel_contents_init();
}
void panel_cleanup(void)
{
if(!disable_user_config)
@ -143,9 +167,6 @@ void panel_cleanup(void)
if (GTK_IS_WIDGET(toplevel))
gtk_widget_destroy(toplevel);
side_panel_cleanup(LEFT);
central_panel_cleanup();
side_panel_cleanup(RIGHT);
}
/* Panel settings
@ -160,6 +181,12 @@ void panel_set_size(int size)
side_panel_set_size(RIGHT, size);
}
void panel_set_orientation(int orientation)
{
settings.orientation = orientation;
// panel_set_size(settings.size);
}
void panel_set_popup_size(int size)
{
settings.popup_size = size;
@ -277,6 +304,7 @@ void init_settings(void)
settings.popup_size = MEDIUM;
settings.popup_position = TOP;
settings.style = NEW_STYLE;
settings.orientation = HORIZONTAL;
settings.theme = NULL;
settings.on_top = TRUE;
@ -301,6 +329,7 @@ void panel_set_settings(void)
panel_set_popup_position(settings.popup_position);
panel_set_style(settings.style);
panel_set_orientation(settings.orientation);
panel_set_theme(settings.theme);
side_panel_set_num_groups(LEFT, settings.num_left);
@ -392,6 +421,13 @@ void panel_parse_xml(xmlNodePtr node)
g_free(value);
value = xmlGetProp(node, (const xmlChar *)"orientation");
if(value)
settings.orientation = atoi(value);
g_free(value);
value = xmlGetProp(node, (const xmlChar *)"icontheme");
if(value)
@ -514,6 +550,8 @@ void panel_parse_xml(xmlNodePtr node)
/* check the values */
if(settings.style < OLD_STYLE || settings.style > NEW_STYLE)
settings.style = NEW_STYLE;
if(settings.orientation < HORIZONTAL || settings.orientation > VERTICAL)
settings.orientation = HORIZONTAL;
if(settings.size < TINY || settings.size > LARGE)
settings.size = SMALL;
if(settings.popup_size < SMALL || settings.popup_size > LARGE)
@ -550,6 +588,9 @@ void panel_write_xml(xmlNodePtr root)
snprintf(value, 2, "%d", settings.style);
xmlSetProp(node, "style", value);
snprintf(value, 2, "%d", settings.orientation);
xmlSetProp(node, "orientation", value);
if(settings.theme)
xmlSetProp(node, "icontheme", settings.theme);
@ -593,6 +634,26 @@ void panel_write_xml(xmlNodePtr root)
}
}
void panel_reorient()
{
gtk_widget_hide(toplevel);
gtk_widget_destroy(main_frame);
panel_contents_init();
side_panel_init(LEFT, GTK_BOX(left_hbox));
central_panel_init(GTK_BOX(central_hbox));
side_panel_init(RIGHT, GTK_BOX(right_hbox));
/* read and apply configuration
* This function creates the panel items and popup menus */
get_panel_config();
/* give early visual feedback
* the init functions have already created the basic panel */
panel_set_position();
gtk_widget_show(toplevel);
}
/* Main program
* ------------
*/

Loading…
Cancel
Save