Exemple #1
0
void cb_save_graphic()
{
    Shell *shell = shell_get_main_shell();
    GtkWidget *dialog;
    gchar *filename;

    /* save the pixbuf to a png file */
    dialog = gtk_file_chooser_dialog_new("Save Image",
					 NULL,
					 GTK_FILE_CHOOSER_ACTION_SAVE,
					 GTK_STOCK_CANCEL,
					 GTK_RESPONSE_CANCEL,
					 GTK_STOCK_SAVE,
					 GTK_RESPONSE_ACCEPT, NULL);

    filename = g_strconcat(shell->selected->name, ".png", NULL);
    gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), filename);
    g_free(filename);

    if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
	filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
	gtk_widget_destroy(dialog);

	shell_status_update("Saving image...");

	tree_view_save_image(filename);

	shell_status_update("Done.");
	g_free(filename);

	return;
    }

    gtk_widget_destroy(dialog);
}
void report_dialog_show(GtkTreeModel * model, GtkWidget * parent)
{
    gboolean success;
    ReportDialog *rd = report_dialog_new(model, parent);

    if (gtk_dialog_run(GTK_DIALOG(rd->dialog)) == GTK_RESPONSE_ACCEPT) {
        shell_status_update("Generating report...");
        gtk_widget_hide(rd->dialog);
        shell_view_set_enabled(FALSE);
        shell_status_set_enabled(TRUE);

        success = report_generate(rd);

        shell_status_set_enabled(FALSE);

        if (success)
            shell_status_update("Report saved.");
        else
            shell_status_update("Error while creating the report.");
    }

    set_all_active(rd, FALSE);
    gtk_widget_destroy(rd->dialog);
    g_free(rd);
}
void
shell_init(void)
{
    if (shell) {
        g_error("Shell already created");
        return;
    }

    create_window();

    shell->tree = tree_new();
    shell->info = info_tree_new(FALSE);
    shell->moreinfo = info_tree_new(TRUE);
    shell->loadgraph = load_graph_new(75);

    gtk_paned_pack1(GTK_PANED(shell->hpaned), shell->tree->scroll,
                    SHELL_PACK_RESIZE, SHELL_PACK_SHRINK);
    gtk_paned_pack1(GTK_PANED(shell->vpaned), shell->info->scroll,
                    SHELL_PACK_RESIZE, SHELL_PACK_SHRINK);

    gtk_notebook_append_page(GTK_NOTEBOOK(shell->notebook),
                             shell->moreinfo->scroll, NULL);
    gtk_notebook_append_page(GTK_NOTEBOOK(shell->notebook),
                             load_graph_get_framed(shell->loadgraph), NULL);

    gtk_notebook_set_show_tabs(GTK_NOTEBOOK(shell->notebook), FALSE);
    gtk_notebook_set_show_border(GTK_NOTEBOOK(shell->notebook), FALSE);

    shell_status_set_enabled(TRUE);
    shell_status_update("Loading modules...");

    shell_tree_modules_load(shell->tree);
    g_slist_foreach(shell->tree->modules, add_modules_to_gui, shell->tree);
    gtk_tree_view_expand_all(GTK_TREE_VIEW(shell->tree->view));

    shell_status_update("Done.");
    shell_status_set_enabled(FALSE);

    gtk_widget_show_all(shell->hpaned);

    load_graph_configure_expose(shell->loadgraph);

    gtk_widget_hide(shell->notebook);

    shell_action_set_enabled("RefreshAction", FALSE);
    shell_action_set_active("LeftPaneAction", TRUE);
    shell_action_set_active("ToolbarAction", TRUE);
    shell_action_set_property("RefreshAction", "is-important", TRUE);
    shell_action_set_property("ReportAction", "is-important", TRUE);
}
static Computer *
computer_get_info(void)
{
    Computer *computer;

    computer = g_new0(Computer, 1);
    
    if (moreinfo) {
#ifdef g_hash_table_unref
	g_hash_table_unref(moreinfo);
#else
	g_free(moreinfo);
#endif
    }

    moreinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);

    shell_status_update("Getting processor information...");
    computer->processor = computer_get_processor();

    shell_status_update("Getting memory information...");
    computer->memory = computer_get_memory();

    shell_status_update("Getting operating system information...");
    computer->os = computer_get_os();

    shell_status_update("Getting display information...");
    computer->display = computer_get_display();

    shell_status_update("Getting sound card information...");
    computer->alsa = computer_get_alsainfo();

    shell_status_update("Getting mounted file system information...");
    scan_filesystems();

    shell_status_update("Getting shared directories...");
    scan_shared_directories();
    
    shell_status_update("Reading sensors...");
    read_sensors();

    shell_status_update("Obtaining network information...");
    scan_net_interfaces();

    computer->date_time = "...";
    return computer;
}
Exemple #5
0
void
benchmark_nqueens(void)
{
    gdouble elapsed = 0;
    
    shell_view_set_enabled(FALSE);
    shell_status_update("Running N-Queens benchmark...");
        
    elapsed = benchmark_parallel_for(0, 10, nqueens_for, NULL);
    
    bench_results[BENCHMARK_NQUEENS] = elapsed;
}
Exemple #6
0
void
benchmark_raytrace(void)
{
    bench_value r = EMPTY_BENCH_VALUE;

    shell_view_set_enabled(FALSE);
    shell_status_update("Performing John Walker's FBENCH...");

    r = benchmark_parallel_for(0, 0, 1000, parallel_raytrace, NULL);
    r.result = r.elapsed_time;

    bench_results[BENCHMARK_RAYTRACE] = r;
}
Exemple #7
0
void
benchmark_fish(void)
{
    gchar *tmpsrc;
    gchar *bdata_path;

    bdata_path = g_build_filename(params.path_data, "benchmark.data", NULL);
    if (!g_file_get_contents(bdata_path, &tmpsrc, NULL, NULL)) {
        bench_results[BENCHMARK_BLOWFISH] = -1.0f;
        g_free(bdata_path);
        return;
    }

    shell_view_set_enabled(FALSE);
    shell_status_update("Performing Blowfish benchmark...");

    bench_results[BENCHMARK_BLOWFISH] = benchmark_parallel_for(0, 50000, parallel_blowfish, tmpsrc);
    g_free(bdata_path);
    g_free(tmpsrc);
}
Exemple #8
0
void
benchmark_fib(void)
{
    GTimer *timer = g_timer_new();
    bench_value r = EMPTY_BENCH_VALUE;

    shell_view_set_enabled(FALSE);
    shell_status_update("Calculating the 42nd Fibonacci number...");

    g_timer_reset(timer);
    g_timer_start(timer);

    fib(42);

    g_timer_stop(timer);
    r.elapsed_time = g_timer_elapsed(timer, NULL);
    g_timer_destroy(timer);

    r.threads_used = 1;
    r.result = r.elapsed_time;

    bench_results[BENCHMARK_FIB] = r;
}
static void
module_selected(GtkTreeSelection * ts, gpointer data)
{
    ShellTree			*shelltree = shell->tree;
    GtkTreeModel		*model = GTK_TREE_MODEL(shelltree->model);
    GtkTreeIter			 parent;
    ShellModuleEntry		*entry;
    static ShellModuleEntry	*current = NULL;
    static gboolean		updating = FALSE;

    if (updating)
        return;

    updating = TRUE;

    /* Gets the currently selected item on the left-side TreeView; if there is no
       selection, silently return */
    if (!gtk_tree_selection_get_selected(ts, &model, &parent))
        return;

    /* Mark the currently selected module as "unselected"; this is used to kill the
       update timeout. */
    if (current)
        current->selected = FALSE;

    /* Get the current selection and shows its related info */
    gtk_tree_model_get(model, &parent, TREE_COL_DATA, &entry, -1);
    if (entry && entry->func && !entry->selected) {
        shell_status_set_enabled(TRUE);
        shell_status_update("Updating...");

        entry->selected = TRUE;
        shell->selected = entry;
        module_selected_show_info(entry, FALSE);

        info_selected_show_extra(NULL);	/* clears the more info store */
        gtk_tree_view_columns_autosize(GTK_TREE_VIEW(shell->info->view));

        /* urgh. why don't GTK do this when the model is cleared? */
        gtk_range_set_value(GTK_RANGE(GTK_SCROLLED_WINDOW(shell->info->scroll)->vscrollbar), 0.0);
        gtk_range_set_value(GTK_RANGE(GTK_SCROLLED_WINDOW(shell->info->scroll)->hscrollbar), 0.0);
        gtk_range_set_value(GTK_RANGE(GTK_SCROLLED_WINDOW(shell->moreinfo->scroll)->vscrollbar), 0.0);
        gtk_range_set_value(GTK_RANGE(GTK_SCROLLED_WINDOW(shell->moreinfo->scroll)->hscrollbar), 0.0);

        shell_status_update("Done.");
        shell_status_set_enabled(FALSE);

        gchar *tmp = g_strdup_printf("%s - System Information", entry->name);
        gtk_window_set_title(GTK_WINDOW(shell->window), tmp);
        g_free(tmp);

        shell_action_set_enabled("RefreshAction", entry->reloadfunc ? TRUE : FALSE);
    } else {
        gtk_window_set_title(GTK_WINDOW(shell->window), "System Information");
        shell_action_set_enabled("RefreshAction", FALSE);

        gtk_tree_store_clear(GTK_TREE_STORE(shell->info->model));
        set_view_type(SHELL_VIEW_NORMAL);
    }

    current = entry;
    updating = FALSE;
}
Exemple #10
0
void scan_dev(gboolean reload)
{
    SCAN_START();
    
    int i;
    struct {
       gchar *compiler_name;
       gchar *version_command;
       gchar *regex;
       gboolean stdout;
    } detect_lang[] = {
       { "Scripting Languages", NULL, FALSE },
       { "CPython", "python -V", "\\d+\\.\\d+\\.\\d+", FALSE },
       { "Perl", "perl -v", "\\d+\\.\\d+\\.\\d+", TRUE },
       { "PHP", "php --version", "\\d+\\.\\d+\\.\\S+", TRUE},
       { "Ruby", "ruby --version", "\\d+\\.\\d+\\.\\d+", TRUE },
       { "Bash", "bash --version", "\\d+\\.\\d+\\.\\S+", TRUE},
       { "Compilers", NULL, FALSE },
       { "C (GCC)", "gcc -v", "\\d+\\.\\d+\\.\\d+", FALSE },
       { "Java", "javac -version", "\\d+\\.\\d+\\.\\d+", FALSE },
       { "CSharp (Mono, old)", "mcs --version", "\\d+\\.\\d+\\.\\d+\\.\\d+", TRUE },
       { "CSharp (Mono)", "gmcs --version", "\\d+\\.\\d+\\.\\d+\\.\\d+", TRUE },
       { "Vala", "valac --version", "\\d+\\.\\d+\\.\\d+", TRUE },
       { "Haskell (GHC)", "ghc -v", "\\d+\\.\\d+\\.\\d+", FALSE },
       { "FreePascal", "fpc --version", "\\d+\\.\\d+\\.\\S+", TRUE },
       { "Tools", NULL, FALSE },
       { "make", "make --version", "\\d+\\.\\d+", TRUE },
       { "GDB", "gdb --version", "\\d+\\.\\S+", TRUE },
       { "strace", "strace -V", "\\d+\\.\\d+\\.\\d+", TRUE },
       { "valgrind", "valgrind --version", "\\d+\\.\\d+\\.\\S+", TRUE },
       { "QMake", "qmake --version", "\\d+\\.\\S+", TRUE},
    };
    
    g_free(dev_list);
    
    dev_list = g_strdup("");
    
    for (i = 0; i < G_N_ELEMENTS(detect_lang); i++) {
       gchar *version = NULL;
       gchar *output;
       gchar *temp;
       GRegex *regex;
       GMatchInfo *match_info;
       gboolean found;
       
       if (!detect_lang[i].regex) {
            dev_list = h_strdup_cprintf("[%s]\n", dev_list, detect_lang[i].compiler_name);
            continue;
       }
       
       if (detect_lang[i].stdout) {
            found = g_spawn_command_line_sync(detect_lang[i].version_command, &output, NULL, NULL, NULL);
       } else {
            found = g_spawn_command_line_sync(detect_lang[i].version_command, NULL, &output, NULL, NULL);
       }
       
       if (found) {
           regex = g_regex_new(detect_lang[i].regex, 0, 0, NULL);

           g_regex_match(regex, output, 0, &match_info);
           if (g_match_info_matches(match_info)) {
               version = g_match_info_fetch(match_info, 0);
           }
           
           g_match_info_free(match_info);
           g_regex_unref(regex);
           g_free(output);
       }
       
       if (version) {
           dev_list = h_strdup_cprintf("%s=%s\n", dev_list, detect_lang[i].compiler_name, version);
           g_free(version);
       } else {
           dev_list = h_strdup_cprintf("%s=Not found\n", dev_list, detect_lang[i].compiler_name);
       }
       
       temp = g_strdup_printf("Detecting version: %s",
                              detect_lang[i].compiler_name);
       shell_status_update(temp);
       g_free(temp);
    }
    
    SCAN_END();
}