673
panel_widget_jump_applet_right (PanelWidget *panel,
679
AppletData *nad = NULL;
685
if (pos >= panel->size)
688
if (!nad || nad->constrained >= pos + ad->min_cells)
691
if (!panel_widget_push_applet_right (panel, next, pos + ad->min_cells - nad->constrained)) {
692
panel_widget_jump_applet_right (panel,
695
nad->constrained + nad->min_cells);
700
ad->pos = ad->constrained = pos;
701
panel->applet_list = g_list_remove_link (panel->applet_list, list);
702
panel->applet_list = panel_g_list_insert_before (panel->applet_list, next, list);
703
gtk_widget_queue_resize (GTK_WIDGET (panel));
704
emit_applet_moved (panel, ad);
559
panel_widget_compress_pack_indexes_list (PanelWidget *panel,
566
for (l = list, index = 0; l; l = l->next, index++) {
568
if (ad->pack_index != index) {
569
ad->pack_index = index;
570
emit_applet_moved (panel, ad);
575
/* make sure our lists always start at 0 */
577
panel_widget_compress_pack_indexes (PanelWidget *panel)
581
list = get_applet_list_pack (panel, PANEL_OBJECT_PACK_START);
582
panel_widget_compress_pack_indexes_list (panel, list);
585
list = get_applet_list_pack (panel, PANEL_OBJECT_PACK_CENTER);
586
panel_widget_compress_pack_indexes_list (panel, list);
589
list = get_applet_list_pack (panel, PANEL_OBJECT_PACK_END);
590
list = g_list_reverse (list);
591
panel_widget_compress_pack_indexes_list (panel, list);
596
panel_widget_update_size_hints_for_toplevel (PanelWidget *panel)
599
GList *ad_with_hints = NULL;
601
panel->nb_applets_size_hints = 0;
602
if (panel->applets_hints != NULL)
603
g_free (panel->applets_hints);
604
panel->applets_hints = NULL;
605
if (panel->applets_using_hint != NULL)
606
g_free (panel->applets_using_hint);
607
panel->applets_using_hint = NULL;
612
for (list = panel->applet_list; list; list = list->next) {
613
AppletData *ad = list->data;
614
if (ad->expand_major && ad->size_hints)
615
ad_with_hints = g_list_prepend (ad_with_hints, ad);
618
/* put the list in the correct order: this is important
619
* since we'll use this order in the size_allocate() */
620
ad_with_hints = g_list_reverse (ad_with_hints);
622
panel->nb_applets_size_hints = g_list_length (ad_with_hints);
624
if (panel->nb_applets_size_hints > 0) {
626
panel->applets_hints = g_new0 (AppletSizeHints,
627
panel->nb_applets_size_hints);
628
panel->applets_using_hint = g_new0 (AppletSizeHintsAlloc,
629
panel->nb_applets_size_hints);
632
for (list = ad_with_hints;
634
list = g_list_next (list)) {
635
AppletData *ad = list->data;
637
panel->applets_hints[i].hints = ad->size_hints;
638
panel->applets_hints[i].len = ad->size_hints_len;
644
/* Note: this can only be called at the beginning of size_allocate, which means
645
* that ad->constrained doesn't matter yet (it will be set to the correct
646
* value in size_allocate). */
648
panel_widget_update_positions_packed_start (PanelWidget *panel)
658
list = get_applet_list_pack (panel, PANEL_OBJECT_PACK_START);
660
/* get size used by the objects */
661
for (l = list; l; l = l->next) {
663
size_all += ad->cells;
666
/* update absolute position of all applets based on this information,
667
* starting with the first object */
673
ad->constrained = pos_next;
674
pos_next += ad->cells;
681
/* Note: only use this function when you can; see comment above
682
* panel_widget_update_positions_packed_start()
683
* For center specifically, we require ad->cells to be set. Note that we don't
684
* care much about min_cells: if we need it, this means objects will have to be
685
* pushed to accomodate other objects, which will kill centering anyway.
686
* (FIXME: hrm, not that sure about it ;-)) */
688
panel_widget_update_positions_packed_center (PanelWidget *panel)
698
list = get_applet_list_pack (panel, PANEL_OBJECT_PACK_CENTER);
700
/* get size used by the objects */
701
for (l = list; l; l = l->next) {
703
size_all += ad->cells;
706
/* update absolute position of all applets based on this information,
707
* starting with the first centered object */
708
pos_next = (panel->size - size_all) / 2;
713
ad->constrained = pos_next;
714
pos_next += ad->cells;
721
/* Note: only use this function when you can; see comment above
722
* panel_widget_update_positions_packed_start() */
724
panel_widget_update_positions_packed_end (PanelWidget *panel)
734
list = get_applet_list_pack (panel, PANEL_OBJECT_PACK_END);
736
/* get size used by the objects */
737
for (l = list; l; l = l->next) {
739
size_all += ad->cells;
742
/* update absolute position of all applets based on this information,
743
* starting with the first object */
744
pos_next = panel->size - size_all;
749
ad->constrained = pos_next;
750
pos_next += ad->cells;
758
panel_widget_update_positions (PanelWidget *panel)
767
/* Because of the following, we have to be very careful that
768
* this code path is called only before a size_request() on the
770
panel_widget_update_size_hints_for_toplevel (panel);
772
/* keep in sync with code in size_allocate */
773
for (list = panel->applet_list;
775
list = g_list_next (list)) {
781
/* Re-compute the ideal position of objects, based on their size */
782
panel_widget_update_positions_packed_start (panel);
783
panel_widget_update_positions_packed_center (panel);
784
panel_widget_update_positions_packed_end (panel);
786
/* Second pass: try to position from the start, to make sure
787
* there's enough room. We don't use size hints yet. */
788
for (list = panel->applet_list;
790
list = g_list_next (list)) {
792
if (ad->constrained < i)
795
i = ad->constrained + ad->cells;
798
/* Third pass: now expand from the end, and start using size
799
* hints if we need more room */
801
for(list = g_list_last(panel->applet_list);
803
list = g_list_previous(list)) {
807
if (ad->constrained + ad->min_cells > i)
808
ad->constrained = MAX (i - ad->min_cells, 0);
810
if (ad->expand_major) {
811
cells = (i - ad->constrained) - 1;
814
cells = get_size_from_hints (ad, cells);
815
cells = MAX (cells, ad->min_cells);
816
cells = MIN (cells, panel->size);
824
/* EEEEK, there's not enough room, so shift applets even
825
* at the expense of perhaps running out of room on the
826
* right if there is no free space in the middle */
829
for(list = panel->applet_list;
831
list = g_list_next(list)) {
834
if (ad->constrained < i)
837
i = ad->constrained + ad->cells;
844
panel_widget_get_moveby (PanelWidget *panel,
847
/* move relative to the center of the object */
848
return panel_widget_get_cursorloc (panel) - ad->constrained - ad->cells / 2;
852
panel_widget_move_get_pos_pack (PanelWidget *panel,
853
PanelObjectPackType pack_type)
856
case PANEL_OBJECT_PACK_START:
859
case PANEL_OBJECT_PACK_CENTER:
860
return panel->size / 2;
862
case PANEL_OBJECT_PACK_END:
866
g_assert_not_reached ();
874
panel_widget_move_get_pos_next_pack (PanelWidget *panel,
878
if (!nad || nad->pack_type > ad->pack_type + 1)
879
return panel_widget_move_get_pos_pack (panel, ad->pack_type + 1);
881
return nad->constrained;
885
panel_widget_move_get_pos_prev_pack (PanelWidget *panel,
889
if (!pad || pad->pack_type < ad->pack_type - 1)
890
return panel_widget_move_get_pos_pack (panel, ad->pack_type - 1);
892
return pad->constrained + pad->cells;
896
panel_widget_move_to_pack (PanelWidget *panel,
898
PanelObjectPackType new_pack_type,
903
if (pack_index >= 0) {
904
for (l = panel->applet_list; l; l = l->next) {
905
AppletData *ad_to_move = l->data;
906
if (ad_to_move->pack_type == new_pack_type &&
907
ad_to_move->pack_index >= pack_index) {
908
ad_to_move->pack_index++;
909
emit_applet_moved (panel, ad_to_move);
913
pack_index = panel_widget_get_new_pack_index (panel, new_pack_type);
915
ad->pack_type = new_pack_type;
916
ad->pack_index = pack_index;
923
/* if force_switch is set, moveby will be ignored */
708
925
panel_widget_switch_applet_right (PanelWidget *panel,
928
gboolean force_switch)
712
AppletData *nad = NULL;
714
g_assert (list != NULL);
717
if (ad->constrained + ad->min_cells >= panel->size)
721
nad = list->next->data;
723
if (!nad || nad->constrained >= ad->constrained + ad->min_cells + MOVE_INCREMENT) {
724
ad->pos = ad->constrained += MOVE_INCREMENT;
937
if (panel->packed && !list->next)
940
if (ad->pack_type == PANEL_OBJECT_PACK_END && !list->next)
943
/* count moveby from end of object => remove distance to go there */
944
moveby -= ad->cells / 2;
946
nad = list->next ? list->next->data : NULL;
948
/* Move inside same pack */
949
if (nad && nad->pack_type == ad->pack_type) {
951
(moveby >= nad->cells / 2)) {
952
swap_index = ad->pack_index;
953
ad->pack_index = nad->pack_index;
954
nad->pack_index = swap_index;
956
panel->applet_list = panel_g_list_swap_next (panel->applet_list, list);
958
emit_applet_moved (panel, nad);
959
emit_applet_moved (panel, ad);
961
panel_widget_update_positions (panel);
962
gtk_widget_queue_resize (GTK_WIDGET (panel));
969
/* Move to next pack */
970
next_pos = panel_widget_move_get_pos_next_pack (panel, ad, nad);
972
(moveby >= (next_pos - (ad->constrained + ad->cells)) / 2)) {
973
if (ad->pack_type + 1 == PANEL_OBJECT_PACK_END)
974
panel_widget_move_to_pack (panel, ad, ad->pack_type + 1, -1);
976
panel_widget_move_to_pack (panel, ad, ad->pack_type + 1, 0);
978
emit_applet_moved (panel, ad);
980
panel_widget_update_positions (panel);
725
981
gtk_widget_queue_resize (GTK_WIDGET (panel));
726
emit_applet_moved (panel, ad);
731
panel_widget_jump_applet_right (panel,
734
nad->constrained + nad->min_cells);
738
nad->constrained = nad->pos = ad->constrained;
739
ad->constrained = ad->pos = ad->constrained + nad->min_cells;
740
panel->applet_list = panel_g_list_swap_next (panel->applet_list, list);
742
gtk_widget_queue_resize (GTK_WIDGET (panel));
744
emit_applet_moved (panel, ad);
745
emit_applet_moved (panel, nad);
749
panel_widget_jump_applet_left (PanelWidget *panel,
755
AppletData *pad = NULL;
764
if (!pad || pad->constrained + pad->min_cells <= pos)
767
if (!panel_widget_push_applet_left (panel, prev, pad->constrained + pad->min_cells - pos)) {
768
panel_widget_jump_applet_left (panel,
771
pad->constrained - ad->min_cells);
776
ad->pos = ad->constrained = pos;
777
panel->applet_list = g_list_remove_link (panel->applet_list, list);
778
panel->applet_list = panel_g_list_insert_after (panel->applet_list, prev, list);
779
gtk_widget_queue_resize (GTK_WIDGET (panel));
780
emit_applet_moved (panel, ad);
989
/* if force_switch is set, moveby will be ignored */
784
991
panel_widget_switch_applet_left (PanelWidget *panel,
994
gboolean force_switch)
788
AppletData *pad = NULL;
790
1001
ad = list->data;
791
if (ad->constrained <= 0)
795
pad = list->prev->data;
797
if (!pad || pad->constrained + pad->min_cells <= ad->constrained - MOVE_INCREMENT) {
798
ad->pos = ad->constrained -= MOVE_INCREMENT;
1003
if (panel->packed && !list->prev)
1006
if (ad->pack_type == PANEL_OBJECT_PACK_START && !list->prev)
1009
/* count moveby from start of object => add distance to go there */
1010
moveby += ad->cells / 2;
1012
pad = list->prev ? list->prev->data : NULL;
1014
/* Move inside same pack */
1015
if (pad && pad->pack_type == ad->pack_type) {
1017
(moveby <= - pad->cells / 2)) {
1018
swap_index = ad->pack_index;
1019
ad->pack_index = pad->pack_index;
1020
pad->pack_index = swap_index;
1022
panel->applet_list = panel_g_list_swap_prev (panel->applet_list, list);
1024
emit_applet_moved (panel, ad);
1025
emit_applet_moved (panel, pad);
1027
panel_widget_update_positions (panel);
1028
gtk_widget_queue_resize (GTK_WIDGET (panel));
1035
/* Move to prev pack */
1036
prev_pos = panel_widget_move_get_pos_prev_pack (panel, ad, pad);
1038
(moveby <= - ((ad->constrained - prev_pos) / 2))) {
1039
panel_widget_move_to_pack (panel, ad, ad->pack_type - 1, -1);
1040
emit_applet_moved (panel, ad);
1042
panel_widget_update_positions (panel);
799
1043
gtk_widget_queue_resize (GTK_WIDGET (panel));
800
emit_applet_moved (panel, ad);
805
panel_widget_jump_applet_left (panel,
808
pad->constrained - ad->min_cells);
812
ad->constrained = ad->pos = pad->constrained;
813
pad->constrained = pad->pos = ad->constrained + ad->min_cells;
814
panel->applet_list = panel_g_list_swap_prev (panel->applet_list, list);
816
gtk_widget_queue_resize (GTK_WIDGET (panel));
818
emit_applet_moved (panel, ad);
819
emit_applet_moved (panel, pad);
823
panel_widget_try_push_right (PanelWidget *panel,
828
AppletData *nad = NULL;
830
g_assert (list != NULL);
834
nad = list->next->data;
839
if (ad->constrained + ad->min_cells + push >= panel->size)
842
if (!nad || nad->constrained >= ad->constrained + ad->min_cells + push)
845
return panel_widget_try_push_right (panel, list->next, push);
849
panel_widget_get_right_jump_pos (PanelWidget *panel,
854
AppletData *nad = NULL;
859
if (!nad || nad->constrained >= pos + ad->min_cells)
862
if (panel_widget_try_push_right (panel, next, pos + ad->min_cells - nad->constrained))
865
return panel_widget_get_right_jump_pos (panel,
868
nad->constrained + nad->min_cells);
872
panel_widget_get_right_switch_pos (PanelWidget *panel,
876
AppletData *nad = NULL;
878
g_assert (list != NULL);
882
nad = list->next->data;
884
if (!nad || nad->constrained >= ad->constrained + ad->min_cells + MOVE_INCREMENT)
885
return ad->constrained + MOVE_INCREMENT;
888
return panel_widget_get_right_jump_pos (panel,
891
nad->constrained + nad->min_cells);
893
return nad->constrained + nad->min_cells - ad->cells;
897
panel_widget_try_push_left (PanelWidget *panel,
902
AppletData *pad = NULL;
904
g_assert (list != NULL);
908
pad = list->prev->data;
913
if (ad->constrained - push < 0)
916
if (!pad || pad->constrained + pad->min_cells <= ad->constrained - push)
919
return panel_widget_try_push_left (panel, list->prev, push);
923
panel_widget_get_left_jump_pos (PanelWidget *panel,
928
AppletData *pad = NULL;
933
if (!pad || pad->constrained + pad->min_cells <= pos)
936
if (panel_widget_try_push_left (panel, prev, pad->constrained + pad->min_cells - pos))
939
return panel_widget_get_left_jump_pos (panel,
942
pad->constrained - ad->min_cells);
946
panel_widget_get_left_switch_pos (PanelWidget *panel,
950
AppletData *pad = NULL;
952
g_assert (list != NULL);
956
pad = list->prev->data;
958
if (!pad || pad->constrained + pad->min_cells <= ad->constrained - MOVE_INCREMENT)
959
return ad->constrained - MOVE_INCREMENT;
962
return panel_widget_get_left_jump_pos (panel,
965
pad->constrained - ad->min_cells);
967
return pad->constrained;
971
1052
panel_widget_switch_move (PanelWidget *panel,
979
1059
g_return_if_fail (ad != NULL);
980
1060
g_return_if_fail (PANEL_IS_WIDGET (panel));
985
1062
list = g_list_find (panel->applet_list, ad);
986
1063
g_return_if_fail (list != NULL);
988
finalpos = ad->constrained + moveby;
990
if (ad->constrained < finalpos) {
994
pad = list->prev->data;
995
if (pad->expand_major)
996
gtk_widget_queue_resize (GTK_WIDGET (panel));
999
while (ad->constrained < finalpos) {
1000
pos = panel_widget_get_right_switch_pos (panel, list);
1002
if (abs (pos - finalpos) >= abs (ad->constrained - finalpos) ||
1003
pos + ad->min_cells > panel->size)
1006
panel_widget_switch_applet_right (panel, list);
1010
pad = list->prev->data;
1011
if (pad->expand_major)
1012
gtk_widget_queue_resize (GTK_WIDGET (panel));
1065
moveby = panel_widget_get_moveby (panel, ad);
1067
if (moveby > ad->cells / 2) {
1069
while (moved && moveby > ad->cells / 2) {
1070
moved = panel_widget_switch_applet_right (panel, list,
1072
moveby = panel_widget_get_moveby (panel, ad);
1018
nad = list->next->data;
1019
if (nad->expand_major)
1020
gtk_widget_queue_resize (GTK_WIDGET (panel));
1023
while (ad->constrained > finalpos) {
1024
pos = panel_widget_get_left_switch_pos (panel, list);
1026
if (abs (pos - finalpos) >= abs (ad->constrained - finalpos) || pos < 0)
1029
panel_widget_switch_applet_left (panel, list);
1076
while (moved && moveby < - ad->cells / 2) {
1077
moved = panel_widget_switch_applet_left (panel, list,
1079
moveby = panel_widget_get_moveby (panel, ad);
1036
1085
panel_widget_push_applet_right (PanelWidget *panel,
1088
gboolean force_switch)
1040
1090
AppletData *ad;
1041
AppletData *nad = NULL;
1092
PanelObjectPackType new_pack_type;
1094
GList *last_in_pack;
1043
g_assert (list != NULL);
1045
1097
ad = list->data;
1046
if (ad->constrained + ad->min_cells + push >= panel->size)
1053
nad = list->next->data;
1055
if (!nad || nad->constrained >= ad->constrained + ad->min_cells + push) {
1056
ad->pos = ad->constrained += push;
1057
gtk_widget_queue_resize (GTK_WIDGET (panel));
1099
if (ad->pack_type == PANEL_OBJECT_PACK_END)
1102
/* count moveby from end of object => remove distance to go there */
1103
moveby -= ad->cells / 2;
1105
new_pack_type = ad->pack_type + 1;
1107
for (l = list; l && l->next; l = l->next) {
1108
nad = l->next->data;
1109
if (nad->pack_type != ad->pack_type)
1115
nad = last_in_pack->next ? last_in_pack->next->data : NULL;
1116
next_pos = panel_widget_move_get_pos_next_pack (panel, ad, nad);
1118
if (!force_switch &&
1119
(moveby < (next_pos - (ad->constrained + ad->cells)) / 2))
1122
for (l = last_in_pack; l; l = l->prev) {
1125
if (new_pack_type == PANEL_OBJECT_PACK_END)
1126
panel_widget_move_to_pack (panel, ad, new_pack_type, -1);
1128
panel_widget_move_to_pack (panel, ad, new_pack_type, 0);
1058
1130
emit_applet_moved (panel, ad);
1062
g_assert (list->next != NULL);
1064
if (!panel_widget_push_applet_right (panel, list->next, push))
1067
ad->pos = ad->constrained += push;;
1136
panel_widget_update_positions (panel);
1068
1137
gtk_widget_queue_resize (GTK_WIDGET (panel));
1069
emit_applet_moved (panel, ad);
1075
1143
panel_widget_push_applet_left (PanelWidget *panel,
1146
gboolean force_switch)
1079
1148
AppletData *ad;
1080
AppletData *pad = NULL;
1082
g_assert (list != NULL);
1150
PanelObjectPackType new_pack_type;
1152
GList *first_in_pack;
1084
1155
ad = list->data;
1085
if (ad->constrained - push < 0)
1092
pad = list->prev->data;
1094
if (!pad || pad->constrained + pad->min_cells <= ad->constrained - push) {
1095
ad->pos = ad->constrained -= push;
1096
gtk_widget_queue_resize (GTK_WIDGET (panel));
1157
if (ad->pack_type == PANEL_OBJECT_PACK_START)
1160
/* count moveby from start of object => add distance to go there */
1161
moveby += ad->cells / 2;
1163
new_pack_type = ad->pack_type - 1;
1165
for (l = list; l && l->prev; l = l->prev) {
1166
pad = l->prev->data;
1167
if (pad->pack_type != ad->pack_type)
1173
pad = first_in_pack->prev ? first_in_pack->prev->data : NULL;
1174
prev_pos = panel_widget_move_get_pos_prev_pack (panel, ad, pad);
1176
if (!force_switch &&
1177
(moveby > - ((ad->constrained - prev_pos) / 2)))
1180
for (l = first_in_pack; l; l = l->next) {
1183
panel_widget_move_to_pack (panel, ad, new_pack_type, -1);
1097
1184
emit_applet_moved (panel, ad);
1101
g_assert (list->prev != NULL);
1103
if (!panel_widget_push_applet_left (panel, list->prev, push))
1106
ad->pos = ad->constrained -= push;
1190
panel_widget_update_positions (panel);
1107
1191
gtk_widget_queue_resize (GTK_WIDGET (panel));
1108
emit_applet_moved (panel, ad);
1114
1197
panel_widget_push_move (PanelWidget *panel,
1115
1198
AppletData *ad,
1205
/* direction is only used when we move with keybindings */
1122
1207
g_return_if_fail (ad != NULL);
1123
1208
g_return_if_fail (PANEL_IS_WIDGET (panel));
1128
1210
list = g_list_find (panel->applet_list, ad);
1129
1211
g_return_if_fail (list != NULL);
1131
finalpos = ad->constrained + moveby;
1133
if (ad->constrained < finalpos) {
1134
while (ad->constrained < finalpos)
1135
if (!panel_widget_push_applet_right (panel, list, 1))
1213
moveby = panel_widget_get_moveby (panel, ad);
1215
if (direction > 0 || moveby > ad->cells / 2) {
1217
while (direction > 0 ||
1218
(moved && moveby > ad->cells / 2)) {
1219
moved = panel_widget_push_applet_right (panel, list,
1222
moveby = panel_widget_get_moveby (panel, ad);
1224
/* a keybinding pushes only once */
1139
pad = list->prev->data;
1140
if (pad->expand_major)
1141
gtk_widget_queue_resize (GTK_WIDGET (panel));
1144
while (ad->constrained > finalpos)
1145
if (!panel_widget_push_applet_left (panel, list, 1))
1230
while (direction < 0 ||
1231
(moved && moveby < ad->cells / 2)) {
1232
moved = panel_widget_push_applet_left (panel, list,
1235
moveby = panel_widget_get_moveby (panel, ad);
1237
/* a keybinding pushes only once */
1151
/*this is a special function and may fail if called improperly, it works
1152
only under special circumstance when we know there is nothing from
1153
old_size to panel->size*/
1155
panel_widget_right_stick(PanelWidget *panel,int old_size)
1161
g_return_if_fail(PANEL_IS_WIDGET(panel));
1162
g_return_if_fail(old_size>=0);
1164
if(old_size>=panel->size ||
1168
list = get_applet_list_pos(panel,old_size-1);
1173
pos = panel->size-1;
1178
ad->pos = ad->constrained = pos--;
1181
list = g_list_previous(list);
1185
} while(ad->pos + ad->cells == i);
1187
for (list = prev; list; list = list->next)
1188
emit_applet_moved (panel, list->data);
1192
1245
panel_widget_size_request(GtkWidget *widget, GtkRequisition *requisition)
1194
1247
PanelWidget *panel;
1196
GList *ad_with_hints;
1197
1249
gboolean dont_fill;
1199
1251
g_return_if_fail(PANEL_IS_WIDGET(widget));
1930
/*calculates the value to move the applet by*/
1932
panel_widget_get_moveby (PanelWidget *panel, int pos, int offset)
1934
g_return_val_if_fail (PANEL_IS_WIDGET (panel), -1);
1936
return panel_widget_get_cursorloc (panel) - offset - pos;
1940
walk_up_to (int pos, GList *list)
1944
g_return_val_if_fail (list != NULL, NULL);
1948
if (ad->constrained <= pos &&
1949
ad->constrained + ad->cells > pos)
1951
while (list->next != NULL &&
1952
ad->constrained + ad->cells <= pos) {
1956
while (list->prev != NULL &&
1957
ad->constrained > pos) {
1965
is_in_applet (int pos, AppletData *ad)
1967
g_return_val_if_fail (ad != NULL, NULL);
1969
if (ad->constrained <= pos &&
1970
ad->constrained + ad->min_cells > pos)
1976
panel_widget_get_free_spot (PanelWidget *panel,
1982
int right = -1, left = -1;
1985
g_return_val_if_fail (PANEL_IS_WIDGET (panel), -1);
1986
g_return_val_if_fail (ad != NULL, -1);
1988
if (ad->constrained >= panel->size)
1991
if (panel->applet_list == NULL) {
1992
if (place + ad->min_cells > panel->size)
1993
return panel->size-ad->min_cells;
1998
list = panel->applet_list;
2000
start = place - ad->drag_off;
2003
for (e = 0, i = start; i < panel->size; i++) {
2005
list = walk_up_to (i, list);
2006
applet = is_in_applet (i, list->data);
2007
if (applet == NULL ||
2008
applet == ad->applet) {
2010
if (e >= ad->min_cells) {
2019
start = place + ad->drag_off;
2020
if (start >= panel->size)
2021
start = panel->size - 1;
2022
for (e = 0, i = start; i >= 0; i--) {
2024
list = walk_up_to (i, list);
2025
applet = is_in_applet (i, list->data);
2026
if (applet == NULL ||
2027
applet == ad->applet) {
2029
if (e >= ad->min_cells) {
2038
start = place - ad->drag_off;
2049
return abs (left - start) > abs (right - start) ?
2055
panel_widget_nice_move (PanelWidget *panel,
2059
g_return_if_fail (PANEL_IS_WIDGET (panel));
2060
g_return_if_fail (ad != NULL);
2062
pos = panel_widget_get_free_spot (panel, ad, pos);
2063
if (pos < 0 || pos == ad->pos)
2066
ad->pos = ad->constrained = pos;
2068
panel->applet_list =
2069
panel_g_list_resort_item (panel->applet_list, ad,
2070
(GCompareFunc)applet_data_compare);
2072
gtk_widget_queue_resize (GTK_WIDGET (panel));
2074
emit_applet_moved (panel, ad);
1913
/* get pack type & index for insertion at the cursor location in panel */
1915
panel_widget_get_insert_at_cursor (PanelWidget *widget,
1916
PanelObjectPackType *pack_type,
1923
g_return_if_fail (PANEL_IS_WIDGET (widget));
1925
pos = panel_widget_get_cursorloc (widget);
1927
/* check if cursor is in an object; in this case, return the pack type
1929
for (l = widget->applet_list; l; l = l->next) {
1932
if (ad->constrained <= pos) {
1933
if (ad->constrained + ad->cells > pos) {
1934
*pack_type = ad->pack_type;
1935
*pack_index = ad->pack_index;
1941
if (pos <= widget->size / 2)
1942
*pack_type = PANEL_OBJECT_PACK_START;
1944
*pack_type = PANEL_OBJECT_PACK_END;
1946
*pack_index = panel_widget_get_new_pack_index (widget, *pack_type);
1949
/* get pack type for insertion at the cursor location in panel */
1951
panel_widget_get_insert_pack_type_at_cursor (PanelWidget *panel)
1953
PanelObjectPackType ret = PANEL_OBJECT_PACK_START;
1956
panel_widget_get_insert_at_cursor (panel, &ret, &pack_index);
1961
/* get index for insertion with pack type */
1963
panel_widget_get_new_pack_index (PanelWidget *panel,
1964
PanelObjectPackType pack_type)
1968
int max_pack_index = -1;
1970
for (l = panel->applet_list; l; l = l->next) {
1972
if (ad->pack_type == pack_type)
1973
max_pack_index = MAX (max_pack_index, ad->pack_index);
1976
return max_pack_index + 1;
2077
1979
/* schedule to run the below function */