~ubuntu-branches/ubuntu/lucid/quick-lounge-applet/lucid

« back to all changes in this revision

Viewing changes to src/quick-box.c

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Rottmann
  • Date: 2004-12-16 13:06:08 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20041216130608-i7tq2h21kzrdy4yl
Tags: 2.2.0-1
* New upstream release.
* Build-Depend on debhelper (>= 4.1.0), fixes linda error.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
/*
4
4
 *  Quick Lounge Applet
5
5
 *
6
 
 *  Copyright (C) 2001 The Free Software Foundation, Inc.
 
6
 *  Copyright (C) 2001, 2004 Free Software Foundation, Inc.
7
7
 *
8
8
 *  This program is free software; you can redistribute it and/or modify
9
9
 *  it under the terms of the GNU General Public License as published by
188
188
        min_columns = MAX (min_columns, 0);
189
189
 
190
190
        max_columns = p->max_visible_cols;
191
 
        max_columns = MAX (max_columns, 1);
 
191
        max_columns = MAX (max_columns, 0);
192
192
        max_columns = MAX (max_columns, min_columns);
193
193
 
194
194
        /**/
258
258
                           && QUICK_IS_SEPARATOR (child->widget)) {
259
259
                        
260
260
                        if (max_column_height != 0) {
261
 
                                p->col_size[col - 1] = max_column_height + spacing;
262
 
                                p->buttons_on_col[col - 1] = row - 1;
263
 
                                cur_size += p->col_size[col - 1];
264
 
                                if (col == min_columns)
 
261
                                p->col_size[row - 1] = max_column_height + spacing;
 
262
                                p->buttons_on_col[row - 1] = col - 1;
 
263
                                cur_size += p->col_size[row - 1];
 
264
                                if (row == min_columns)
265
265
                                        min_size = cur_size;
266
 
                                if (col == max_columns)
 
266
                                if (row == max_columns)
267
267
                                        max_size = cur_size;
268
268
                                max_column_height = 0;
269
 
                                col++;
270
 
                                row = 1;
 
269
                                row++;
 
270
                                col = 1;
271
271
                        }
272
272
                        
273
 
                        p->col_size[col - 1] = child_requisition.height + spacing;
274
 
                        p->buttons_on_col[col - 1] = 1;
275
 
                        cur_size += p->col_size[col - 1];
276
 
                        if (col == min_columns)
 
273
                        p->col_size[row - 1] = child_requisition.height + spacing;
 
274
                        p->buttons_on_col[row - 1] = 1;
 
275
                        cur_size += p->col_size[row - 1];
 
276
                        if (row == min_columns)
277
277
                                min_size = cur_size;
278
 
                        if (col == max_columns)
 
278
                        if (row == max_columns)
279
279
                                max_size = cur_size;
280
280
                        max_column_height = 0;
281
 
                        col++;
282
 
                        row = 1;
 
281
                        row++;
 
282
                        col = 1;
283
283
 
284
284
                } else if ((orientation == GTK_ORIENTATION_VERTICAL)
285
285
                           && QUICK_IS_BUTTON (child->widget)) {
287
287
                        max_column_height = MAX (max_column_height, 
288
288
                                                 child_requisition.height);
289
289
 
290
 
                        if (row++ == p->rows) {
291
 
                                p->col_size[col - 1] = max_column_height + spacing;
292
 
                                p->buttons_on_col[col - 1] = row - 1;
293
 
                                cur_size += p->col_size[col - 1];
294
 
                                if (col == min_columns)
 
290
                        if (col++ == p->rows) {
 
291
                                p->col_size[row - 1] = max_column_height + spacing;
 
292
                                p->buttons_on_col[row - 1] = col - 1;
 
293
                                cur_size += p->col_size[row - 1];
 
294
                                if (row == min_columns)
295
295
                                        min_size = cur_size;
296
 
                                if (col == max_columns)
 
296
                                if (row == max_columns)
297
297
                                        max_size = cur_size;
298
298
                                max_column_height = 0;
299
 
                                col++;
300
 
                                row = 1;
 
299
                                row++;
 
300
                                col = 1;
301
301
                        }
302
302
                }
303
303
        }
310
310
                }
311
311
        } else {
312
312
                if (max_column_height != 0) {
313
 
                        p->col_size[col - 1] = max_column_height + spacing;
314
 
                        p->buttons_on_col[col - 1] = row - 1;
315
 
                        cur_size += p->col_size[col - 1];
 
313
                        p->col_size[row - 1] = max_column_height + spacing;
 
314
                        p->buttons_on_col[row - 1] = col - 1;
 
315
                        cur_size += p->col_size[row - 1];
316
316
                }
317
317
        }
318
318
 
319
 
        if (col <= min_columns)
320
 
                min_size = cur_size;
321
 
        if (col <= max_columns)
322
 
                max_size = cur_size;
 
319
        if (orientation == GTK_ORIENTATION_HORIZONTAL) {
 
320
                if (col <= min_columns)
 
321
                        min_size = cur_size;
 
322
                if (col <= max_columns)
 
323
                        max_size = cur_size;
 
324
        } else {
 
325
                if (row <= min_columns)
 
326
                        min_size = cur_size;
 
327
                if (row <= max_columns)
 
328
                        max_size = cur_size;
 
329
        }
323
330
 
324
331
        min_size += spacing + INITIAL_OFFSET * 2;
325
332
        max_size += spacing + INITIAL_OFFSET * 2;
334
341
        if (orientation == GTK_ORIENTATION_HORIZONTAL) { 
335
342
                min_size += spacing + arrow_width;
336
343
                max_size += spacing + arrow_width;
 
344
                if (box->children == NULL) /* when the box is empty */
 
345
                        min_size = p->size / p->rows; 
 
346
                requisition->width = min_size;
 
347
                requisition->height = MAX (p->size, arrow_height);
 
348
                p->size_hint[SIZE_HINT_MAX] = max_size - requisition->width;
337
349
        } else {
338
350
                min_size += spacing + arrow_height;
339
351
                max_size += spacing + arrow_height;
340
 
        }
341
 
 
342
 
        if (box->children == NULL) /* when the box is empty */
343
 
                min_size = p->size / p->rows; 
344
 
 
345
 
        /**/
346
 
 
347
 
        if (orientation == GTK_ORIENTATION_HORIZONTAL) {
348
 
                requisition->width = min_size;
349
 
                requisition->height = MAX (p->size, arrow_height);
350
 
        } else {
 
352
                if (box->children == NULL) /* when the box is empty */
 
353
                        min_size = p->size / p->rows; 
351
354
                requisition->width = MAX (p->size, arrow_width);
352
355
                requisition->height = min_size;
353
 
        }
354
 
 
355
 
        /**/
356
 
 
357
 
        if (orientation == GTK_ORIENTATION_HORIZONTAL) 
358
 
                p->size_hint[SIZE_HINT_MAX] = max_size - requisition->width;
359
 
        else
360
356
                p->size_hint[SIZE_HINT_MAX] = max_size - requisition->height;
 
357
        }
 
358
 
361
359
        p->size_hint[SIZE_HINT_MIN] = 0;
362
360
 
363
361
        /* FIXME
373
371
 
374
372
        requisition->width += GTK_CONTAINER (box)->border_width * 2;
375
373
        requisition->height += GTK_CONTAINER (box)->border_width * 2;
 
374
 
 
375
#ifdef DEBUG
 
376
        g_print ("REQ [%d, %d]", requisition->width, requisition->height);
 
377
#endif
376
378
}
377
379
 
378
380
 
565
567
                initial_y = (allocation->height - (get_child_size (quick_box) + ICON_SPACING) * quick_box->priv->rows) / 2;
566
568
 
567
569
        } else {
568
 
                initial_x = allocation->x + border_width;
569
 
 
570
570
                /* center horizontally */
571
571
                initial_x = (allocation->width - (get_child_size (quick_box) + ICON_SPACING) * quick_box->priv->rows) / 2;
572
 
                
 
572
 
573
573
                initial_y = allocation->y + border_width + spacing + INITIAL_OFFSET;
574
574
        }
575
575
 
589
589
        current_width  = initial_x;
590
590
        current_height = initial_y;
591
591
 
592
 
        under_arrow_children = children_under_the_arrow (quick_box, arrow_width);
 
592
        if (orientation == GTK_ORIENTATION_HORIZONTAL)
 
593
                under_arrow_children = children_under_the_arrow (quick_box, arrow_width);
 
594
        else
 
595
                under_arrow_children = children_under_the_arrow (quick_box, arrow_height);
593
596
        ignoring_arrow = TRUE;
594
597
 
595
598
        for (children = box->children; children; ) {
616
619
                else
617
620
                        current_width += child_allocation.width;
618
621
 
 
622
 
 
623
                if (orientation == GTK_ORIENTATION_HORIZONTAL) {
 
624
 
619
625
#ifdef DEBUG
620
 
                g_print ("\n");
621
 
                g_print ("[X] %d <--> %d\n", x + child_allocation.width, max_width);
622
 
                g_print ("[Y] %d <--> %d\n", current_height, max_height);
 
626
                        g_print ("\n");
 
627
                        g_print ("[X] %d <--> %d\n", x + child_allocation.width, max_width);
 
628
                        g_print ("[Y] %d <--> %d\n", current_height, max_height);
623
629
#endif
624
 
 
625
 
                if (orientation == GTK_ORIENTATION_HORIZONTAL) {
 
630
                        
626
631
                        if (x + child_allocation.width > max_width) {
627
632
                                if (! do_not_fit) {
628
633
                                        do_not_fit = TRUE;
634
639
                                        hide_from_here = children;
635
640
                                } else {
636
641
                                        x += max_line_width + spacing;
637
 
                                        y  = initial_y;
638
 
                                        current_height  = border_width;
639
 
                                        max_line_width  = 0;
 
642
                                        y = initial_y;
 
643
                                        current_height = border_width;
 
644
                                        max_line_width = 0;
640
645
                                        second_try = TRUE;
641
646
                                        continue;
642
647
                                }
643
648
                        }
644
649
                } else {
 
650
                        
 
651
#ifdef DEBUG
 
652
                        g_print ("\n");
 
653
                        g_print ("[X] %d <--> %d\n", current_width, max_width);
 
654
                        g_print ("[Y] %d <--> %d\n", y + child_allocation.height, max_height);
 
655
                        
 
656
#endif
 
657
                        
645
658
                        if (y + child_allocation.height > max_height) {
646
659
                                if (! do_not_fit) {
647
660
                                        do_not_fit = TRUE;
652
665
                                        do_not_fit = TRUE;
653
666
                                        hide_from_here = children;
654
667
                                } else {
655
 
                                        x  = initial_x;
 
668
                                        x = initial_x;
656
669
                                        y += max_line_height + spacing;
657
 
                                        current_width    = border_width;
658
 
                                        max_line_height  = 0;
 
670
                                        current_width = border_width;
 
671
                                        max_line_height = 0;
659
672
                                        second_try = TRUE;
660
673
                                        continue;
661
674
                                }
1083
1096
        GList      *children;
1084
1097
        gboolean    menu_empty = TRUE;
1085
1098
 
 
1099
        gtk_tooltips_set_tip (quick_box->tooltips, 
 
1100
                              GTK_WIDGET (tbutton),
 
1101
                              _("Hide launchers menu"),
 
1102
                              NULL);
 
1103
 
1086
1104
        if (quick_box->priv->popup_menu != NULL) {
1087
1105
                gtk_menu_shell_deactivate (GTK_MENU_SHELL (quick_box->priv->popup_menu));
1088
1106
                return TRUE;
1225
1243
                                         quick_box);
1226
1244
        
1227
1245
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (arrow), FALSE);
 
1246
        gtk_tooltips_set_tip (quick_box->tooltips, 
 
1247
                              arrow,
 
1248
                              _("Show hidden launchers"),
 
1249
                              NULL);
1228
1250
        
1229
1251
        g_signal_handlers_unblock_by_func (G_OBJECT (arrow),
1230
1252
                                           G_CALLBACK (arrow_button_pressed),
1249
1271
        gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
1250
1272
        gtk_widget_set_parent (button, GTK_WIDGET (quick_box));
1251
1273
 
 
1274
        gtk_tooltips_set_tip (quick_box->tooltips, 
 
1275
                              button,
 
1276
                              _("Show hidden launchers"),
 
1277
                              NULL);
 
1278
 
1252
1279
        g_signal_connect (G_OBJECT (button), 
1253
1280
                          "toggled",
1254
1281
                          G_CALLBACK (arrow_button_pressed), 
1283
1310
        priv->populate_menu_func = NULL;
1284
1311
        priv->populate_menu_data = NULL;
1285
1312
 
 
1313
        quick_box->tooltips = gtk_tooltips_new ();
 
1314
        g_object_ref (quick_box->tooltips);
 
1315
        gtk_object_sink (GTK_OBJECT (quick_box->tooltips));
 
1316
 
1286
1317
        priv->arrow_up    = create_arrow_button (quick_box, GTK_ARROW_UP);
1287
1318
        priv->arrow_down  = create_arrow_button (quick_box, GTK_ARROW_DOWN);
1288
1319
        priv->arrow_left  = create_arrow_button (quick_box, GTK_ARROW_LEFT);
1289
1320
        priv->arrow_right = create_arrow_button (quick_box, GTK_ARROW_RIGHT);
1290
 
 
1291
 
        quick_box->tooltips = gtk_tooltips_new ();
1292
 
        g_object_ref (quick_box->tooltips);
1293
 
        gtk_object_sink (GTK_OBJECT (quick_box->tooltips));
1294
1321
}
1295
1322
 
1296
1323