void PathChooserDelegate::browse_button_clicked() { char *open_dir = NULL; switch (prefs.gui_fileopen_style) { case FO_STYLE_LAST_OPENED: open_dir = get_last_open_dir(); break; case FO_STYLE_SPECIFIED: if (prefs.gui_fileopen_dir[0] != '\0') open_dir = prefs.gui_fileopen_dir; break; } QString file_name = QFileDialog::getOpenFileName(tree_, tr("Open Pipe"), open_dir); if (!file_name.isEmpty()) { path_le_->setText(file_name); } }
void pixmap_save_cb(GtkWidget *w, gpointer pixmap_ptr _U_) { GtkWidget *save_as_w; #if GTK_CHECK_VERSION(2,22,0) surface_info_t *surface_info = g_object_get_data(G_OBJECT(w), "surface-info"); #else GdkPixmap *pixmap = g_object_get_data(G_OBJECT(w), "pixmap"); #endif GdkPixbuf *pixbuf; GdkPixbufFormat *pixbuf_format; GtkWidget *main_vb, *save_as_type_hb, *type_lb, *type_cm; GSList *file_formats,*ffp; GdkWindow *parent; gchar *format_name; guint format_index = 0; guint default_index = 0; gchar *filename, *file_type; GError *error = NULL; gboolean ret; GtkWidget *msg_dialog; #if GTK_CHECK_VERSION(2,22,0) pixbuf = gdk_pixbuf_get_from_surface (surface_info->surface, 0, 0, surface_info->width, surface_info->height); #else pixbuf = gdk_pixbuf_get_from_drawable(NULL, pixmap, NULL, 0, 0, 0, 0, -1, -1); #endif if(!pixbuf) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%sCould not get image from graph%s", simple_dialog_primary_start(), simple_dialog_primary_end()); return; } save_as_w = file_selection_new("Wireshark: Save Graph As ...", FILE_SELECTION_SAVE); gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(save_as_w), TRUE); /* Container for each row of widgets */ main_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE); file_selection_set_extra_widget(save_as_w, main_vb); gtk_widget_show(main_vb); save_as_type_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0, FALSE); gtk_box_pack_start(GTK_BOX(main_vb), save_as_type_hb, FALSE, FALSE, 0); gtk_widget_show(save_as_type_hb); type_lb = gtk_label_new("File type: "); gtk_box_pack_start(GTK_BOX(save_as_type_hb), type_lb, FALSE, FALSE, 0); gtk_widget_show(type_lb); type_cm = gtk_combo_box_text_new(); gtk_box_pack_start(GTK_BOX(save_as_type_hb), type_cm, FALSE, FALSE, 0); /* List all of the file formats the gdk-pixbuf library supports */ file_formats = gdk_pixbuf_get_formats(); ffp = file_formats; while(ffp) { pixbuf_format = ffp->data; if (gdk_pixbuf_format_is_writable(pixbuf_format)) { format_name = gdk_pixbuf_format_get_name(pixbuf_format); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(type_cm), format_name); if (!(g_ascii_strcasecmp(format_name, "png"))) default_index = format_index; format_index++; } ffp = g_slist_next(ffp); } g_slist_free(file_formats); gtk_combo_box_set_active(GTK_COMBO_BOX(type_cm), default_index); gtk_widget_show(type_cm); gtk_widget_show(save_as_w); window_present(save_as_w); parent = gtk_widget_get_parent_window(w); gdk_window_set_transient_for(gtk_widget_get_window(save_as_w), parent); /* * Loop until the user either selects a file or gives up. */ for (;;) { if (gtk_dialog_run(GTK_DIALOG(save_as_w)) != GTK_RESPONSE_ACCEPT) { /* They clicked "Cancel" or closed the dialog or.... */ window_destroy(save_as_w); return; } filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(save_as_w)); /* Perhaps the user specified a directory instead of a file. Check whether they did. */ if (test_for_directory(filename) == EISDIR) { /* It's a directory - set the file selection box to display that directory, and leave the selection box displayed. */ set_last_open_dir(filename); g_free(filename); file_selection_set_current_folder(save_as_w, get_last_open_dir()); gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(save_as_w), ""); continue; } file_type = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(type_cm)); ret = gdk_pixbuf_save(pixbuf, filename, file_type, &error, NULL); g_free(filename); g_free(file_type); if (!ret) { msg_dialog = gtk_message_dialog_new(GTK_WINDOW(save_as_w), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "%s", error->message); gtk_dialog_run(GTK_DIALOG(msg_dialog)); gtk_widget_destroy(msg_dialog); continue; } window_destroy(save_as_w); return; } }
/* Attempt to Write out profile "recent" to the user's profile recent file. If we got an error report it with a dialog box and return FALSE, otherwise return TRUE. */ gboolean write_profile_recent(void) { char *pf_dir_path; char *rf_path; FILE *rf; /* To do: * - Split output lines longer than MAX_VAL_LEN * - Create a function for the preference directory check/creation * so that duplication can be avoided with filter.c */ /* Create the directory that holds personal configuration files, if necessary. */ if (create_persconffile_dir(&pf_dir_path) == -1) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Can't create directory\n\"%s\"\nfor recent file: %s.", pf_dir_path, g_strerror(errno)); g_free(pf_dir_path); return FALSE; } rf_path = get_persconffile_path(RECENT_FILE_NAME, TRUE); if ((rf = ws_fopen(rf_path, "w")) == NULL) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Can't open recent file\n\"%s\": %s.", rf_path, g_strerror(errno)); g_free(rf_path); return FALSE; } g_free(rf_path); fputs("# Recent settings file for Wireshark " VERSION ".\n" "#\n" "# This file is regenerated each time Wireshark is quit\n" "# and when changing configuration profile.\n" "# So be careful, if you want to make manual changes here.\n" "\n", rf); fprintf(rf, "\n# Main Toolbar show (hide).\n"); fprintf(rf, "# TRUE or FALSE (case-insensitive).\n"); fprintf(rf, RECENT_KEY_MAIN_TOOLBAR_SHOW ": %s\n", recent.main_toolbar_show == TRUE ? "TRUE" : "FALSE"); fprintf(rf, "\n# Filter Toolbar show (hide).\n"); fprintf(rf, "# TRUE or FALSE (case-insensitive).\n"); fprintf(rf, RECENT_KEY_FILTER_TOOLBAR_SHOW ": %s\n", recent.filter_toolbar_show == TRUE ? "TRUE" : "FALSE"); fprintf(rf, "\n# Wireless Settings Toolbar show (hide).\n"); fprintf(rf, "# TRUE or FALSE (case-insensitive).\n"); fprintf(rf, RECENT_KEY_WIRELESS_TOOLBAR_SHOW ": %s\n", recent.wireless_toolbar_show == TRUE ? "TRUE" : "FALSE"); #ifdef HAVE_AIRPCAP fprintf(rf, "\n# Show (hide) old AirPcap driver warning dialog box.\n"); fprintf(rf, "# TRUE or FALSE (case-insensitive).\n"); fprintf(rf, RECENT_KEY_DRIVER_CHECK_SHOW ": %s\n", recent.airpcap_driver_check_show == TRUE ? "TRUE" : "FALSE"); #endif fprintf(rf, "\n# Packet list show (hide).\n"); fprintf(rf, "# TRUE or FALSE (case-insensitive).\n"); fprintf(rf, RECENT_KEY_PACKET_LIST_SHOW ": %s\n", recent.packet_list_show == TRUE ? "TRUE" : "FALSE"); fprintf(rf, "\n# Tree view show (hide).\n"); fprintf(rf, "# TRUE or FALSE (case-insensitive).\n"); fprintf(rf, RECENT_KEY_TREE_VIEW_SHOW ": %s\n", recent.tree_view_show == TRUE ? "TRUE" : "FALSE"); fprintf(rf, "\n# Byte view show (hide).\n"); fprintf(rf, "# TRUE or FALSE (case-insensitive).\n"); fprintf(rf, RECENT_KEY_BYTE_VIEW_SHOW ": %s\n", recent.byte_view_show == TRUE ? "TRUE" : "FALSE"); fprintf(rf, "\n# Statusbar show (hide).\n"); fprintf(rf, "# TRUE or FALSE (case-insensitive).\n"); fprintf(rf, RECENT_KEY_STATUSBAR_SHOW ": %s\n", recent.statusbar_show == TRUE ? "TRUE" : "FALSE"); fprintf(rf, "\n# Packet list colorize (hide).\n"); fprintf(rf, "# TRUE or FALSE (case-insensitive).\n"); fprintf(rf, RECENT_KEY_PACKET_LIST_COLORIZE ": %s\n", recent.packet_list_colorize == TRUE ? "TRUE" : "FALSE"); fprintf(rf, "\n# Timestamp display format.\n"); fprintf(rf, "# One of: RELATIVE, ABSOLUTE, ABSOLUTE_WITH_DATE, DELTA, DELTA_DIS, EPOCH, UTC, UTC_WITH_DATE\n"); fprintf(rf, RECENT_GUI_TIME_FORMAT ": %s\n", ts_type_text[recent.gui_time_format]); fprintf(rf, "\n# Timestamp display precision.\n"); fprintf(rf, "# One of: AUTO, SEC, DSEC, CSEC, MSEC, USEC, NSEC\n"); fprintf(rf, RECENT_GUI_TIME_PRECISION ": %s\n", ts_precision_text[recent.gui_time_precision]); fprintf(rf, "\n# Seconds display format.\n"); fprintf(rf, "# One of: SECONDS, HOUR_MIN_SEC\n"); fprintf(rf, RECENT_GUI_SECONDS_FORMAT ": %s\n", ts_seconds_text[recent.gui_seconds_format]); fprintf(rf, "\n# Zoom level.\n"); fprintf(rf, "# A decimal number.\n"); fprintf(rf, RECENT_GUI_ZOOM_LEVEL ": %d\n", recent.gui_zoom_level); fprintf(rf, "\n# Bytes view.\n"); fprintf(rf, "# A decimal number.\n"); fprintf(rf, RECENT_GUI_BYTES_VIEW ": %d\n", recent.gui_bytes_view); fprintf(rf, "\n# Main window upper (or leftmost) pane size.\n"); fprintf(rf, "# Decimal number.\n"); if (recent.gui_geometry_main_upper_pane != 0) { fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_UPPER_PANE ": %d\n", recent.gui_geometry_main_upper_pane); } fprintf(rf, "\n# Main window middle pane size.\n"); fprintf(rf, "# Decimal number.\n"); if (recent.gui_geometry_main_lower_pane != 0) { fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_LOWER_PANE ": %d\n", recent.gui_geometry_main_lower_pane); } fprintf(rf, "\n# Packet list column pixel widths.\n"); fprintf(rf, "# Each pair of strings consists of a column format and its pixel width.\n"); packet_list_recent_write_all(rf); if (get_last_open_dir() != NULL) { fprintf(rf, "\n# Last directory navigated to in File Open dialog.\n"); if(u3_active()) fprintf(rf, RECENT_GUI_FILEOPEN_REMEMBERED_DIR ": %s\n", u3_contract_device_path(get_last_open_dir())); else fprintf(rf, RECENT_GUI_FILEOPEN_REMEMBERED_DIR ": %s\n", get_last_open_dir()); } fclose(rf); /* XXX - catch I/O errors (e.g. "ran out of disk space") and return an error indication, or maybe write to a new recent file and rename that file on top of the old one only if there are not I/O errors. */ return TRUE; }
/* Attempt to Write out profile "recent" to the user's profile recent file. If we got an error report it with a dialog box and return FALSE, otherwise return TRUE. */ gboolean write_profile_recent(void) { char *pf_dir_path; char *rf_path; char *string_list; FILE *rf; /* To do: * - Split output lines longer than MAX_VAL_LEN * - Create a function for the preference directory check/creation * so that duplication can be avoided with filter.c */ /* Create the directory that holds personal configuration files, if necessary. */ if (create_persconffile_dir(&pf_dir_path) == -1) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Can't create directory\n\"%s\"\nfor recent file: %s.", pf_dir_path, g_strerror(errno)); g_free(pf_dir_path); return FALSE; } rf_path = get_persconffile_path(RECENT_FILE_NAME, TRUE); if ((rf = ws_fopen(rf_path, "w")) == NULL) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Can't open recent file\n\"%s\": %s.", rf_path, g_strerror(errno)); g_free(rf_path); return FALSE; } g_free(rf_path); fputs("# Recent settings file for Wireshark " VERSION ".\n" "#\n" "# This file is regenerated each time Wireshark is quit\n" "# and when changing configuration profile.\n" "# So be careful, if you want to make manual changes here.\n" "\n", rf); write_recent_boolean(rf, "Main Toolbar show (hide)", RECENT_KEY_MAIN_TOOLBAR_SHOW, recent.main_toolbar_show); write_recent_boolean(rf, "Filter Toolbar show (hide)", RECENT_KEY_FILTER_TOOLBAR_SHOW, recent.filter_toolbar_show); write_recent_boolean(rf, "Wireless Settings Toolbar show (hide)", RECENT_KEY_WIRELESS_TOOLBAR_SHOW, recent.wireless_toolbar_show); #ifdef HAVE_AIRPCAP write_recent_boolean(rf, "Show (hide) old AirPcap driver warning dialog box", RECENT_KEY_DRIVER_CHECK_SHOW, recent.airpcap_driver_check_show); #endif write_recent_boolean(rf, "Packet list show (hide)", RECENT_KEY_PACKET_LIST_SHOW, recent.packet_list_show); write_recent_boolean(rf, "Tree view show (hide)", RECENT_KEY_TREE_VIEW_SHOW, recent.tree_view_show); write_recent_boolean(rf, "Byte view show (hide)", RECENT_KEY_BYTE_VIEW_SHOW, recent.byte_view_show); write_recent_boolean(rf, "Statusbar show (hide)", RECENT_KEY_STATUSBAR_SHOW, recent.statusbar_show); write_recent_boolean(rf, "Packet list colorize (hide)", RECENT_KEY_PACKET_LIST_COLORIZE, recent.packet_list_colorize); write_recent_enum(rf, "Timestamp display format", RECENT_GUI_TIME_FORMAT, ts_type_values, recent.gui_time_format); write_recent_enum(rf, "Timestamp display precision", RECENT_GUI_TIME_PRECISION, ts_precision_values, recent.gui_time_precision); write_recent_enum(rf, "Seconds display format", RECENT_GUI_SECONDS_FORMAT, ts_seconds_values, recent.gui_seconds_format); fprintf(rf, "\n# Zoom level.\n"); fprintf(rf, "# A decimal number.\n"); fprintf(rf, RECENT_GUI_ZOOM_LEVEL ": %d\n", recent.gui_zoom_level); fprintf(rf, "\n# Bytes view.\n"); fprintf(rf, "# A decimal number.\n"); fprintf(rf, RECENT_GUI_BYTES_VIEW ": %d\n", recent.gui_bytes_view); fprintf(rf, "\n# Main window upper (or leftmost) pane size.\n"); fprintf(rf, "# Decimal number.\n"); if (recent.gui_geometry_main_upper_pane != 0) { fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_UPPER_PANE ": %d\n", recent.gui_geometry_main_upper_pane); } fprintf(rf, "\n# Main window middle pane size.\n"); fprintf(rf, "# Decimal number.\n"); if (recent.gui_geometry_main_lower_pane != 0) { fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_LOWER_PANE ": %d\n", recent.gui_geometry_main_lower_pane); } fprintf(rf, "\n# Packet list column pixel widths.\n"); fprintf(rf, "# Each pair of strings consists of a column format and its pixel width.\n"); packet_list_recent_write_all(rf); fprintf(rf, "\n# Open conversation dialog tabs.\n"); fprintf(rf, "# List of conversation names, e.g. \"TCP\", \"IPv6\".\n"); string_list = join_string_list(recent.conversation_tabs); fprintf(rf, RECENT_GUI_CONVERSATION_TABS ": %s\n", string_list); g_free(string_list); fprintf(rf, "\n# Open endpoint dialog tabs.\n"); fprintf(rf, "# List of endpoint names, e.g. \"TCP\", \"IPv6\".\n"); string_list = join_string_list(recent.endpoint_tabs); fprintf(rf, RECENT_GUI_ENDPOINT_TABS ": %s\n", string_list); g_free(string_list); write_recent_boolean(rf, "For RLC stats, whether to use RLC PDUs found inside MAC frames", RECENT_GUI_RLC_PDUS_FROM_MAC_FRAMES, recent.gui_rlc_use_pdus_from_mac); if (get_last_open_dir() != NULL) { fprintf(rf, "\n# Last directory navigated to in File Open dialog.\n"); fprintf(rf, RECENT_GUI_FILEOPEN_REMEMBERED_DIR ": %s\n", get_last_open_dir()); } fclose(rf); /* XXX - catch I/O errors (e.g. "ran out of disk space") and return an error indication, or maybe write to a new recent file and rename that file on top of the old one only if there are not I/O errors. */ return TRUE; }
static GtkWidget * about_folders_page_new(void) { GtkWidget *table; const char *constpath; char *path; const gchar *titles[] = { "Name", "Folder", "Typical Files"}; GtkWidget *scrolledwindow; #if defined (HAVE_LIBSMI) || defined (HAVE_GEOIP) gint i; gchar **resultArray; #endif scrolledwindow = scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwindow), GTK_SHADOW_IN); /* Container for our data */ table = simple_list_new(3, titles); /* connect a callback so we can spot a double-click */ g_signal_connect(table, "button_press_event", G_CALLBACK(about_folders_callback), NULL); simple_list_url_col(table, 1); /* "file open" */ about_folders_row(table, "\"File\" dialogs", get_last_open_dir(), "capture files"); /* temp */ path = get_tempfile_path(""); about_folders_row(table, "Temp", path, "untitled capture files"); g_free(path); /* pers conf */ path = get_persconffile_path("", FALSE, FALSE); about_folders_row(table, "Personal configuration", path, "\"dfilters\", \"preferences\", \"ethers\", ..."); g_free(path); /* global conf */ constpath = get_datafile_dir(); if (constpath != NULL) { about_folders_row(table, "Global configuration", constpath, "\"dfilters\", \"preferences\", \"manuf\", ..."); } /* system */ constpath = get_systemfile_dir(); about_folders_row(table, "System", constpath, "\"ethers\", \"ipxnets\""); /* program */ constpath = get_progfile_dir(); about_folders_row(table, "Program", constpath, "program files"); #if defined(HAVE_PLUGINS) || defined(HAVE_LUA_5_1) /* pers plugins */ path = get_plugins_pers_dir(); about_folders_row(table, "Personal Plugins", path, "dissector plugins"); g_free(path); /* global plugins */ about_folders_row(table, "Global Plugins", get_plugin_dir(), "dissector plugins"); #endif #ifdef HAVE_PYTHON /* global python bindings */ about_folders_row(table, "Python Bindings", get_wspython_dir(), "python bindings"); #endif #ifdef HAVE_GEOIP /* GeoIP */ path = geoip_db_get_paths(); resultArray = g_strsplit(path, G_SEARCHPATH_SEPARATOR_S, 10); for(i = 0; resultArray[i]; i++) about_folders_row(table, "GeoIP path", g_strstrip(resultArray[i]), "GeoIP database search path"); g_strfreev(resultArray); g_free(path); #endif #ifdef HAVE_LIBSMI /* SMI MIBs/PIBs */ path = oid_get_default_mib_path(); resultArray = g_strsplit(path, G_SEARCHPATH_SEPARATOR_S, 10); for(i = 0; resultArray[i]; i++) about_folders_row(table, "MIB/PIB path", g_strstrip(resultArray[i]), "SMI MIB/PIB search path"); g_strfreev(resultArray); g_free(path); #endif gtk_container_add(GTK_CONTAINER(scrolledwindow), table); return scrolledwindow; }
AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent), ui(new Ui::AboutDialog) { ui->setupUi(this); QFile f_authors; QFile f_license; char *path = NULL; const char *constpath; gchar *message; #if defined (HAVE_LIBSMI) || defined (HAVE_GEOIP) gint i; gchar **resultArray; #endif /* Wireshark tab */ /* Construct the message string */ message = g_strdup_printf( "Version " VERSION "%s\n" "\n" "%s" "\n" "%s" "\n" "%s" "\n" "Wireshark is Open Source Software released under the GNU General Public License.\n" "\n" "Check the man page and http://www.wireshark.org for more information.", wireshark_gitversion, get_copyright_info(), comp_info_str->str, runtime_info_str->str); ui->label_wireshark->setTextInteractionFlags(Qt::TextSelectableByMouse); ui->label_wireshark->setText(message); /* Check if it is a dev release... (VERSION_MINOR is odd in dev release) */ #if VERSION_MINOR & 1 ui->label_logo->setPixmap( QPixmap( ":/about/wssplash_dev.png" ) ); #endif /* Authors */ f_authors.setFileName(get_datafile_path("AUTHORS-SHORT")); f_authors.open(QFile::ReadOnly | QFile::Text); QTextStream ReadFile_authors(&f_authors); ReadFile_authors.setCodec("UTF-8"); ui->pte_Authors->setFont(wsApp->monospaceFont()); ui->pte_Authors->insertPlainText(ReadFile_authors.readAll()); ui->pte_Authors->moveCursor(QTextCursor::Start); /* Folders */ /* set column widths */ #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) ui->tbFolders->horizontalHeader()->setResizeMode(2, QHeaderView::Stretch); #else ui->tbFolders->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Stretch); #endif ui->tbFolders->setRowCount(0); /* "file open" */ about_folders_row("\"File\" dialogs", get_last_open_dir(), "capture files"); /* temp */ about_folders_row("Temp", g_get_tmp_dir(), "untitled capture files"); /* pers conf */ path = get_persconffile_path("", FALSE); about_folders_row("Personal configuration", path, "\"dfilters\", \"preferences\", \"ethers\", ..."); g_free(path); /* global conf */ constpath = get_datafile_dir(); if (constpath != NULL) { about_folders_row("Global configuration", constpath, "\"dfilters\", \"preferences\", \"manuf\", ..."); } /* system */ constpath = get_systemfile_dir(); about_folders_row("System", constpath, "\"ethers\", \"ipxnets\""); /* program */ constpath = get_progfile_dir(); about_folders_row("Program", constpath, "program files"); #if defined(HAVE_PLUGINS) || defined(HAVE_LUA) /* pers plugins */ path = get_plugins_pers_dir(); about_folders_row("Personal Plugins", path, "dissector plugins"); g_free(path); /* global plugins */ about_folders_row("Global Plugins", get_plugin_dir(), "dissector plugins"); #endif #ifdef HAVE_PYTHON /* global python bindings */ about_folders_row("Python Bindings", get_wspython_dir(), "python bindings"); #endif #ifdef HAVE_GEOIP /* GeoIP */ path = geoip_db_get_paths(); resultArray = g_strsplit(path, G_SEARCHPATH_SEPARATOR_S, 10); for(i = 0; resultArray[i]; i++) about_folders_row("GeoIP path", g_strstrip(resultArray[i]), "GeoIP database search path"); g_strfreev(resultArray); g_free(path); #endif #ifdef HAVE_LIBSMI /* SMI MIBs/PIBs */ path = oid_get_default_mib_path(); resultArray = g_strsplit(path, G_SEARCHPATH_SEPARATOR_S, 10); for(i = 0; resultArray[i]; i++) about_folders_row("MIB/PIB path", g_strstrip(resultArray[i]), "SMI MIB/PIB search path"); g_strfreev(resultArray); g_free(path); #endif /* Plugins */ #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) ui->tbPlugins->horizontalHeader()->setResizeMode(3, QHeaderView::Stretch); #else ui->tbPlugins->horizontalHeader()->setSectionResizeMode(3, QHeaderView::Stretch); #endif plugins_scan(); /* License */ #if defined(_WIN32) f_license.setFileName(get_datafile_path("COPYING.txt")); #else f_license.setFileName(get_datafile_path("COPYING")); #endif f_license.open(QFile::ReadOnly | QFile::Text); QTextStream ReadFile_license(&f_license); ui->pte_License->setFont(wsApp->monospaceFont()); ui->pte_License->insertPlainText(ReadFile_license.readAll()); ui->pte_License->moveCursor(QTextCursor::Start); }
void StatsTreeDialog::on_actionSaveAs_triggered() { QString selectedFilter; st_format_type file_type; const char *file_ext; FILE *f; GString *str_tree; bool success= false; int last_errno; QFileDialog SaveAsDialog(this, tr("Wireshark: Save stats tree as ..."), get_last_open_dir()); SaveAsDialog.setNameFilter(tr("Plain text file (*.txt);;" "Comma separated values (*.csv);;" "XML document (*.xml);;" "YAML document (*.yaml)")); SaveAsDialog.selectNameFilter(tr("Plain text file (*.txt)")); SaveAsDialog.setAcceptMode(QFileDialog::AcceptSave); if (!SaveAsDialog.exec()) { return; } selectedFilter= SaveAsDialog.selectedNameFilter(); if (selectedFilter.contains("*.yaml", Qt::CaseInsensitive)) { file_type= ST_FORMAT_YAML; file_ext = ".yaml"; } else if (selectedFilter.contains("*.xml", Qt::CaseInsensitive)) { file_type= ST_FORMAT_XML; file_ext = ".xml"; } else if (selectedFilter.contains("*.csv", Qt::CaseInsensitive)) { file_type= ST_FORMAT_CSV; file_ext = ".csv"; } else { file_type= ST_FORMAT_PLAIN; file_ext = ".txt"; } // Get selected filename and add extension of necessary QString file_name = SaveAsDialog.selectedFiles()[0]; if (!file_name.endsWith(file_ext, Qt::CaseInsensitive)) { file_name.append(file_ext); } // produce output in selected format using current sort information str_tree=stats_tree_format_as_str(st_ ,file_type, ui->statsTreeWidget->sortColumn(), ui->statsTreeWidget->header()->sortIndicatorOrder()==Qt::DescendingOrder); // actually save the file f= ws_fopen (file_name.toUtf8().constData(),"w"); last_errno= errno; if (f) { if (fputs(str_tree->str, f)!=EOF) { success= true; } last_errno= errno; fclose(f); } if (!success) { QMessageBox::warning(this, tr("Error saving file %1").arg(file_name), g_strerror (last_errno)); } g_string_free(str_tree, TRUE); }