Mercurial > pidgin
comparison finch/libgnt/gntfilesel.c @ 18556:5e1412f4e67a
Do some work to make pygnt more useful. The dbus-gnt script works fairly
well now.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Tue, 17 Jul 2007 11:09:03 +0000 |
parents | 7122bcebf7c9 |
children | d470282d49da |
comparison
equal
deleted
inserted
replaced
18554:ab58b55f38b0 | 18556:5e1412f4e67a |
---|---|
45 | 45 |
46 static GntWindowClass *parent_class = NULL; | 46 static GntWindowClass *parent_class = NULL; |
47 static guint signals[SIGS] = { 0 }; | 47 static guint signals[SIGS] = { 0 }; |
48 static void (*orig_map)(GntWidget *widget); | 48 static void (*orig_map)(GntWidget *widget); |
49 static void (*orig_size_request)(GntWidget *widget); | 49 static void (*orig_size_request)(GntWidget *widget); |
50 | |
51 static void select_activated_cb(GntWidget *button, GntFileSel *sel); | |
50 | 52 |
51 static void | 53 static void |
52 gnt_file_sel_destroy(GntWidget *widget) | 54 gnt_file_sel_destroy(GntWidget *widget) |
53 { | 55 { |
54 GntFileSel *sel = GNT_FILE_SEL(widget); | 56 GntFileSel *sel = GNT_FILE_SEL(widget); |
598 } | 600 } |
599 | 601 |
600 static void | 602 static void |
601 gnt_file_sel_init(GTypeInstance *instance, gpointer class) | 603 gnt_file_sel_init(GTypeInstance *instance, gpointer class) |
602 { | 604 { |
603 GNTDEBUG; | 605 GntFileSel *sel = GNT_FILE_SEL(instance); |
606 | |
607 sel->dirs = gnt_tree_new(); | |
608 gnt_tree_set_compare_func(GNT_TREE(sel->dirs), (GCompareFunc)g_utf8_collate); | |
609 gnt_tree_set_hash_fns(GNT_TREE(sel->dirs), g_str_hash, g_str_equal, g_free); | |
610 gnt_tree_set_column_titles(GNT_TREE(sel->dirs), "Directories"); | |
611 gnt_tree_set_show_title(GNT_TREE(sel->dirs), TRUE); | |
612 gnt_tree_set_col_width(GNT_TREE(sel->dirs), 0, 20); | |
613 g_signal_connect(G_OBJECT(sel->dirs), "key_pressed", G_CALLBACK(dir_key_pressed), sel); | |
614 | |
615 sel->files = gnt_tree_new_with_columns(2); /* Name, Size */ | |
616 gnt_tree_set_compare_func(GNT_TREE(sel->files), (GCompareFunc)g_utf8_collate); | |
617 gnt_tree_set_column_titles(GNT_TREE(sel->files), "Filename", "Size"); | |
618 gnt_tree_set_show_title(GNT_TREE(sel->files), TRUE); | |
619 gnt_tree_set_col_width(GNT_TREE(sel->files), 0, 25); | |
620 gnt_tree_set_col_width(GNT_TREE(sel->files), 1, 10); | |
621 gnt_tree_set_column_is_right_aligned(GNT_TREE(sel->files), 1, TRUE); | |
622 g_signal_connect(G_OBJECT(sel->files), "selection_changed", G_CALLBACK(file_sel_changed), sel); | |
623 | |
624 /* The location entry */ | |
625 sel->location = gnt_entry_new(NULL); | |
626 g_signal_connect(G_OBJECT(sel->location), "key_pressed", G_CALLBACK(location_key_pressed), sel); | |
627 | |
628 sel->cancel = gnt_button_new("Cancel"); | |
629 sel->select = gnt_button_new("Select"); | |
630 | |
631 g_signal_connect(G_OBJECT(sel->select), "activate", G_CALLBACK(select_activated_cb), sel); | |
604 } | 632 } |
605 | 633 |
606 /****************************************************************************** | 634 /****************************************************************************** |
607 * GntFileSel API | 635 * GntFileSel API |
608 *****************************************************************************/ | 636 *****************************************************************************/ |
645 } | 673 } |
646 | 674 |
647 GntWidget *gnt_file_sel_new(void) | 675 GntWidget *gnt_file_sel_new(void) |
648 { | 676 { |
649 GntWidget *widget = g_object_new(GNT_TYPE_FILE_SEL, NULL); | 677 GntWidget *widget = g_object_new(GNT_TYPE_FILE_SEL, NULL); |
650 GntFileSel *sel = GNT_FILE_SEL(widget); | |
651 | |
652 sel->dirs = gnt_tree_new(); | |
653 gnt_tree_set_compare_func(GNT_TREE(sel->dirs), (GCompareFunc)g_utf8_collate); | |
654 gnt_tree_set_hash_fns(GNT_TREE(sel->dirs), g_str_hash, g_str_equal, g_free); | |
655 gnt_tree_set_column_titles(GNT_TREE(sel->dirs), "Directories"); | |
656 gnt_tree_set_show_title(GNT_TREE(sel->dirs), TRUE); | |
657 gnt_tree_set_col_width(GNT_TREE(sel->dirs), 0, 20); | |
658 g_signal_connect(G_OBJECT(sel->dirs), "key_pressed", G_CALLBACK(dir_key_pressed), sel); | |
659 | |
660 sel->files = gnt_tree_new_with_columns(2); /* Name, Size */ | |
661 gnt_tree_set_compare_func(GNT_TREE(sel->files), (GCompareFunc)g_utf8_collate); | |
662 gnt_tree_set_column_titles(GNT_TREE(sel->files), "Filename", "Size"); | |
663 gnt_tree_set_show_title(GNT_TREE(sel->files), TRUE); | |
664 gnt_tree_set_col_width(GNT_TREE(sel->files), 0, 25); | |
665 gnt_tree_set_col_width(GNT_TREE(sel->files), 1, 10); | |
666 gnt_tree_set_column_is_right_aligned(GNT_TREE(sel->files), 1, TRUE); | |
667 g_signal_connect(G_OBJECT(sel->files), "selection_changed", G_CALLBACK(file_sel_changed), sel); | |
668 | |
669 /* The location entry */ | |
670 sel->location = gnt_entry_new(NULL); | |
671 g_signal_connect(G_OBJECT(sel->location), "key_pressed", G_CALLBACK(location_key_pressed), sel); | |
672 | |
673 sel->cancel = gnt_button_new("Cancel"); | |
674 sel->select = gnt_button_new("Select"); | |
675 | |
676 g_signal_connect(G_OBJECT(sel->select), "activate", G_CALLBACK(select_activated_cb), sel); | |
677 | |
678 return widget; | 678 return widget; |
679 } | 679 } |
680 | 680 |
681 gboolean gnt_file_sel_set_current_location(GntFileSel *sel, const char *path) | 681 gboolean gnt_file_sel_set_current_location(GntFileSel *sel, const char *path) |
682 { | 682 { |