GLADE_CB gboolean on_treeview2_button_press_event(GtkWidget* widget, GdkEventButton* event, gpointer user_data) { GtkTreeView *view = GTK_TREE_VIEW(widget); GtkTreeModel *model = GTK_TREE_MODEL(list); GtkTreePath *path; GtkTreeViewColumn *column; GtkTreeIter iter; GdkEventButton *bevent; gint tx = (gint) event->x; gint ty = (gint) event->y; gint cx, cy; FileEntry *fe; gtk_tree_view_get_path_at_pos(view, tx, ty, &path, &column, &cx, &cy); switch (event->type) { case GDK_BUTTON_PRESS: if (event->button == 3) { bevent = (GdkEventButton *) (event); gtk_menu_popup(GTK_MENU(create_clist_rbm()), NULL, NULL, NULL, NULL, bevent->button, bevent->time); return TRUE; } break; case GDK_2BUTTON_PRESS: if (path == NULL) return FALSE; gtk_tree_model_get_iter(model, &iter, path); gtk_tree_model_get(model, &iter, COLUMN_DATA, &fe, -1); if (S_ISDIR(fe->attrib)) { // go into folder tilp_file_chdir(fe->name); g_free(local.cwdir); local.cwdir = g_get_current_dir(); clist_refresh(); labels_refresh(); } break; default: break; } return FALSE; // pass event on }
/* Change the current drive (Win32 only) */ int tilp_drive_change(char drive_letter) { #ifdef __WIN32__ gchar *s; g_snprintf(local.cwdir, 8, "%c:\\", (char) drive_letter); s = g_strdup(local.cwdir); if (tilp_file_chdir(s) == -1) { gif->msg_box1(_("Error"), _("Unable to change directory.")); } g_free(s); #else gif->msg_box1(_("Information"), _("This function is only available in the Windows version.")); #endif return 0; }
// change folder TILP_EXPORT void on_button14_clicked(GtkButton* button, gpointer user_data) { gchar *folder; folder = msg_entry(_("Path"), _("Enter new path"), local.cwdir); if(folder != NULL) { if(g_file_test(folder, G_FILE_TEST_IS_DIR)) { tilp_file_chdir(folder); g_free(local.cwdir); local.cwdir = g_get_current_dir(); clist_refresh(); labels_refresh(); } g_free(folder); } }
/* This function must be the first function to call in your function 'main'. It initializes the TiLP core engine. */ int tilp_init(int *argc, char ***argv) { /* Display program version */ tilp_cmdline_version(); /* Initialize platform independant paths */ tilp_paths_init(); /* Init i18n support */ #ifdef ENABLE_NLS tilp_info("setlocale: %s", setlocale(LC_ALL, "")); tilp_info("bindtextdomain: %s", bindtextdomain(PACKAGE, inst_paths.locale_dir)); bind_textdomain_codeset(PACKAGE, "UTF-8"/*"ISO-8859-15"*/); tilp_info("textdomain: %s", textdomain(PACKAGE)); #endif /* Initialize callbacks with default functions */ tilp_gif_set_default(); /* Initialize/reload config */ tilp_config_default(); tilp_config_read(); /* Scan and modify command line and change to working folder*/ tilp_cmdline_scan(argc, argv); tilp_file_chdir(options.working_dir); /* Catch 'Ctrl-C' */ signal(SIGINT, signal_handler); /* Check the version of libraries and init framework */ if (strcmp(ticonv_version_get(), TILP_REQUIRES_LIBCONV_VERSION) < 0) tilp_error(_("libticonv library version is %s but %s mini required.\n"), ticonv_version_get(), TILP_REQUIRES_LIBCONV_VERSION); if (strcmp(tifiles_version_get(), TILP_REQUIRES_LIBFILES_VERSION) < 0) tilp_error(_("libtifiles library version is %s but %s mini required.\n"), tifiles_version_get(), TILP_REQUIRES_LIBFILES_VERSION); if (strcmp(ticables_version_get(), TILP_REQUIRES_LIBCABLES_VERSION) < 0) tilp_error(_("libticables library version is %s but %s mini required.\n"), ticables_version_get(), TILP_REQUIRES_LIBCABLES_VERSION); if (strcmp(ticalcs_version_get(), TILP_REQUIRES_LIBCALCS_VERSION) < 0) tilp_error(_("libticalcs library version is %s but %s mini required.\n"), ticalcs_version_get(), TILP_REQUIRES_LIBCALCS_VERSION); ticables_library_init(); tifiles_library_init(); ticalcs_library_init(); /* Check for USB support */ options.usb_avail = ticables_is_usb_enabled(); /* Set cable & calc */ if(options.auto_detect && options.usb_avail) { int ret; CableModel cable; CalcModel calc; CablePort port; ret = tilp_device_probe_usb(&cable, &port, &calc); if(!ret) { options.cable_model = cable; options.cable_port = port; options.calc_model = calc; } } tilp_device_open(); /* If we are in command line mode, does the required operation and exit else fallback on a graphic interface. */ if((working_mode & MODE_CMD) && !(working_mode & MODE_GUI)) { int ret; ret = tilp_cmdline_send(); exit(ret); } else if(working_mode == MODE_INI) exit(0); return 0; }