Revision 41f65a78d919384ad599d73c656a367d92292a41
sadrul at pidgin.im
sadrul at pidgin.im
Mon Mar 19 21:52:44 EDT 2007
o -----------------------------------------------------------------
| Revision: 41f65a78d919384ad599d73c656a367d92292a41
| Ancestor: ef6f2a7555b995f54919eec7e8765ba18eff36a2
| Author: sadrul at pidgin.im
| Date: 2007-03-20T02:09:46
| Branch: im.pidgin.pidgin
|
| Modified files:
| finch/libgnt/gntfilesel.c finch/libgnt/gntfilesel.h
| finch/libgnt/test/file.c
|
| ChangeLog:
|
| Directory only selection.
|
| ============================================================
| --- finch/libgnt/gntfilesel.c 7987fa6f6f4407efc9cc5eb8521caa9ff4ed674e
| +++ finch/libgnt/gntfilesel.c 5cd1751de2cc8ba264bd489e345ac5fc6e757c6d
| @@ -66,7 +66,7 @@ update_location(GntFileSel *sel)
| {
| char *old;
| const char *tmp;
| - tmp = (const char*)gnt_tree_get_selection_data(GNT_TREE(sel->files));
| + tmp = (const char*)gnt_tree_get_selection_data(sel->dirsonly ? GNT_TREE(sel->dirs) : GNT_TREE(sel->files));
| old = g_strdup_printf("%s%s%s", sel->current, sel->current[1] ? G_DIR_SEPARATOR_S : "", tmp ? tmp : "");
| gnt_entry_set_text(GNT_ENTRY(sel->location), old);
| g_free(old);
| @@ -78,8 +78,12 @@ location_changed(GntFileSel *sel, GError
| GDir *dir;
| const char *str;
|
| + if (!sel->dirs)
| + return TRUE;
| +
| gnt_tree_remove_all(GNT_TREE(sel->dirs));
| - gnt_tree_remove_all(GNT_TREE(sel->files));
| + if (sel->files)
| + gnt_tree_remove_all(GNT_TREE(sel->files));
| gnt_entry_set_text(GNT_ENTRY(sel->location), NULL);
| if (sel->current == NULL) {
| if (GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(sel), GNT_WIDGET_MAPPED))
| @@ -108,7 +112,7 @@ location_changed(GntFileSel *sel, GError
| if (S_ISDIR(st.st_mode))
| gnt_tree_add_row_after(GNT_TREE(sel->dirs), g_strdup(str),
| gnt_tree_create_row(GNT_TREE(sel->dirs), str), NULL, NULL);
| - else {
| + else if (!sel->dirsonly) {
| char size[128];
| snprintf(size, sizeof(size), "%ld", (long)st.st_size);
|
| @@ -178,7 +182,7 @@ location_key_pressed(GntTree *tree, cons
| stat(gl.gl_pathv[0], &st);
| gnt_file_sel_set_current_location(sel, loc); /* XXX: check the return value */
| g_free(loc);
| - if (!S_ISDIR(st.st_mode)) {
| + if (!S_ISDIR(st.st_mode) && !sel->dirsonly) {
| gnt_tree_remove_all(GNT_TREE(sel->files));
| for (count = 0; count < gl.gl_pathc; count++) {
| char *tmp = process_path(gl.gl_pathv[count]);
| @@ -195,7 +199,7 @@ location_key_pressed(GntTree *tree, cons
| }
| gnt_widget_draw(sel->files);
| }
| - } else {
| + } else if (sel->files) {
| gnt_tree_remove_all(GNT_TREE(sel->files));
| gnt_widget_draw(sel->files);
| }
| @@ -216,8 +220,37 @@ gnt_file_sel_map(GntWidget *widget)
| static void
| gnt_file_sel_map(GntWidget *widget)
| {
| + GntFileSel *sel = GNT_FILE_SEL(widget);
| + GntWidget *hbox, *vbox;
| +
| + vbox = gnt_vbox_new(FALSE);
| + gnt_box_set_pad(GNT_BOX(vbox), 0);
| + gnt_box_set_alignment(GNT_BOX(vbox), GNT_ALIGN_LEFT);
| +
| + /* The dir. and files list */
| + hbox = gnt_hbox_new(FALSE);
| + gnt_box_set_pad(GNT_BOX(hbox), 0);
| +
| + gnt_box_add_widget(GNT_BOX(hbox), sel->dirs);
| +
| + if (!sel->dirsonly) {
| + gnt_box_add_widget(GNT_BOX(hbox), sel->files);
| + } else {
| + g_signal_connect(G_OBJECT(sel->dirs), "selection_changed", G_CALLBACK(file_sel_changed), sel);
| + }
| +
| + gnt_box_add_widget(GNT_BOX(vbox), hbox);
| + gnt_box_add_widget(GNT_BOX(vbox), sel->location);
| +
| + /* The buttons */
| + hbox = gnt_hbox_new(FALSE);
| + gnt_box_add_widget(GNT_BOX(hbox), sel->cancel);
| + gnt_box_add_widget(GNT_BOX(hbox), sel->select);
| + gnt_box_add_widget(GNT_BOX(vbox), hbox);
| +
| + gnt_box_add_widget(GNT_BOX(sel), vbox);
| orig_map(widget);
| - update_location(GNT_FILE_SEL(widget));
| + update_location(sel);
| }
|
| static void
| @@ -283,16 +316,7 @@ GntWidget *gnt_file_sel_new()
| {
| GntWidget *widget = g_object_new(GNT_TYPE_FILE_SEL, NULL);
| GntFileSel *sel = GNT_FILE_SEL(widget);
| - GntWidget *hbox, *vbox;
|
| - vbox = gnt_vbox_new(FALSE);
| - gnt_box_set_pad(GNT_BOX(vbox), 0);
| - gnt_box_set_alignment(GNT_BOX(vbox), GNT_ALIGN_LEFT);
| -
| - /* The dir. and files list */
| - hbox = gnt_hbox_new(FALSE);
| - gnt_box_set_pad(GNT_BOX(hbox), 0);
| -
| sel->dirs = gnt_tree_new();
| gnt_tree_set_compare_func(GNT_TREE(sel->dirs), (GCompareFunc)g_utf8_collate);
| gnt_tree_set_hash_fns(GNT_TREE(sel->dirs), g_str_hash, g_str_equal, g_free);
| @@ -301,34 +325,21 @@ GntWidget *gnt_file_sel_new()
| gnt_tree_set_col_width(GNT_TREE(sel->dirs), 0, 20);
| g_signal_connect(G_OBJECT(sel->dirs), "key_pressed", G_CALLBACK(dir_key_pressed), sel);
|
| - sel->files = gnt_tree_new_with_columns(2); /* Name, Size, Modified */
| + sel->files = gnt_tree_new_with_columns(2); /* Name, Size */
| gnt_tree_set_compare_func(GNT_TREE(sel->files), (GCompareFunc)g_utf8_collate);
| - /*gnt_tree_set_column_titles(GNT_TREE(sel->files), "Filename", "Size", "Modified");*/
| gnt_tree_set_column_titles(GNT_TREE(sel->files), "Filename", "Size");
| gnt_tree_set_show_title(GNT_TREE(sel->files), TRUE);
| gnt_tree_set_col_width(GNT_TREE(sel->files), 0, 25);
| gnt_tree_set_col_width(GNT_TREE(sel->files), 1, 10);
| - /*gnt_tree_set_col_width(GNT_TREE(sel->files), 2, 10);*/
| g_signal_connect(G_OBJECT(sel->files), "selection_changed", G_CALLBACK(file_sel_changed), sel);
|
| - gnt_box_add_widget(GNT_BOX(hbox), sel->dirs);
| - gnt_box_add_widget(GNT_BOX(hbox), sel->files);
| - gnt_box_add_widget(GNT_BOX(vbox), hbox);
| -
| /* The location entry */
| sel->location = gnt_entry_new(NULL);
| - gnt_box_add_widget(GNT_BOX(vbox), sel->location);
| g_signal_connect(G_OBJECT(sel->location), "key_pressed", G_CALLBACK(location_key_pressed), sel);
|
| - /* The buttons */
| - hbox = gnt_hbox_new(FALSE);
| sel->cancel = gnt_button_new("Cancel");
| sel->select = gnt_button_new("Select");
| - gnt_box_add_widget(GNT_BOX(hbox), sel->cancel);
| - gnt_box_add_widget(GNT_BOX(hbox), sel->select);
| - gnt_box_add_widget(GNT_BOX(vbox), hbox);
|
| - gnt_box_add_widget(GNT_BOX(sel), vbox);
| return widget;
| }
|
| @@ -354,3 +365,13 @@ gboolean gnt_file_sel_set_current_locati
| return ret;
| }
|
| +void gnt_file_sel_set_dirs_only(GntFileSel *sel, gboolean dirs)
| +{
| + sel->dirsonly = dirs;
| +}
| +
| +gboolean gnt_file_sel_get_dirs_only(GntFileSel *sel)
| +{
| + return sel->dirsonly;
| +}
| +
| ============================================================
| --- finch/libgnt/gntfilesel.h 29e413b8882011bcb47b479f194959b09e5aad50
| +++ finch/libgnt/gntfilesel.h af313756974c65a7203b81ec0a933fb56822c69c
| @@ -59,6 +59,10 @@ const char *gnt_file_sel_get_current_loc
|
| const char *gnt_file_sel_get_current_location(GntFileSel *sel);
|
| +void gnt_file_sel_set_dirs_only(GntFileSel *sel, gboolean dirs);
| +
| +gboolean gnt_file_sel_get_dirs_only(GntFileSel *sel);
| +
| G_END_DECLS
|
| #endif /* GNT_FILE_SEL_H */
| ============================================================
| --- finch/libgnt/test/file.c 567a1f1b7154dc6974a6217e130f4c2edf7124da
| +++ finch/libgnt/test/file.c eff26206bf4a4273aed3aa6edff5d04b2b8a8672
| @@ -8,6 +8,7 @@ int main()
|
| GntWidget *w = gnt_file_sel_new();
| gnt_file_sel_set_current_location(GNT_FILE_SEL(w), "/home/");
| + gnt_file_sel_set_dirs_only(GNT_FILE_SEL(w), TRUE);
| gnt_widget_show(w);
|
| gnt_main();
To get the patch for this revision, please do this:
mtn log --last 1 --diffs --from 41f65a78d919384ad599d73c656a367d92292a41
More information about the Commits
mailing list