Mercurial > dwindows
comparison gtk3/dw.c @ 788:f8f4f72d6462
Implemented dw_listbox_selected_multi() however need to do some testing to make sure this works in all cases.
The code expects the selection list to be returned in the order the items are in the listbox.
Also fixed a crash in HandyFTP caused by an unset column click handler returning a semivalid result.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 22 Mar 2011 04:55:47 +0000 |
parents | 098458f3bdfb |
children | 8fe51d916b36 |
comparison
equal
deleted
inserted
replaced
787:098458f3bdfb | 788:f8f4f72d6462 |
---|---|
1761 } | 1761 } |
1762 | 1762 |
1763 static gint _column_click_event(GtkWidget *widget, gpointer data) | 1763 static gint _column_click_event(GtkWidget *widget, gpointer data) |
1764 { | 1764 { |
1765 GtkWidget *tree = data; | 1765 GtkWidget *tree = data; |
1766 gpointer handlerdata = g_object_get_data(G_OBJECT(tree), "_dw_column_click_id"); | 1766 gint handlerdata = (gint)g_object_get_data(G_OBJECT(tree), "_dw_column_click_id"); |
1767 SignalHandler work = _get_signal_handler(tree, handlerdata); | 1767 SignalHandler work; |
1768 int retval = FALSE; | 1768 int retval = FALSE; |
1769 | 1769 |
1770 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); | 1770 if(handlerdata) |
1771 if(work.window) | 1771 { |
1772 { | 1772 work = _get_signal_handler(tree, GINT_TO_POINTER(handlerdata-1)); |
1773 int column_num = (int)g_object_get_data(G_OBJECT(widget), "_dw_column"); | 1773 |
1774 int (*clickcolumnfunc)(HWND, int, void *) = work.func; | 1774 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); |
1775 retval = clickcolumnfunc(work.window, column_num, work.data); | 1775 if(work.window) |
1776 { | |
1777 int column_num = (int)g_object_get_data(G_OBJECT(widget), "_dw_column"); | |
1778 int (*clickcolumnfunc)(HWND, int, void *) = work.func; | |
1779 retval = clickcolumnfunc(work.window, column_num, work.data); | |
1780 } | |
1776 } | 1781 } |
1777 return retval; | 1782 return retval; |
1778 } | 1783 } |
1779 | 1784 |
1780 static int _round_value(gfloat val) | 1785 static int _round_value(gfloat val) |
8849 * handle: Handle to the listbox to be queried. | 8854 * handle: Handle to the listbox to be queried. |
8850 * where: Either the previous return or -1 to restart. | 8855 * where: Either the previous return or -1 to restart. |
8851 */ | 8856 */ |
8852 int dw_listbox_selected_multi(HWND handle, int where) | 8857 int dw_listbox_selected_multi(HWND handle, int where) |
8853 { | 8858 { |
8854 GtkWidget *handle2 = handle; | 8859 GtkWidget *handle2; |
8860 GtkListStore *store = NULL; | |
8855 int retval = DW_LIT_NONE; | 8861 int retval = DW_LIT_NONE; |
8856 int _locked_by_me = FALSE; | 8862 int _locked_by_me = FALSE; |
8857 | 8863 |
8858 DW_MUTEX_LOCK; | 8864 DW_MUTEX_LOCK; |
8859 if(GTK_IS_SCROLLED_WINDOW(handle)) | 8865 handle2 = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"); |
8860 { | 8866 |
8861 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"); | 8867 /* Make sure it is the correct tree type */ |
8862 if(tmp) | 8868 if(handle2 && GTK_IS_TREE_VIEW(handle2) && g_object_get_data(G_OBJECT(handle2), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_LISTBOX)) |
8863 handle2 = tmp; | 8869 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(handle2)); |
8864 } | 8870 |
8865 #if 0 | 8871 if(store) |
8866 if(GTK_IS_LIST(handle2)) | 8872 { |
8867 { | 8873 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(handle2)); |
8868 int counter = 0; | 8874 GList *list = gtk_tree_selection_get_selected_rows(sel, NULL); |
8869 GList *list = GTK_LIST(handle2)->children; | 8875 |
8870 | 8876 if(list) |
8871 while(list) | 8877 { |
8872 { | 8878 int counter = 0; |
8873 GtkItem *item = (GtkItem *)list->data; | 8879 GtkTreePath *path = g_list_nth_data(list, 0); |
8874 | 8880 |
8875 if(item && | 8881 while(path) |
8876 item->bin.container.widget.state == GTK_STATE_SELECTED | |
8877 && counter > where) | |
8878 { | 8882 { |
8879 retval = counter; | 8883 gint *indices = gtk_tree_path_get_indices(path); |
8880 break; | 8884 |
8885 if(indices && indices[0] > where) | |
8886 { | |
8887 retval = indices[0]; | |
8888 break; | |
8889 } | |
8890 | |
8891 counter++; | |
8892 path = g_list_nth_data(list, counter); | |
8881 } | 8893 } |
8882 | 8894 |
8883 | 8895 g_list_foreach(list, (GFunc) gtk_tree_path_free, NULL); |
8884 list = list->next; | 8896 g_list_free(list); |
8885 counter++; | 8897 } |
8886 } | 8898 } |
8887 } | |
8888 #endif | |
8889 DW_MUTEX_UNLOCK; | |
8890 return retval; | 8899 return retval; |
8891 } | 8900 } |
8892 | 8901 |
8893 /* | 8902 /* |
8894 * Returns the index to the item in the list currently selected. | 8903 * Returns the index to the item in the list currently selected. |
10354 { | 10363 { |
10355 /* We don't actually need a signal handler here... just need to assign the handler ID | 10364 /* We don't actually need a signal handler here... just need to assign the handler ID |
10356 * Since the handlers for the columns were already created in _dw_container_setup() | 10365 * Since the handlers for the columns were already created in _dw_container_setup() |
10357 */ | 10366 */ |
10358 sigid = _set_signal_handler(thiswindow, window, sigfunc, data, _column_click_event); | 10367 sigid = _set_signal_handler(thiswindow, window, sigfunc, data, _column_click_event); |
10359 g_object_set_data(G_OBJECT(thiswindow), "_dw_column_click_id", GINT_TO_POINTER(sigid)); | 10368 g_object_set_data(G_OBJECT(thiswindow), "_dw_column_click_id", GINT_TO_POINTER(sigid+1)); |
10360 DW_MUTEX_UNLOCK; | 10369 DW_MUTEX_UNLOCK; |
10361 return; | 10370 return; |
10362 } | 10371 } |
10363 #if 0 | 10372 #if 0 |
10364 else if (strcmp(signame, DW_SIGNAL_SET_FOCUS) == 0) | 10373 else if (strcmp(signame, DW_SIGNAL_SET_FOCUS) == 0) |