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

implement a new simple movement type (free movement, sort of like it was

Fri May 01 23:01:32 1998  George Lebl  <jirka@5z.com>

        * panel-widget.[ch]: implement a new simple movement
          type (free movement, sort of like it was before I
          wrote the panel-widget), the old one is still default

        * panel.c,main.c,panel_config.c,panel_config_global.[ch]:
          added support for the new movement type, plus minor fixes
parent 8f3287f0
Fri May 01 23:01:32 1998 George Lebl <jirka@5z.com>
* panel-widget.[ch]: implement a new simple movement
type (free movement, sort of like it was before I
wrote the panel-widget), the old one is still default
* panel.c,main.c,panel_config.c,panel_config_global.[ch]:
added support for the new movement type, plus minor fixes
Fri May 01 19:33:05 1998 George Lebl <jirka@5z.com>
* panel_config.c,panel-widget.c: made it possible to
......
Fri May 01 23:01:32 1998 George Lebl <jirka@5z.com>
* panel-widget.[ch]: implement a new simple movement
type (free movement, sort of like it was before I
wrote the panel-widget), the old one is still default
* panel.c,main.c,panel_config.c,panel_config_global.[ch]:
added support for the new movement type, plus minor fixes
Fri May 01 19:33:05 1998 George Lebl <jirka@5z.com>
* panel_config.c,panel-widget.c: made it possible to
......
......@@ -720,7 +720,8 @@ init_user_panels(void)
panel_widget_change_global(DEFAULT_EXPLICIT_HIDE_STEP_SIZE,
DEFAULT_AUTO_HIDE_STEP_SIZE,
DEFAULT_MINIMIZED_SIZE,
DEFAULT_MINIMIZE_DELAY);
DEFAULT_MINIMIZE_DELAY,
PANEL_SWITCH_MOVE);
for(num=1;num<=count;num++) {
g_snprintf(buf,256,"%sPanel_%d/", old_panel_cfg_path, num);
......@@ -937,6 +938,9 @@ main(int argc, char **argv)
g_snprintf(buf,256,"%sConfig/minimized_size=%d",old_panel_cfg_path,
DEFAULT_MINIMIZED_SIZE);
global_config.minimized_size=gnome_config_get_int(buf);
g_snprintf(buf,256,"%sConfig/movement_type=%d",old_panel_cfg_path,
PANEL_SWITCH_MOVE);
global_config.movement_type=gnome_config_get_int(buf);
init_main_menu();
init_user_panels();
......
#include "panel-widget.h"
#ifndef PANEL_CONFIG_GLOBAL_H
#define PANEL_CONFIG_GLOBAL_H
......@@ -9,6 +11,7 @@ struct _GlobalConfig {
gint minimize_delay;
gint tooltips_enabled;
gint show_small_icons;
PanelMovementType movement_type;
};
......
......@@ -242,6 +242,7 @@ pixmap_page (PanelWidget *panel)
CONFIG_PADDING_SIZE);
box = gtk_vbox_new (0, 0);
gtk_container_border_width(GTK_CONTAINER (box), CONFIG_PADDING_SIZE);
gtk_container_add (GTK_CONTAINER (f), box);
file_entry = gnome_file_entry_new ("pixmap", _("Browse"));
t = gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (file_entry));
......
......@@ -25,6 +25,8 @@ static gint pw_auto_step = 10;
static gint pw_minimized_size = 6;
static gint pw_minimize_delay = 300;
static PanelMovementType movement_type = PANEL_SWITCH_MOVE;
/* FIXME: real DND is disabled, needs fixing(??), or might be left for dead
really ... if an applet wants to do dnd it will do it on it's own and
the panel will do interpanel drags differently
......@@ -2137,6 +2139,95 @@ panel_widget_get_moveby(PanelWidget *panel, gint pos)
return (y/PANEL_CELL_SIZE)- pos;
}
static gint
panel_widget_get_free_spot(PanelWidget *panel, AppletData *ad)
{
int i,e;
gint x,y;
gint place;
gint start;
gint right=-1,left=-1;
gtk_widget_get_pointer(panel->fixed, &x, &y);
if(panel->orient == PANEL_HORIZONTAL)
place = x/PANEL_CELL_SIZE;
else
place = y/PANEL_CELL_SIZE;
if(ad->pos>=panel->size)
return -1;
start = place-(ad->cells/2);
if(start<0)
start = 0;
for(e=0,i=start;i<panel->size;i++) {
if(!panel->applets[i].applet ||
panel->applets[i].applet == ad->applet) {
e++;
if(e>=ad->cells) {
right = i-e+1;
break;
}
} else
e=0;
}
start = place+(ad->cells/2);
if(start>=panel->size)
start = panel->size-1;
for(e=0,i=start;i>=0;i--) {
if(!panel->applets[i].applet ||
panel->applets[i].applet == ad->applet) {
e++;
if(e>=ad->cells) {
left = i;
break;
}
} else
e=0;
}
start = place-(ad->cells/2);
if(left==-1) {
if(right==-1)
return -1;
else
return right;
} else {
if(right==-1)
return left;
else
return abs(left-start)>abs(right-start)?right:left;
}
}
/*to call this function we MUST know that there is at least
ad->cells free at pos otherwise we will mess up the panel*/
static void
panel_widget_nice_move(PanelWidget *panel, AppletData *ad, gint pos)
{
gint i;
if(pos==ad->pos)
return;
for(i=ad->pos;i<ad->pos+ad->cells;i++) {
panel->applets[i].applet=NULL;
panel->applets[i].cells=1;
}
ad->pos = pos;
for(i=ad->pos;i<ad->pos+ad->cells;i++) {
panel->applets[i].applet=ad->applet;
panel->applets[i].cells=ad->cells;
}
panel_widget_applet_put(panel,pos);
}
/*find the cursor position and move the applet to that position*/
gint
......@@ -2193,9 +2284,20 @@ panel_widget_applet_move_to_cursor(PanelWidget *panel)
/*return TRUE;*/
}
moveby = panel_widget_get_moveby(panel, pos);
if(moveby != 0)
panel_widget_switch_move(panel, pos, moveby);
if(movement_type == PANEL_SWITCH_MOVE ||
panel->snapped == PANEL_DRAWER) {
moveby = panel_widget_get_moveby(panel, pos);
if(moveby != 0)
panel_widget_switch_move(panel, pos, moveby);
} else {
pos = panel_widget_get_free_spot(panel,
panel->currently_dragged_applet);
if(pos>=0)
panel_widget_nice_move(panel,
panel->currently_dragged_applet,
pos);
}
return TRUE;
}
return FALSE;
......@@ -2490,11 +2592,10 @@ panel_widget_find_empty_pos(PanelWidget *panel, gint pos)
return i;
/*panel is full to the right*/
if(i==panel->size) {
for(i=pos-1;i>=0;i--)
if(!panel->applets[i].applet)
return i;
}
for(i=pos-1;i>=0;i--)
if(!panel->applets[i].applet)
return i;
/*panel is full!*/
return -1;
}
......@@ -2509,7 +2610,12 @@ panel_widget_add (PanelWidget *panel, GtkWidget *applet, gint pos)
g_return_val_if_fail(applet!=NULL,-1);
g_return_val_if_fail(pos>=0,-1);
pos = panel_widget_make_empty_pos(panel,pos);
if(movement_type == PANEL_SWITCH_MOVE ||
panel->snapped == PANEL_DRAWER)
pos = panel_widget_make_empty_pos(panel,pos);
else
pos = panel_widget_find_empty_pos(panel,pos);
if(pos==-1) return -1;
/*this will get done right on size allocate!*/
......@@ -2558,7 +2664,12 @@ panel_widget_reparent (PanelWidget *old_panel,
g_return_val_if_fail(applet!=NULL,-1);
g_return_val_if_fail(pos>=0,-1);
pos = panel_widget_make_empty_pos(new_panel,pos);
if(movement_type == PANEL_SWITCH_MOVE ||
new_panel->snapped == PANEL_DRAWER)
pos = panel_widget_make_empty_pos(new_panel,pos);
else
pos = panel_widget_find_empty_pos(new_panel,pos);
if(pos==-1) return -1;
/*remove from the old_panel*/
......@@ -2960,7 +3071,8 @@ void
panel_widget_change_global(gint explicit_step,
gint auto_step,
gint minimized_size,
gint minimize_delay)
gint minimize_delay,
PanelMovementType move_type)
{
if(explicit_step>0)
pw_explicit_step=explicit_step;
......@@ -2970,6 +3082,7 @@ panel_widget_change_global(gint explicit_step,
pw_minimized_size=minimized_size;
if(minimize_delay>=0)
pw_minimize_delay=minimize_delay;
movement_type = move_type;
}
void
......
......@@ -55,6 +55,10 @@ typedef enum {
DROP_ZONE_LEFT,
DROP_ZONE_RIGHT
} DrawerDropZonePos;
typedef enum {
PANEL_SWITCH_MOVE,
PANEL_FREE_MOVE
} PanelMovementType;
struct _AppletRecord
{
......@@ -222,7 +226,8 @@ void panel_widget_change_drop_zone_pos(PanelWidget *panel,
void panel_widget_change_global (gint explicit_step,
gint auto_step,
gint minimized_size,
gint minimize_delay);
gint minimize_delay,
PanelMovementType move_type);
/*popup the widget if it's popped down (autohide)*/
void panel_widget_pop_up (PanelWidget *panel);
......
......@@ -52,7 +52,8 @@ apply_global_config(void)
panel_widget_change_global(global_config.explicit_hide_step_size,
global_config.auto_hide_step_size,
global_config.minimized_size,
global_config.minimize_delay);
global_config.minimize_delay,
global_config.movement_type);
if(global_config.tooltips_enabled)
gtk_tooltips_enable(panel_tooltips);
else
......
......@@ -242,6 +242,7 @@ pixmap_page (PanelWidget *panel)
CONFIG_PADDING_SIZE);
box = gtk_vbox_new (0, 0);
gtk_container_border_width(GTK_CONTAINER (box), CONFIG_PADDING_SIZE);
gtk_container_add (GTK_CONTAINER (f), box);
file_entry = gnome_file_entry_new ("pixmap", _("Browse"));
t = gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (file_entry));
......
......@@ -50,6 +50,7 @@ config_apply (GtkWidget *widget, int page, gpointer data)
temp_config.explicit_hide_step_size;
global_config.tooltips_enabled = temp_config.tooltips_enabled;
global_config.show_small_icons = temp_config.show_small_icons;
global_config.movement_type = temp_config.movement_type;
apply_global_config();
}
......@@ -140,6 +141,17 @@ animation_notebook_page(void)
return (vbox);
}
static void
set_movement (GtkWidget *widget, gpointer data)
{
PanelMovementType move_type = (PanelMovementType) data;
temp_config.movement_type = move_type;
gnome_property_box_changed (GNOME_PROPERTY_BOX (config_window));
}
GtkWidget *
misc_notebook_page(void)
{
......@@ -168,9 +180,8 @@ misc_notebook_page(void)
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (set_toggle_button_value),
&(temp_config.tooltips_enabled));
if (temp_config.tooltips_enabled) {
if (temp_config.tooltips_enabled)
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (button), TRUE);
}
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE,
CONFIG_PADDING_SIZE);
......@@ -190,11 +201,43 @@ misc_notebook_page(void)
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (set_toggle_button_value),
&(temp_config.show_small_icons));
if (temp_config.show_small_icons) {
if (temp_config.show_small_icons)
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (button), TRUE);
}
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE,
CONFIG_PADDING_SIZE);
/* Movement frame */
frame = gtk_frame_new (_("Movement"));
gtk_container_border_width(GTK_CONTAINER (frame), CONFIG_PADDING_SIZE);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE,
CONFIG_PADDING_SIZE);
/* vbox for frame */
box = gtk_vbox_new (FALSE, CONFIG_PADDING_SIZE);
gtk_container_border_width(GTK_CONTAINER (box), CONFIG_PADDING_SIZE);
gtk_container_add (GTK_CONTAINER (frame), box);
/* Switched */
button = gtk_radio_button_new_with_label (NULL, _("Switched movement"));
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (set_movement),
(gpointer)PANEL_SWITCH_MOVE);
if (temp_config.movement_type == PANEL_SWITCH_MOVE)
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (button), TRUE);
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE,
CONFIG_PADDING_SIZE);
/* Free */
button = gtk_radio_button_new_with_label (
gtk_radio_button_group (GTK_RADIO_BUTTON (button)),
_("Free movement (doesn't disturb other applets)"));
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (set_movement),
(gpointer)PANEL_FREE_MOVE);
if (temp_config.movement_type == PANEL_FREE_MOVE)
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (button), TRUE);
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE,
CONFIG_PADDING_SIZE);
return (vbox);
}
......
#include "panel-widget.h"
#ifndef PANEL_CONFIG_GLOBAL_H
#define PANEL_CONFIG_GLOBAL_H
......@@ -9,6 +11,7 @@ struct _GlobalConfig {
gint minimize_delay;
gint tooltips_enabled;
gint show_small_icons;
PanelMovementType movement_type;
};
......
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