コード例 #1
0
ファイル: iconcache.c プロジェクト: EkimiaSAS/hardinfo
GtkWidget *icon_cache_get_image(const gchar * file)
{
    GdkPixbuf *icon;

    icon = icon_cache_get_pixbuf(file);
    return gtk_image_new_from_pixbuf(icon);
}
コード例 #2
0
void cb_about()
{
    GtkWidget *about;
    const gchar *authors[] = {
        "Author:",
        "Leandro A. F. Pereira",
        "",
        "Contributors:",
        "Agney Lopes Roth Ferraz",
        "SCSI support by Pascal F. Martin",
        "",
        "Based on work by:",
        "MD5 implementation by Colin Plumb (see md5.c for details)",
        "SHA1 implementation by Steve Raid (see sha1.c for details)",
        "Blowfish implementation by Paul Kocher (see blowfich.c for details)",
        "Raytracing benchmark by John Walker (see fbench.c for details)",
        "Some code partly based on x86cpucaps by Osamu Kayasono",
        "Vendor list based on GtkSysInfo by Pissens Sebastien",
        NULL
    };
    const gchar *artists[] = {
        "The GNOME Project",
        "Tango Project",
        NULL
    };

    about = gtk_about_dialog_new();
    gtk_about_dialog_set_name(GTK_ABOUT_DIALOG(about), "HardInfo");
    gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(about), VERSION);
    gtk_about_dialog_set_copyright(GTK_ABOUT_DIALOG(about),
				   "Copyright \302\251 2003-2007 " 
				   "Leandro A. F. Pereira");
    gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(about),
				  "System information and benchmark tool");
    gtk_about_dialog_set_logo(GTK_ABOUT_DIALOG(about),
			      icon_cache_get_pixbuf("logo.png"));

    gtk_about_dialog_set_license(GTK_ABOUT_DIALOG(about),
       "HardInfo is free software; you can redistribute it and/or modify " \
       "it under the terms of the GNU General Public License as published by " \
       "the Free Software Foundation, version 2.\n\n"
       "This program is distributed in the hope that it will be useful, " \
       "but WITHOUT ANY WARRANTY; without even the implied warranty of " \
       "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the " \
       "GNU General Public License for more details.\n\n"
       "You should have received a copy of the GNU General Public License " \
       "along with this program; if not, write to the Free Software " \
       "Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA");
#if GTK_CHECK_VERSION(2,8,0)
    gtk_about_dialog_set_wrap_license(GTK_ABOUT_DIALOG(about), TRUE);
#endif
    
    gtk_about_dialog_set_authors(GTK_ABOUT_DIALOG(about), authors);
    gtk_about_dialog_set_artists(GTK_ABOUT_DIALOG(about), artists);

    gtk_dialog_run(GTK_DIALOG(about));
    gtk_widget_destroy(about);
}
コード例 #3
0
ファイル: shell.c プロジェクト: BackupTheBerlios/hardinfo-svn
static void
create_window(void)
{
    GtkWidget		*vbox, *hbox;

    shell = g_new0(Shell, 1);

    shell->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_icon(GTK_WINDOW(shell->window),
                        icon_cache_get_pixbuf("logo.png"));
    gtk_window_set_title(GTK_WINDOW(shell->window), "System Information");
    gtk_widget_set_size_request(shell->window, 600, 400);
    g_signal_connect(G_OBJECT(shell->window), "destroy", destroy_me, NULL);

    vbox = gtk_vbox_new(FALSE, 0);
    gtk_widget_show(vbox);
    gtk_container_add(GTK_CONTAINER(shell->window), vbox);
    shell->vbox = vbox;

    menu_init(shell);

    hbox = gtk_hbox_new(FALSE, 5);
    gtk_widget_show(hbox);
    gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 3);

    shell->progress = gtk_progress_bar_new();
    gtk_widget_set_size_request(shell->progress, 70, 10);
    gtk_widget_hide(shell->progress);
    gtk_box_pack_end(GTK_BOX(hbox), shell->progress, FALSE, FALSE, 0);

    shell->status = gtk_label_new("");
    gtk_misc_set_alignment(GTK_MISC(shell->status), 0.0, 0.5);
    gtk_widget_show(shell->status);
    gtk_box_pack_start(GTK_BOX(hbox), shell->status, FALSE, FALSE, 0);

    shell->hpaned = gtk_hpaned_new();
    gtk_widget_show(shell->hpaned);
    gtk_box_pack_end(GTK_BOX(vbox), shell->hpaned, TRUE, TRUE, 0);
    gtk_paned_set_position(GTK_PANED(shell->hpaned), 210);

    shell->vpaned = gtk_vpaned_new();
    gtk_widget_show(shell->vpaned);
    gtk_paned_add2(GTK_PANED(shell->hpaned), shell->vpaned);

    shell->notebook = gtk_notebook_new();
    gtk_paned_add2(GTK_PANED(shell->vpaned), shell->notebook);

    gtk_widget_show(shell->window);
    while (gtk_events_pending())
        gtk_main_iteration();
}
コード例 #4
0
ファイル: stock.c プロジェクト: BackupTheBerlios/hardinfo-svn
void stock_icon_register(gchar * filename, gchar * stock_id)
{
    GtkIconSet *icon_set;
    GtkIconSource *icon_source;

    icon_set = gtk_icon_set_new();
    icon_source = gtk_icon_source_new();

    gtk_icon_source_set_pixbuf(icon_source,
			       icon_cache_get_pixbuf(filename));
    gtk_icon_set_add_source(icon_set, icon_source);
    gtk_icon_source_free(icon_source);

    gtk_icon_factory_add(icon_factory, stock_id, icon_set);

    gtk_icon_set_unref(icon_set);
}
コード例 #5
0
static SyncDialog *sync_dialog_new(void)
{
    SyncDialog *sd;
    GtkWidget *dialog;
    GtkWidget *dialog1_vbox;
    GtkWidget *scrolledwindow2;
    GtkWidget *treeview2;
    GtkWidget *dialog1_action_area;
    GtkWidget *button8;
    GtkWidget *button7;
    GtkWidget *button6;
    GtkWidget *label;
    GtkWidget *hbox;

    GtkTreeViewColumn *column;
    GtkTreeModel *model;
    GtkListStore *store;
    GtkCellRenderer *cr_text, *cr_toggle;

    sd = g_new0(SyncDialog, 1);
    sd->sna = sync_dialog_netarea_new();

    dialog = gtk_dialog_new();
    gtk_window_set_title(GTK_WINDOW(dialog), "Network Updater");
    gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
    gtk_window_set_icon(GTK_WINDOW(dialog),
			icon_cache_get_pixbuf("syncmanager.png"));
    gtk_window_set_default_size(GTK_WINDOW(dialog), 420, 260);
    gtk_window_set_position(GTK_WINDOW(dialog),
			    GTK_WIN_POS_CENTER_ON_PARENT);
    gtk_window_set_type_hint(GTK_WINDOW(dialog),
			     GDK_WINDOW_TYPE_HINT_DIALOG);

    gtk_container_set_border_width(GTK_CONTAINER(dialog), 5);

    dialog1_vbox = GTK_DIALOG(dialog)->vbox;
    gtk_box_set_spacing(GTK_BOX(dialog1_vbox), 5);
    gtk_container_set_border_width(GTK_CONTAINER(dialog1_vbox), 4);
    gtk_widget_show(dialog1_vbox);

    hbox = gtk_hbox_new(FALSE, 5);
    gtk_box_pack_start(GTK_BOX(dialog1_vbox), hbox, FALSE, FALSE, 0);

    label = gtk_label_new(LABEL_SYNC_DEFAULT);
    gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
    gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
    gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);

    gtk_box_pack_start(GTK_BOX(hbox),
		       icon_cache_get_image("syncmanager.png"),
		       FALSE, FALSE, 0);
    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, TRUE, 0);
    gtk_widget_show_all(hbox);


    gtk_box_pack_start(GTK_BOX(dialog1_vbox), sd->sna->vbox, TRUE, TRUE,
		       0);

    scrolledwindow2 = gtk_scrolled_window_new(NULL, NULL);
    gtk_widget_show(scrolledwindow2);
    gtk_box_pack_start(GTK_BOX(dialog1_vbox), scrolledwindow2, TRUE, TRUE,
		       0);
    gtk_widget_set_size_request(scrolledwindow2, -1, 200);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow2),
				   GTK_POLICY_AUTOMATIC,
				   GTK_POLICY_AUTOMATIC);
    gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW
					(scrolledwindow2), GTK_SHADOW_IN);

    store =
	gtk_list_store_new(3, G_TYPE_BOOLEAN, G_TYPE_STRING,
			   G_TYPE_POINTER);
    model = GTK_TREE_MODEL(store);

    treeview2 = gtk_tree_view_new_with_model(model);
    gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview2), FALSE);
    gtk_widget_show(treeview2);
    gtk_container_add(GTK_CONTAINER(scrolledwindow2), treeview2);

    column = gtk_tree_view_column_new();
    gtk_tree_view_append_column(GTK_TREE_VIEW(treeview2), column);

    cr_toggle = gtk_cell_renderer_toggle_new();
    gtk_tree_view_column_pack_start(column, cr_toggle, FALSE);
    g_signal_connect(cr_toggle, "toggled", G_CALLBACK(sel_toggle), model);
    gtk_tree_view_column_add_attribute(column, cr_toggle, "active", 0);

    cr_text = gtk_cell_renderer_text_new();
    gtk_tree_view_column_pack_start(column, cr_text, TRUE);
    gtk_tree_view_column_add_attribute(column, cr_text, "markup", 1);

    populate_store(store);

    dialog1_action_area = GTK_DIALOG(dialog)->action_area;
    gtk_widget_show(dialog1_action_area);
    gtk_button_box_set_layout(GTK_BUTTON_BOX(dialog1_action_area),
			      GTK_BUTTONBOX_END);

    button8 = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
    gtk_widget_show(button8);
    gtk_dialog_add_action_widget(GTK_DIALOG(dialog), button8,
				 GTK_RESPONSE_CANCEL);
    GTK_WIDGET_SET_FLAGS(button8, GTK_CAN_DEFAULT);

    button7 = gtk_button_new_with_mnemonic("_Synchronize");
    gtk_widget_show(button7);
    gtk_dialog_add_action_widget(GTK_DIALOG(dialog), button7,
				 GTK_RESPONSE_ACCEPT);
    GTK_WIDGET_SET_FLAGS(button7, GTK_CAN_DEFAULT);

    button6 = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
    g_signal_connect(G_OBJECT(button6), "clicked",
		     (GCallback) close_clicked, NULL);
    gtk_dialog_add_action_widget(GTK_DIALOG(dialog), button6,
				 GTK_RESPONSE_ACCEPT);
    GTK_WIDGET_SET_FLAGS(button6, GTK_CAN_DEFAULT);

    sd->dialog = dialog;
    sd->button_sync = button7;
    sd->button_cancel = button8;
    sd->button_close = button6;
    sd->scroll_box = scrolledwindow2;
    sd->label = label;

    return sd;
}
コード例 #6
0
static void sync_dialog_netarea_start_actions(SyncDialog * sd,
					      SyncNetAction sna[], gint n)
{
    gint i;
    GtkWidget **labels;
    GtkWidget **icons;
    GdkPixbuf *done_icon = icon_cache_get_pixbuf("status-done.png");
    GdkPixbuf *curr_icon = icon_cache_get_pixbuf("status-curr.png");

    labels = g_new0(GtkWidget *, n);
    icons = g_new0(GtkWidget *, n);

    for (i = 0; i < n; i++) {
	GtkWidget *hbox;

	hbox = gtk_hbox_new(FALSE, 5);

	labels[i] = gtk_label_new(sna[i].name);
	icons[i] = gtk_image_new();

	gtk_widget_set_size_request(icons[i],
				    gdk_pixbuf_get_width(done_icon),
				    gdk_pixbuf_get_height(done_icon));

	gtk_label_set_use_markup(GTK_LABEL(labels[i]), TRUE);
	gtk_misc_set_alignment(GTK_MISC(labels[i]), 0.0, 0.5);

	gtk_box_pack_start(GTK_BOX(hbox), icons[i], FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(hbox), labels[i], TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(sd->sna->vbox), hbox, FALSE, FALSE, 3);

	gtk_widget_show_all(hbox);
    }

    while (gtk_events_pending())
	gtk_main_iteration();

    for (i = 0; i < n; i++) {
	gchar *markup;

	if (sd->flag_cancel) {
	    markup =
		g_strdup_printf("<s>%s</s> <i>(canceled)</i>",
				sna[i].name);
	    gtk_label_set_markup(GTK_LABEL(labels[i]), markup);
	    g_free(markup);

	    gtk_image_set_from_pixbuf(GTK_IMAGE(icons[i]),
				      icon_cache_get_pixbuf
				      ("dialog-error.png"));
	    break;
	}

	markup = g_strdup_printf("<b>%s</b>", sna[i].name);
	gtk_label_set_markup(GTK_LABEL(labels[i]), markup);
	g_free(markup);

	gtk_image_set_from_pixbuf(GTK_IMAGE(icons[i]), curr_icon);

	if (sna[i].do_action && !sna[i].do_action(sd, &sna[i])) {
	    markup =
		g_strdup_printf("<b><s>%s</s></b> <i>(failed)</i>",
				sna[i].name);
	    gtk_label_set_markup(GTK_LABEL(labels[i]), markup);
	    g_free(markup);

	    sd->flag_cancel = TRUE;

	    gtk_image_set_from_pixbuf(GTK_IMAGE(icons[i]),
				      icon_cache_get_pixbuf
				      ("dialog-error.png"));
	    if (sna[i].error) {
		if (sna[i].error->code != 1) {
		    /* the user has not cancelled something... */
		    g_warning
			("Failed while performing \"%s\". Please file a bug report "
			 "if this problem persists. (Use the Help\342\206\222Report"
			 " bug option.)\n\nDetails: %s", sna[i].name,
			 sna[i].error->message);
		}

		g_error_free(sna[i].error);
	    } else {
		g_warning
		    ("Failed while performing \"%s\". Please file a bug report "
		     "if this problem persists. (Use the Help\342\206\222Report"
		     " bug option.)", sna[i].name);
	    }
	    break;
	}

	gtk_image_set_from_pixbuf(GTK_IMAGE(icons[i]), done_icon);
	gtk_label_set_markup(GTK_LABEL(labels[i]), sna[i].name);
    }

    g_free(labels);
    g_free(icons);
}
コード例 #7
0
GdkPixbuf *
hi_icon(gint entry)
{
    return icon_cache_get_pixbuf(hi_entries[entry].icon);
}
コード例 #8
0
ファイル: shell.c プロジェクト: BackupTheBerlios/hardinfo-svn
static void
shell_tree_modules_load(ShellTree * shelltree)
{
    GKeyFile	*keyfile = g_key_file_new();
    guint	 categories, i;

    keyfile = g_key_file_new();
    g_key_file_load_from_file(keyfile, PREFIX "modules.conf", 0, NULL);
    if (g_key_file_get_integer(keyfile, "general", "version", NULL) != 2) {
        g_error("Wrong version of modules.conf");
    }

    gchar **cat = g_key_file_get_keys(keyfile, "categories", &categories, NULL);
    for (i = 0; i < categories; i++) {
        ShellModule *module;
        gchar *tmp, *iname;

        module       = g_new0(ShellModule, 1);
        module->name = g_strdup(cat[i]);
        iname        = g_key_file_get_value(keyfile, "categories", cat[i], NULL);

        tmp = g_strdup_printf("%s.png", iname);
        module->icon = icon_cache_get_pixbuf(tmp);
        g_free(tmp);

        tmp = g_strdup_printf(PREFIX "modules/%s.so", iname);
        module->dll = g_module_open(tmp, G_MODULE_BIND_LAZY);
        g_free(tmp);

        if (module->dll) {
            gint(*n_entries) (void);
            gint i;

            if (!g_module_symbol(module->dll, "hi_n_entries", (gpointer) & n_entries))
                continue;

            gint j = n_entries();
            for (i = 0; i <= j; i++) {
                GdkPixbuf	 *(*shell_icon) (gint);
                const gchar	 *(*shell_name) (gint);
                ShellModuleEntry *entry = g_new0(ShellModuleEntry, 1);

                if (g_module_symbol(module->dll, "hi_icon", (gpointer)&(shell_icon))) {
                    entry->icon = shell_icon(i);
                }
                if (g_module_symbol(module->dll, "hi_name", (gpointer)&(shell_name))) {
                    entry->name = g_strdup(shell_name(i));
                }
                g_module_symbol(module->dll, "hi_info",
                                (gpointer) & (entry->func));
                g_module_symbol(module->dll, "hi_reload",
                                (gpointer) & (entry->reloadfunc));
                g_module_symbol(module->dll, "hi_more_info",
                                (gpointer) & (entry->morefunc));
                g_module_symbol(module->dll, "hi_get_field",
                                (gpointer) & (entry->fieldfunc));

                entry->number = i;
                module->entries = g_slist_append(module->entries, entry);
            }

            shelltree->modules = g_slist_append(shelltree->modules, module);
        } else {
            g_free(module->name);
            g_free(module->icon);
            g_free(module);
        }

        g_free(iname);
    }

    g_strfreev(cat);
    g_key_file_free(keyfile);
}