static gint progress_end_cb(GWEN_GUI *gwen_gui, guint32 id) { GncGWENGui *gui = GETDATA_GUI(gwen_gui); Progress *progress; g_return_val_if_fail(gui, -1); g_return_val_if_fail(id == g_list_length(gui->progresses), -1); ENTER("gui=%p, id=%d", gui, id); if (gui->state != RUNNING) { /* Ignore finishes of progresses we do not track */ LEAVE("not running anymore"); return 0; } /* Hide progress */ progress = (Progress*) gui->progresses->data; hide_progress(gui, progress); /* Remove progress from stack and free memory */ gui->progresses = g_list_delete_link(gui->progresses, gui->progresses); free_progress(progress, NULL); if (!gui->progresses) { /* top-level progress finished */ set_finished(gui); } LEAVE(" "); return 0; }
gint drag_received (GtkWidget* widget, GdkDragContext* drag_context, gint x, gint y, GtkSelectionData* data, guint info, guint time, gpointer user_data) { // this receives drops for the whole window. if(!data || data->length < 0){ perr("no data!\n"); return -1; } dbg(1, "%s", data->data); if(g_str_has_prefix((char*)data->data, "colour:")){ char* colour_string = (char*)data->data + 7; unsigned colour_index = atoi(colour_string) ? atoi(colour_string) - 1 : 0; // which row are we on? GtkTreePath* path; GtkTreeIter iter; gint tx, treeview_top; gdk_window_get_position(app->libraryview->widget->window, &tx, &treeview_top); dbg(2, "treeview_top=%i", y); #ifdef HAVE_GTK_2_12 gint bx, by; gtk_tree_view_convert_widget_to_bin_window_coords(GTK_TREE_VIEW(app->libraryview->widget), x, y - treeview_top, &bx, &by); dbg(2, "coords: %dx%d => %dx%d", x, y, bx, by); #else gint by = y - treeview_top - 20; #endif #ifdef USE_GDL GdkWindow* top_window = gdk_window_get_toplevel(gtk_widget_get_toplevel(app->libraryview->widget)->window); GdkWindow* window = app->libraryview->widget->window; while((window = gdk_window_get_parent(window)) != top_window){ gint x0, y0; gdk_window_get_position(window, &x0, &y0); by -= y0; } #endif if(gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(app->libraryview->widget), x, by, &path, NULL, NULL, NULL)){ gtk_tree_model_get_iter(GTK_TREE_MODEL(samplecat.store), &iter, path); gchar* path_str = gtk_tree_model_get_string_from_iter(GTK_TREE_MODEL(samplecat.store), &iter); dbg(2, "path=%s y=%i final_y=%i", path_str, y, y - treeview_top); listview_item_set_colour(path, colour_index); gtk_tree_path_free(path); } else dbg(0, "path not found."); return FALSE; } if(info == GPOINTER_TO_INT(GDK_SELECTION_TYPE_STRING)) printf(" type=string.\n"); if(info == GPOINTER_TO_INT(TARGET_URI_LIST)){ dbg(1, "type=uri_list. len=%i", data->length); GList* list = uri_list_to_glist((char*)data->data); if(g_list_length(list) < 1) pwarn("drag drop: uri list parsing found no uri's.\n"); int i = 0; ScanResults result = {0,}; GList* l = list; #ifdef __APPLE__ gdk_threads_enter(); #endif for(;l;l=l->next){ char* u = l->data; gchar* method_string; vfs_get_method_string(u, &method_string); dbg(2, "%i: %s method=%s", i, u, method_string); if(!strcmp(method_string, "file")){ //we could probably better use g_filename_from_uri() here //http://10.0.0.151/man/glib-2.0/glib-Character-Set-Conversion.html#g-filename-from-uri //-or perhaps get_local_path() from rox/src/support.c char* uri_unescaped = vfs_unescape_string(u + strlen(method_string) + 1, NULL); char* uri = (strstr(uri_unescaped, "///") == uri_unescaped) ? uri_unescaped + 2 : uri_unescaped; if(do_progress(0,0)) break; if(is_dir(uri)) application_add_dir(uri, &result); else application_add_file(uri, &result); g_free(uri_unescaped); } else pwarn("drag drop: unknown format: '%s'. Ignoring.\n", u); i++; } hide_progress(); #ifdef __APPLE__ gdk_threads_leave(); #endif statusbar_print(1, "import complete. %i files added", result.n_added); uri_list_free(list); } return FALSE; }