Exemplo n.º 1
0
/** \brief Create layout selector. */
static void create_layout_selector (GKeyFile *cfg, GtkTable *table)
{
    GtkWidget *label;
    gchar     *buffer;
    gchar     *thumbfile;
    guint      i,sel=PREDEF_NUM-1;


    /* get the current settings */
    if (cfg != NULL) {
        buffer = mod_cfg_get_str (cfg,
                                  MOD_CFG_GLOBAL_SECTION,
                                  MOD_CFG_GRID,
                                  SAT_CFG_STR_MODULE_GRID);
    }
    else {
        buffer = sat_cfg_get_str (SAT_CFG_STR_MODULE_GRID);
    }

    /* create header */
    label = gtk_label_new (_("Select layout:"));
    gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
    gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
                      GTK_SHRINK | GTK_FILL, GTK_EXPAND | GTK_FILL, 5, 0);

    /* layout selector */
    selector = gtk_combo_box_new_text ();
    gtk_table_attach (GTK_TABLE (table), selector, 1, 3, 0, 1,
                      GTK_FILL, GTK_SHRINK, 0, 0);

    for (i = 0; i < PREDEF_NUM; i++) {
        /* append default layout string to combo box */
        gtk_combo_box_append_text (GTK_COMBO_BOX (selector), predef_layout[i][1]);

        /* check if this layout corresponds to the settings */
        if (!g_ascii_strcasecmp (buffer, predef_layout[i][0])) {
            sel = i;
        }
    }

    /* select settings */
    gtk_combo_box_set_active (GTK_COMBO_BOX (selector), sel);

    /* connect signal handler */
    g_signal_connect (selector, "changed", G_CALLBACK (layout_selected_cb), NULL);


    /* layout preview thumbnail */
    thumbfile = thumb_file_from_sel (sel);
    thumb = gtk_image_new_from_file (thumbfile);
    g_free (thumbfile);
    gtk_table_attach (GTK_TABLE (table), thumb, 1, 3, 1, 2,
                      GTK_EXPAND, GTK_EXPAND, 0, 5);


    /* layout string */
    label = gtk_label_new (_("Layout code:"));
    gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
    gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
                      GTK_SHRINK | GTK_FILL, GTK_EXPAND | GTK_FILL, 5, 0);


    gridstr = gtk_entry_new ();
    gtk_entry_set_text (GTK_ENTRY (gridstr), buffer);
    g_free (buffer);

    gtk_widget_set_tooltip_text (gridstr,
                                 _("This entry holds the layout code for the module.\n"\
                                   "Consult the user manual for how to create custom layouts "\
                                   "using layout codes."));

    /* disable if it is a predefined layout */
    if (sel < PREDEF_NUM-1) {
        gtk_widget_set_sensitive (gridstr, FALSE);
    }

    /* connect changed signal handler */
    gridstr_sigid = g_signal_connect (gridstr, "changed", G_CALLBACK (layout_code_changed), NULL);

    gtk_table_attach_defaults (GTK_TABLE (table), gridstr, 1, 4, 2, 3);


}
Exemplo n.º 2
0
CMatchingDlg::CMatchingDlg(GtkWindow *pParent):m_pParent(pParent), m_FileList(NULL), m_FrameCols(NULL), 
	m_CatalogCols(NULL), m_ChartData(NULL), m_ImageData(NULL), m_CatFile(NULL), m_SelectionName(NULL),
	m_Updating(false)
{
	int i, w, width, mon;
	GtkWidget *tbox, *tbar, *frame, *hbox;
	GdkRectangle rc;
	GSList *group;

	m_Negative = CConfig::GetBool(CConfig::NEGATIVE_CHARTS);
	m_RowsUpward = CConfig::GetBool(CConfig::ROWS_UPWARD);

	// Dialog with buttons
	m_pDlg = gtk_dialog_new_with_buttons("Match stars", pParent, 
		(GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
		GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, 
		GTK_STOCK_HELP, GTK_RESPONSE_HELP, NULL);
	gtk_dialog_widget_standard_tooltips(GTK_DIALOG(m_pDlg));
	gtk_dialog_set_tooltip_by_response(GTK_DIALOG(m_pDlg), GTK_RESPONSE_ACCEPT, "Start the process");
	g_signal_connect(G_OBJECT(m_pDlg), "response", G_CALLBACK(response_dialog), this);

	// Dialog icon
	gchar *icon = get_icon_file("matchstars");
	gtk_window_set_icon(GTK_WINDOW(m_pDlg), gdk_pixbuf_new_from_file(icon, NULL));
	g_free(icon);

	// Dialog layout
	GtkWidget *vbox = gtk_vbox_new(FALSE, 4);
	gtk_box_pack_start(GTK_BOX(GTK_DIALOG(m_pDlg)->vbox), vbox, TRUE, TRUE, 0);
	gtk_container_set_border_width(GTK_CONTAINER(vbox), 8);

	// Dialog size
	GdkScreen *scr = gtk_window_get_screen(pParent);
	mon = gdk_screen_get_monitor_at_window(scr, GTK_WIDGET(pParent)->window);
	gdk_screen_get_monitor_geometry(scr, mon, &rc);
	if (rc.width>0 && rc.height>0)
		gtk_window_set_default_size(GTK_WINDOW(m_pDlg), RoundToInt(0.7*rc.width), RoundToInt(0.7*rc.height));

	// Initial state
	m_SelectMode = (tSelectMode)g_Project->GetInt("MatchingDlg", "Select", REFERENCE_FRAME);
	m_DMFrame = (tDisplayMode)g_Project->GetInt("MatchingDlg", "Display", DISPLAY_CHART);
	m_DMCatalog = (tDisplayMode)g_Project->GetInt("MatchingDlg", "Display2", DISPLAY_CHART);
	m_FrameSort = g_Project->GetInt("MatchingDlg", "Sort", FCOL_STARS);

	// List of frames
	m_Frames = gtk_list_store_new(FNCOLS, G_TYPE_INT, G_TYPE_INT, G_TYPE_DOUBLE, G_TYPE_INT);

	// List of catalog files
	m_Catalogs = gtk_list_store_new(CNCOLS, G_TYPE_STRING, G_TYPE_STRING);

	// Reference frame or catalog file?
	m_UseFrame = gtk_vbox_new(TRUE, 4);
	gtk_box_pack_start(GTK_BOX(vbox), m_UseFrame, FALSE, TRUE, 0);
	GtkWidget *label = gtk_label_new(NULL);
	gtk_label_set_markup(GTK_LABEL(label), "<b>As a reference file, use:</b>");
	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
	gtk_box_pack_start(GTK_BOX(m_UseFrame), label, FALSE, TRUE, 0);
	m_FrameBtn = gtk_radio_button_new_with_label(NULL, "a frame from the current project");
	gtk_widget_set_tooltip_text(m_FrameBtn, "Use one of the source frames as a reference frame");
	g_signal_connect(G_OBJECT(m_FrameBtn), "toggled", G_CALLBACK(button_clicked), this);
	gtk_box_pack_start(GTK_BOX(m_UseFrame), m_FrameBtn, TRUE, TRUE, 0);
	group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(m_FrameBtn)); 
	m_CatalogBtn = gtk_radio_button_new_with_label(group, "a catalog file from the disk");
	gtk_widget_set_tooltip_text(m_CatalogBtn, "Use a catalog file as a reference frame");
	g_signal_connect(G_OBJECT(m_CatalogBtn), "toggled", G_CALLBACK(button_clicked), this);
	gtk_box_pack_start(GTK_BOX(m_UseFrame), m_CatalogBtn, TRUE, TRUE, 0);

	// Separator
	gtk_box_pack_start(GTK_BOX(m_UseFrame), gtk_label_new(NULL), FALSE, TRUE, 0);

	m_SelLabel = gtk_label_new(NULL);
	gtk_misc_set_alignment(GTK_MISC(m_SelLabel), 0.0, 0.5);
	gtk_box_pack_start(GTK_BOX(vbox), m_SelLabel, FALSE, TRUE, 0);
	tbox = gtk_table_new(2, 3, FALSE);
	gtk_table_set_col_spacings(GTK_TABLE(tbox), 0);
	gtk_table_set_col_spacing(GTK_TABLE(tbox), 1, 8);
	gtk_table_set_row_spacings(GTK_TABLE(tbox), 0);
	gtk_table_set_row_spacing(GTK_TABLE(tbox), 1, 8);
	gtk_box_pack_start(GTK_BOX(vbox), tbox, TRUE, TRUE, 0);

	// List of reference frames
	m_FrameView = gtk_tree_view_new();
	width = 8;
	for (i=0; FrameColumns[i].caption!=NULL; i++) {
		GtkTreeViewColumn *col = gtk_tree_view_column_new();
		// Set column name and alignment
		gtk_tree_view_column_set_title(col, FrameColumns[i].caption);
		gtk_tree_view_append_column(GTK_TREE_VIEW(m_FrameView), col);
		// Add text renderer
		GtkCellRenderer *renderer = gtk_cell_renderer_text_new();
		gtk_tree_view_column_pack_start(col, renderer, TRUE);
		g_object_set(renderer, "xalign", FrameColumns[i].align, NULL);
		if (FrameColumns[i].datafn) 
			gtk_tree_view_column_set_cell_data_func(col, renderer, FrameColumns[i].datafn, NULL, NULL);
		else
			gtk_tree_view_column_add_attribute(col, renderer, "text", FrameColumns[i].column);
		g_signal_connect(G_OBJECT(col), "clicked", G_CALLBACK(frame_column_clicked), this);
		tColData *data = (tColData*)g_malloc(sizeof(tColData));
		data->col = col;
		data->data = &FrameColumns[i];
		m_FrameCols = g_slist_append(m_FrameCols, data);
		if (FrameColumns[i].maxtext)
			w = text_width(m_FrameView, FrameColumns[i].maxtext);
		else
			w = text_width(m_FrameView, FrameColumns[i].caption);
		width += w + 24;
	}
	gtk_tree_view_set_model(GTK_TREE_VIEW(m_FrameView), GTK_TREE_MODEL(m_Frames));
	gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(m_FrameView), true);
	gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(m_FrameView)), GTK_SELECTION_SINGLE);
	m_FrameBox = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(m_FrameBox),
		GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(m_FrameBox), 
		GTK_SHADOW_ETCHED_IN);
	gtk_container_add(GTK_CONTAINER(m_FrameBox), m_FrameView);
	gtk_widget_set_size_request(m_FrameView, width, -1);
	gtk_table_attach(GTK_TABLE(tbox), m_FrameBox, 0, 1, 0, 2, GTK_FILL, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), 0, 0);

	// Register callback for selection change
	GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(m_FrameView));
	gtk_tree_selection_set_mode(selection, GTK_SELECTION_BROWSE);
	g_signal_connect(G_OBJECT(selection), "changed", G_CALLBACK(selection_changed), this);

	// Catalog files
	m_CatalogView = gtk_tree_view_new();
	for (i=0; CatalogColumns[i].caption!=NULL; i++) {
		GtkTreeViewColumn *col = gtk_tree_view_column_new();
		// Set column name and alignment
		gtk_tree_view_column_set_title(col, CatalogColumns[i].caption);
		gtk_tree_view_append_column(GTK_TREE_VIEW(m_CatalogView), col);
		// Add text renderer
		GtkCellRenderer *renderer = gtk_cell_renderer_text_new();
		gtk_tree_view_column_pack_start(col, renderer, TRUE);
		g_object_set(renderer, "xalign", CatalogColumns[i].align, NULL);
		if (CatalogColumns[i].datafn) 
			gtk_tree_view_column_set_cell_data_func(col, renderer, CatalogColumns[i].datafn, NULL, NULL);
		else
			gtk_tree_view_column_add_attribute(col, renderer, "text", CatalogColumns[i].column);
		tColData *data = (tColData*)g_malloc(sizeof(tColData));
		data->col = col;
		data->data = &CatalogColumns[i];
		m_CatalogCols = g_slist_append(m_CatalogCols, data);
	}
	gtk_tree_view_set_model(GTK_TREE_VIEW(m_CatalogView), GTK_TREE_MODEL(m_Catalogs));
	gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(m_CatalogView), true);
	m_CatalogBox = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(m_CatalogBox),
		GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(m_CatalogBox), 
		GTK_SHADOW_ETCHED_IN);
	gtk_container_add(GTK_CONTAINER(m_CatalogBox), m_CatalogView);
	gtk_widget_set_size_request(m_CatalogView, width, -1);
	gtk_table_attach(GTK_TABLE(tbox), m_CatalogBox, 1, 2, 0, 2, GTK_FILL, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), 0, 0);

	// Register callback for selection change
	selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(m_CatalogView));
	gtk_tree_selection_set_mode(selection, GTK_SELECTION_BROWSE);
	g_signal_connect(G_OBJECT(selection), "changed", G_CALLBACK(selection_changed), this);

	// Toolbox
	tbar = gtk_toolbar_new();
	gtk_toolbar_set_style(GTK_TOOLBAR(tbar), GTK_TOOLBAR_TEXT);
	m_ShowChart = toolbar_new_radio_button(tbar, NULL, "Chart", "Display objects on a flat background");
	g_signal_connect(G_OBJECT(m_ShowChart), "toggled", G_CALLBACK(button_clicked), this);
	m_ShowImage = toolbar_new_radio_button(tbar, m_ShowChart, "Image", "Display an image only");
	g_signal_connect(G_OBJECT(m_ShowImage), "toggled", G_CALLBACK(button_clicked), this);
	gtk_table_attach(GTK_TABLE(tbox), tbar, 2, 3, 0, 1, 
		(GtkAttachOptions)(GTK_EXPAND | GTK_FILL), GTK_FILL, 0, 0);

	// Frame preview
	frame = gtk_frame_new(NULL);
	gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
	m_Preview = cmpack_chart_view_new();
	gtk_container_add(GTK_CONTAINER(frame), m_Preview);
	gtk_widget_set_size_request(frame, 160, 120);
	gtk_table_attach_defaults(GTK_TABLE(tbox), frame, 2, 3, 1, 2);

	// Bottom toolbox
	hbox = gtk_hbox_new(FALSE, 8);
	m_OptionsBtn = gtk_button_new_with_label("Options");
	gtk_widget_set_tooltip_text(m_OptionsBtn, "Edit project settings");
	gtk_box_pack_start(GTK_BOX(hbox), m_OptionsBtn, 0, 0, 0);
	g_signal_connect(G_OBJECT(m_OptionsBtn), "clicked", G_CALLBACK(button_clicked), this);
	m_PathLabel = gtk_label_new("Search path:");
	gtk_box_pack_start(GTK_BOX(hbox), m_PathLabel, FALSE, TRUE, 0);
	m_PathEntry = gtk_entry_new();
	gtk_widget_set_tooltip_text(m_PathEntry, "Path to the folder with catalog files");
	gtk_editable_set_editable(GTK_EDITABLE(m_PathEntry), false);
	gtk_box_pack_start(GTK_BOX(hbox), m_PathEntry, TRUE, TRUE, 0);
	m_PathBtn = gtk_button_new_with_label("Change folder");
	gtk_widget_set_tooltip_text(m_PathBtn, "Change folder with catalog files");
	g_signal_connect(G_OBJECT(m_PathBtn), "clicked", G_CALLBACK(button_clicked), this);
	gtk_box_pack_start(GTK_BOX(hbox), m_PathBtn, FALSE, TRUE, 0);
	gtk_table_attach(GTK_TABLE(tbox), hbox, 0, 3, 2, 3, GTK_FILL, GTK_FILL, 0, 0);

	gtk_widget_show_all(GTK_DIALOG(m_pDlg)->vbox);
}
Exemplo n.º 3
0
struct encdata *enc_new(const char *text)
{
	GtkWidget *verbox, *tabbola;
	GtkWidget *tmpbar, *tmplabel;
	GtkWidget *tmpbox;
	GtkWidget *scaled;
	GtkWidget *ok;
	/*gchar *text;*/
	bool lame = true;
	struct encdata *enc = NULL;
	GList *listola = NULL; /* recycling */

	/* init area */
	enc = (struct encdata *) g_malloc(sizeof(struct encdata));
	/* init area end */
	
	if(!(strcmp(text, "Lame"))) {
		lame = true;
		lameid = mixer->create_enc(MP3);
		enc->outchan = mixer->get_enc(lameid);

		tmplabel = gtk_label_new(_("Configure Lame Encoder"));
	} else {
		oggid = mixer->create_enc(OGG);
		enc->outchan = mixer->get_enc(oggid);
		tmplabel= gtk_label_new(_("Configure Ogg/Vorbis Encoder"));
	}

	enc->outchan->start();

	verbox = gtk_vbox_new(FALSE, 12);
	gtk_box_pack_start(GTK_BOX(verbox), tmplabel, FALSE, FALSE, 0);
	enc->verbox = verbox;
	
	/*tmplabel = GTK_BIN(w)->child;
	gtk_label_get(GTK_LABEL(tmplabel), &text);*/
	
	/*winenc = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_container_set_border_width(GTK_CONTAINER(winenc), 7);
	gtk_window_set_policy(GTK_WINDOW(winenc), TRUE, TRUE, TRUE);
	gtk_signal_connect(GTK_OBJECT(winenc), "destroy",
			(GtkSignalFunc) gtk_widget_destroyed, &winenc);*/
	
	tmpbox = gtk_hbox_new(FALSE, 6);
	gtk_box_pack_start(GTK_BOX(verbox), tmpbox, FALSE, FALSE, 0);

	tmplabel = gtk_label_new(_("Quality: (low)"));
	gtk_box_pack_start(GTK_BOX(tmpbox), tmplabel, FALSE, FALSE, 0);
	
	enc->adj1 = gtk_adjustment_new(0.0, 1.0, 9.0, 1.0, 1.0, 0.0);
	g_signal_connect(G_OBJECT(enc->adj1), "value_changed",
			G_CALLBACK(gcb_enc_set_quality), enc);
	
	scaled = gtk_hscale_new(GTK_ADJUSTMENT(enc->adj1));
	gtk_range_set_update_policy(GTK_RANGE(scaled), GTK_UPDATE_CONTINUOUS);
	gtk_scale_set_draw_value(GTK_SCALE(scaled), FALSE);
	gtk_widget_set_size_request(scaled, 100, 30);
	gtk_box_pack_start(GTK_BOX(tmpbox), scaled, FALSE, FALSE, 0);
	
	tmplabel = gtk_label_new(_("(high)"));
	gtk_box_pack_start(GTK_BOX(tmpbox), tmplabel, FALSE, FALSE, 0);
	
	tmplabel = gtk_label_new(_("    Mode"));
	gtk_box_pack_start(GTK_BOX(tmpbox), tmplabel, FALSE, FALSE, 0);

	enc->mode = gtk_combo_new();
	listola = g_list_append(listola, (void *) _("mono"));
	listola = g_list_append(listola, (void *) _("stereo"));
	gtk_combo_set_popdown_strings(GTK_COMBO(enc->mode), listola);
	gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(enc->mode)->entry), FALSE);
	g_list_free(listola);
	listola = NULL;
	
	gtk_widget_set_size_request(enc->mode, 70, 22);
	gtk_box_pack_start(GTK_BOX(tmpbox), enc->mode, FALSE, FALSE, 0);
	
	enc->adj_lab = gtk_label_new("");
	gtk_box_pack_start(GTK_BOX(verbox), enc->adj_lab, FALSE, FALSE, 0);
	

	gtk_adjustment_set_value(GTK_ADJUSTMENT(enc->adj1), 2.0);
	
	/* hidden info */
	tabbola = gtk_table_new(3, 4, FALSE);
	gtk_table_set_row_spacings(GTK_TABLE(tabbola), 12);
	gtk_table_set_col_spacings(GTK_TABLE(tabbola), 12);
	gtk_box_pack_start(GTK_BOX(verbox), tabbola, FALSE, FALSE, 0);
	enc->tabbola = tabbola;
	
	tmplabel = gtk_label_new(_("bitrate"));
	gtk_table_attach_defaults(GTK_TABLE(tabbola), tmplabel, 0, 1, 0, 1);
	enc->bitrate = gtk_combo_new();
	
	listola = g_list_append(listola, (void *) "16"); 
	listola = g_list_append(listola, (void *) "24"); 
	listola = g_list_append(listola, (void *) "32"); 
	listola = g_list_append(listola, (void *) "48"); 
	listola = g_list_append(listola, (void *) "56"); 
	listola = g_list_append(listola, (void *) "64"); 
	listola = g_list_append(listola, (void *) "96"); 
	listola = g_list_append(listola, (void *) "128");
	gtk_combo_set_popdown_strings(GTK_COMBO(enc->bitrate), listola);
	gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(enc->bitrate)->entry), FALSE);
	g_list_free(listola);
	listola = NULL;

	gtk_widget_set_size_request(enc->bitrate, 70, 22); 
	gtk_table_attach_defaults(GTK_TABLE(tabbola), enc->bitrate, 1, 2, 0, 1);

	tmplabel = gtk_label_new(_("frequency filtering"));
	gtk_table_attach_defaults(GTK_TABLE(tabbola), tmplabel, 2, 3, 0, 1);
	enc->freqfil = gtk_combo_new();
	
	listola = g_list_append(listola, (void *) _("auto"));
	listola = g_list_append(listola, (void *) _("none"));
	listola = g_list_append(listola, (void *) _("manual"));
	gtk_combo_set_popdown_strings(GTK_COMBO(enc->freqfil), listola);
	g_list_free(listola);
	listola = NULL;
	g_signal_connect(G_OBJECT(GTK_COMBO(enc->freqfil)->entry), 
			"changed", G_CALLBACK(gcb_set_pass), enc);
	gtk_widget_set_size_request(enc->freqfil, 70, 22);
	gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(enc->freqfil)->entry), 
			FALSE);
	gtk_table_attach_defaults(GTK_TABLE(tabbola), enc->freqfil, 3, 4, 0, 1);

	
	tmplabel=gtk_label_new(_("frequency"));
	gtk_table_attach_defaults(GTK_TABLE(tabbola), tmplabel, 0, 1, 1, 2);
	enc->freq = gtk_combo_new();
	listola = g_list_append(listola, (void *) "auto");
	listola = g_list_append(listola, (void *) "11000");
	listola = g_list_append(listola, (void *) "16000");
	listola = g_list_append(listola, (void *) "22050");
	listola = g_list_append(listola, (void *) "44100");
	gtk_combo_set_popdown_strings(GTK_COMBO(enc->freq), listola);
	g_list_free(listola);
	listola = NULL;
	gtk_widget_set_size_request(enc->freq, 70, 22);
	gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(enc->freq)->entry), FALSE);
	gtk_table_attach_defaults(GTK_TABLE(tabbola), enc->freq, 1, 2, 1, 2);

	tmplabel = gtk_label_new(_("lowpass Hz"));
	gtk_table_attach_defaults(GTK_TABLE(tabbola), tmplabel, 2, 3, 1, 2);
	enc->lowps = gtk_entry_new();
	gtk_entry_set_editable(GTK_ENTRY(enc->lowps), FALSE);
	gtk_entry_set_text(GTK_ENTRY(enc->lowps), _("guessed"));
	gtk_widget_set_size_request(enc->lowps, 70, 22);
	gtk_table_attach_defaults(GTK_TABLE(tabbola), enc->lowps, 3, 4, 1, 2);

	tmplabel = gtk_label_new(_("highpass Hz"));
	gtk_table_attach_defaults(GTK_TABLE(tabbola), tmplabel, 2, 3, 2, 3);
	enc->highps = gtk_entry_new();
	gtk_entry_set_editable(GTK_ENTRY(enc->highps), FALSE);
	gtk_entry_set_text(GTK_ENTRY(enc->highps), _("guessed"));
	gtk_widget_set_size_request(enc->highps, 70, 22);
	gtk_table_attach_defaults(GTK_TABLE(tabbola), enc->highps, 3, 4, 2, 3);
	
	/* end of hidden info */

	enc->tasti = gtk_vbox_new(FALSE, 5);
	
	enc->expert = gtk_toggle_button_new_with_label(_("I'm Expert..."));
	g_signal_connect(G_OBJECT(enc->expert), "toggled",
			G_CALLBACK(expert_mode), tabbola);
	gtk_box_pack_start(GTK_BOX(enc->tasti), enc->expert, FALSE, FALSE, 0);
	
	/* profile menu */
	tmpbar = gtk_menu_bar_new();
	gtk_box_pack_start(GTK_BOX(enc->tasti), tmpbar, FALSE, FALSE, 0);

	enc->profroot = gtk_menu_item_new_with_label(_("Profile..."));
	gtk_menu_bar_append(GTK_MENU_BAR(tmpbar), enc->profroot);
	
	if(enc->outchan->tipo == MP3)
		profile_lame_load();
	else
		profile_vorbis_load();

	enc_profmenu(enc);

	
	/* profile menu end */
	
	ok = gtk_button_new_with_label(_("Apply"));
	gtk_button_set_relief(GTK_BUTTON(ok), GTK_RELIEF_HALF);
	g_signal_connect(G_OBJECT(ok), "clicked", 
			G_CALLBACK(gcb_set_enc), enc);
	gtk_box_pack_start(GTK_BOX(enc->tasti), ok, FALSE, FALSE, 0);

	/* set value from core */	
	enc_put(enc);

	gtk_widget_show_all(verbox);
	gtk_widget_hide_on_delete(tabbola);
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(enc->expert), FALSE);
	
	return enc;
}
Exemplo n.º 4
0
/* Add one foil */
void add_foil(GtkWidget *notebook, int foil_num, GtkWidget *type[][MAX_FOILS],
              GtkWidget *size[][MAX_FOILS], GtkWidget *distance[], GtkWidget *stop_ion[],
              GtkWidget *stop_rec[], GtkWidget *element[][MAX_FOILS],
              GtkWidget *concentration[][MAX_FOILS], GtkWidget *mass[][MAX_FOILS],
              GtkWidget *thickness[], GtkWidget *density[])
{
  GtkWidget *table, *hbox_type, *hbox_size, *size_x, *size_y;
  
  table = gtk_table_new(4, 8 + MAX_FELEMENTS, FALSE);

  type[0][foil_num] = gtk_radio_button_new_with_label(NULL, "circular");
  type[1][foil_num] = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(type[0][foil_num]), "rectangular");
  hbox_type = gtk_hbox_new(FALSE, 5);
  gtk_box_pack_start_defaults(GTK_BOX(hbox_type), type[0][foil_num]);
  gtk_box_pack_start_defaults(GTK_BOX(hbox_type), type[1][foil_num]);
  size[0][foil_num] = gtk_spin_button_new(GTK_ADJUSTMENT(gtk_adjustment_new(0.00, MIN_DIAM, MAX_DIAM, 1.00, 10.00, 0.00)), 1.00, 2);
  size[1][foil_num] = gtk_spin_button_new(GTK_ADJUSTMENT(gtk_adjustment_new(0.00, MIN_DIAM, MAX_DIAM, 1.00, 10.00, 0.00)), 1.00, 2);
  size[2][foil_num] = gtk_spin_button_new(GTK_ADJUSTMENT(gtk_adjustment_new(0.00, MIN_DIAM, MAX_DIAM, 1.00, 10.00, 0.00)), 1.00, 2);
  size_x = gtk_label_new("x:");
  size_y = gtk_label_new("y:");
  hbox_size = gtk_hbox_new(FALSE, 5);
  gtk_box_pack_start_defaults(GTK_BOX(hbox_size), size_x);
  gtk_box_pack_start_defaults(GTK_BOX(hbox_size), size[1][foil_num]);
  gtk_box_pack_start_defaults(GTK_BOX(hbox_size), size_y);
  gtk_box_pack_start_defaults(GTK_BOX(hbox_size), size[2][foil_num]);
  
  if (foil_type[foil_num] == FOIL_RECT)
  {
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(type[1][foil_num]) ,TRUE);
    gtk_widget_set_sensitive(size[0][foil_num], FALSE);
  }
  else
  {
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(type[0][foil_num]) ,TRUE);
    gtk_widget_set_sensitive(hbox_size, FALSE);
  }
  gtk_spin_button_set_value(GTK_SPIN_BUTTON(size[0][foil_num]), foil_diameter[0][foil_num]);
  gtk_spin_button_set_value(GTK_SPIN_BUTTON(size[1][foil_num]), foil_diameter[1][foil_num]);
  gtk_spin_button_set_value(GTK_SPIN_BUTTON(size[2][foil_num]), foil_diameter[2][foil_num]);
  
  /* Controls that only one (circular or rectangular) can be selected. */
  g_signal_connect(G_OBJECT(type[0][foil_num]), "toggled", G_CALLBACK(hide_check), (gpointer) hbox_size);
  g_signal_connect(G_OBJECT(type[1][foil_num]), "toggled", G_CALLBACK(hide_check), (gpointer) size[0][foil_num]);
  
  distance[foil_num] = gtk_spin_button_new(GTK_ADJUSTMENT(gtk_adjustment_new(0.00, MIN_DIST, MAX_DIST, 10.00, 100.00, 0.00)), 10.00, 2);
  gtk_spin_button_set_value(GTK_SPIN_BUTTON(distance[foil_num]), foil_distance[foil_num]);
  
  stop_ion[foil_num] = gtk_entry_new();
  stop_rec[foil_num] = gtk_entry_new();
  if (stop_ion_foil[foil_num] != NULL)
  {
    gtk_entry_set_text(GTK_ENTRY(stop_ion[foil_num]),
                       g_locale_to_utf8(stop_ion_foil[foil_num], -1, NULL, NULL, NULL));
  }
  if (stop_rec_foil[foil_num] != NULL)
  {
    gtk_entry_set_text(GTK_ENTRY(stop_rec[foil_num]),
                       g_locale_to_utf8(stop_rec_foil[foil_num], -1, NULL, NULL, NULL));
  }
  
  thickness[foil_num] = gtk_spin_button_new(GTK_ADJUSTMENT(gtk_adjustment_new(0.00, MIN_D, MAX_D, 10.00, 100.00, 0.00)), 10.00, 2);
  gtk_spin_button_set_value(GTK_SPIN_BUTTON(thickness[foil_num]), foil_thickness[foil_num]);
  density[foil_num] = gtk_spin_button_new(GTK_ADJUSTMENT(gtk_adjustment_new(0.000, MIN_DENS, MAX_DENS, 1.000, 10.000, 0.000)), 1.000, 3);
  gtk_spin_button_set_value(GTK_SPIN_BUTTON(density[foil_num]), foil_density[foil_num]);

  gtk_table_attach_defaults(GTK_TABLE(table), gtk_label_new("Foil type:"), 0, 1, 0, 1);
  gtk_table_attach_defaults(GTK_TABLE(table), hbox_type, 1, 2, 0, 1);
  gtk_table_attach_defaults(GTK_TABLE(table), gtk_label_new("Foil diameter (circular):"), 0, 1, 1, 2);
  gtk_table_attach_defaults(GTK_TABLE(table), size[0][foil_num], 1, 2, 1, 2);
  gtk_table_attach_defaults(GTK_TABLE(table), gtk_label_new(U_SIZE), 2, 3, 1, 2);
  gtk_table_attach_defaults(GTK_TABLE(table), gtk_label_new("Foil width and height (rectangular):"), 0, 1, 2, 3);
  gtk_table_attach_defaults(GTK_TABLE(table), hbox_size, 1, 2, 2, 3);
  gtk_table_attach_defaults(GTK_TABLE(table), gtk_label_new(U_SIZE), 2, 3, 2, 3);
  gtk_table_attach_defaults(GTK_TABLE(table), gtk_label_new("Foil distance:"), 0, 1, 3, 4);
  gtk_table_attach_defaults(GTK_TABLE(table), distance[foil_num], 1, 2, 3, 4);
  gtk_table_attach_defaults(GTK_TABLE(table), gtk_label_new(U_SIZE), 2, 3, 3, 4);
  
  gtk_table_attach_defaults(GTK_TABLE(table), gtk_label_new("Foil thickness:"), 0, 1, 5, 6);
  gtk_table_attach_defaults(GTK_TABLE(table), thickness[foil_num], 1, 2, 5, 6);
  gtk_table_attach_defaults(GTK_TABLE(table), gtk_label_new(U_THICKNESS), 2, 3, 5, 6);
  gtk_table_attach_defaults(GTK_TABLE(table), gtk_label_new("Stopping power for the ion:"), 0, 1, 6, 7);
  gtk_table_attach_defaults(GTK_TABLE(table), stop_ion[foil_num], 1, 2, 6, 7);
  gtk_table_attach_defaults(GTK_TABLE(table), gtk_label_new("Stopping power for the recoil:"), 0, 1, 7, 8);
  gtk_table_attach_defaults(GTK_TABLE(table), stop_rec[foil_num], 1, 2, 7, 8);
  gtk_table_attach_defaults(GTK_TABLE(table), gtk_label_new("Foil density:"), 0, 1, 8, 9);
  gtk_table_attach_defaults(GTK_TABLE(table), density[foil_num], 1, 2, 8, 9);
  gtk_table_attach_defaults(GTK_TABLE(table), gtk_label_new(U_DENSITY), 2, 3, 8, 9);
  
  gtk_table_attach_defaults(GTK_TABLE(table), gtk_label_new("Element:"), 0, 1, 9, 10);
  gtk_table_attach_defaults(GTK_TABLE(table), gtk_label_new("Mass [u]:"), 1, 2, 9, 10);
  gtk_table_attach_defaults(GTK_TABLE(table), gtk_label_new("Concentration:"), 2, 3, 9, 10);
  
  /* Add element table */
  add_felements(table, foil_num, element, concentration, mass);
  
  gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table, gtk_label_new("foil"));

}
Exemplo n.º 5
0
extern void specific_info_resv(popup_info_t *popup_win)
{
	int resv_error_code = SLURM_SUCCESS;
	static reserve_info_msg_t *resv_info_ptr = NULL;
	static reserve_info_t *resv_ptr = NULL;
	specific_info_t *spec_info = popup_win->spec_info;
	sview_search_info_t *search_info = spec_info->search_info;
	char error_char[100];
	GtkWidget *label = NULL;
	GtkTreeView *tree_view = NULL;
	List resv_list = NULL;
	List send_resv_list = NULL;
	sview_resv_info_t *sview_resv_info_ptr = NULL;
	int j=0, i=-1;
	hostset_t hostset = NULL;
	ListIterator itr = NULL;

	if (!spec_info->display_widget) {
		setup_popup_info(popup_win, display_data_resv, SORTID_CNT);
	}

	if (spec_info->display_widget && popup_win->toggled) {
		gtk_widget_destroy(spec_info->display_widget);
		spec_info->display_widget = NULL;
		goto display_it;
	}

	if ((resv_error_code =
	     get_new_info_resv(&resv_info_ptr, popup_win->force_refresh))
	    == SLURM_NO_CHANGE_IN_DATA) {
		if (!spec_info->display_widget || spec_info->view == ERROR_VIEW)
			goto display_it;
	} else if (resv_error_code != SLURM_SUCCESS) {
		if (spec_info->view == ERROR_VIEW)
			goto end_it;
		spec_info->view = ERROR_VIEW;
		if (spec_info->display_widget)
			gtk_widget_destroy(spec_info->display_widget);
		sprintf(error_char, "get_new_info_resv: %s",
			slurm_strerror(slurm_get_errno()));
		label = gtk_label_new(error_char);
		gtk_table_attach_defaults(popup_win->table,
					  label,
					  0, 1, 0, 1);
		gtk_widget_show(label);
		spec_info->display_widget = gtk_widget_ref(label);
		goto end_it;
	}

display_it:

	resv_list = _create_resv_info_list(resv_info_ptr);

	if (!resv_list)
		return;

	if (spec_info->view == ERROR_VIEW && spec_info->display_widget) {
		gtk_widget_destroy(spec_info->display_widget);
		spec_info->display_widget = NULL;
	}
	if (spec_info->type != INFO_PAGE && !spec_info->display_widget) {
		tree_view = create_treeview(local_display_data,
					    &popup_win->grid_button_list);
		gtk_tree_selection_set_mode(
			gtk_tree_view_get_selection(tree_view),
			GTK_SELECTION_MULTIPLE);
		spec_info->display_widget =
			gtk_widget_ref(GTK_WIDGET(tree_view));
		gtk_table_attach_defaults(popup_win->table,
					  GTK_WIDGET(tree_view),
					  0, 1, 0, 1);
		/* since this function sets the model of the tree_view
		   to the treestore we don't really care about
		   the return value */
		create_treestore(tree_view, popup_win->display_data,
				 SORTID_CNT, SORTID_TIME_START, SORTID_COLOR);
	}

	setup_popup_grid_list(popup_win);

	spec_info->view = INFO_VIEW;
	if (spec_info->type == INFO_PAGE) {
		_display_info_resv(resv_list, popup_win);
		goto end_it;
	}

	/* just linking to another list, don't free the inside, just
	   the list */
	send_resv_list = list_create(NULL);
	itr = list_iterator_create(resv_list);
	i = -1;
	while ((sview_resv_info_ptr = list_next(itr))) {
		i++;
		resv_ptr = sview_resv_info_ptr->resv_ptr;
		switch(spec_info->type) {
		case PART_PAGE:
		case BLOCK_PAGE:
		case NODE_PAGE:
			if (!resv_ptr->node_list)
				continue;

			if (!(hostset = hostset_create(
				      search_info->gchar_data)))
				continue;
			if (!hostset_intersects(hostset, resv_ptr->node_list)) {
				hostset_destroy(hostset);
				continue;
			}
			hostset_destroy(hostset);
			break;
		case JOB_PAGE:
			if (strcmp(resv_ptr->name,
				   search_info->gchar_data))
				continue;
			break;
		case RESV_PAGE:
			switch(search_info->search_type) {
			case SEARCH_RESERVATION_NAME:
				if (!search_info->gchar_data)
					continue;

				if (strcmp(resv_ptr->name,
					   search_info->gchar_data))
					continue;
				break;
			default:
				continue;
			}
			break;
		default:
			g_print("Unknown type %d\n", spec_info->type);
			continue;
		}
		list_push(send_resv_list, sview_resv_info_ptr);
		j=0;
		while (resv_ptr->node_inx[j] >= 0) {
			change_grid_color(
				popup_win->grid_button_list,
				resv_ptr->node_inx[j],
				resv_ptr->node_inx[j+1],
				sview_resv_info_ptr->color_inx,
				true, 0);
			j += 2;
		}
	}
	list_iterator_destroy(itr);
	post_setup_popup_grid_list(popup_win);

	_update_info_resv(send_resv_list,
			  GTK_TREE_VIEW(spec_info->display_widget));
	list_destroy(send_resv_list);
end_it:
	popup_win->toggled = 0;
	popup_win->force_refresh = 0;

	return;
}
Exemplo n.º 6
0
void timing_dia_window_show(struct vgpu_compute_unit_t *compute_unit)
{
	struct vgpu_t *vgpu = compute_unit->vgpu;
	char text[MAX_STRING_SIZE];

	/* Activate */
	assert(!compute_unit->timing_dia_active);
	compute_unit->timing_dia_active = 1;

	/* Create lists */
	compute_unit->timing_inst_uops = list_create();

	/* Create window */
	GtkWidget *timing_window;
	timing_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	snprintf(text, sizeof text, "Compute Unit %d - Timing Diagram", compute_unit->id);
	gtk_window_set_title(GTK_WINDOW(timing_window), text);
	gtk_window_set_position(GTK_WINDOW(timing_window), GTK_WIN_POS_CENTER);
	gtk_window_set_default_size(GTK_WINDOW(timing_window), 700, 200);
	g_signal_connect(G_OBJECT(timing_window), "delete-event", G_CALLBACK(timing_window_delete_event), compute_unit);

	/* Instruction drawing area */
	GtkWidget *timing_inst_layout = gtk_layout_new(NULL, NULL);
	GtkWidget *timing_inst_title_area = gtk_drawing_area_new();
	GtkWidget *timing_inst_table = gtk_table_new(3, 1, FALSE);
	GtkWidget *timing_inst_frame = gtk_frame_new(NULL);
	gtk_widget_set_size_request(timing_inst_layout, 100, 200);
	gtk_table_attach(GTK_TABLE(timing_inst_table), timing_inst_title_area, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
	gtk_table_attach(GTK_TABLE(timing_inst_table), gtk_hseparator_new(), 0, 1, 1, 2, GTK_FILL, GTK_FILL, 0, 0);
	gtk_table_attach_defaults(GTK_TABLE(timing_inst_table), timing_inst_layout, 0, 1, 2, 3);
	gtk_container_add(GTK_CONTAINER(timing_inst_frame), timing_inst_table);
	g_signal_connect(G_OBJECT(timing_inst_title_area), "draw",
		G_CALLBACK(timing_inst_title_area_draw_event), compute_unit);

	/* White background for instruction layout */
	GdkColor color;
	gdk_color_parse("white", &color);
	gtk_widget_modify_bg(timing_inst_layout, GTK_STATE_NORMAL, &color);

	/* Diagram drawing area */
	GtkWidget *timing_dia_area = gtk_drawing_area_new();
	GtkWidget *timing_dia_title_area = gtk_drawing_area_new();
	GtkWidget *timing_dia_table = gtk_table_new(3, 1, FALSE);
	GtkWidget *timing_dia_frame = gtk_frame_new(NULL);
	gtk_table_attach(GTK_TABLE(timing_dia_table), timing_dia_title_area, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
	gtk_table_attach(GTK_TABLE(timing_dia_table), gtk_hseparator_new(), 0, 1, 1, 2, GTK_FILL, GTK_FILL, 0, 0);
	gtk_table_attach_defaults(GTK_TABLE(timing_dia_table), timing_dia_area, 0, 1, 2, 3);
	gtk_container_add(GTK_CONTAINER(timing_dia_frame), timing_dia_table);
	gtk_widget_set_size_request(timing_dia_area, 200, 200);
	gtk_widget_add_events(timing_dia_area, GDK_BUTTON_PRESS_MASK);
	g_signal_connect(G_OBJECT(timing_dia_title_area), "draw",
		G_CALLBACK(timing_dia_title_area_draw_event), compute_unit);
	g_signal_connect(G_OBJECT(timing_dia_area), "draw",
		G_CALLBACK(timing_dia_area_draw_event), compute_unit);
	g_signal_connect(G_OBJECT(timing_dia_area), "scroll-event",
		G_CALLBACK(timing_dia_area_scroll_event), compute_unit);

	/* Horizontal pane */
	GtkWidget *hpane;
	hpane = gtk_hpaned_new();
	gtk_paned_pack1(GTK_PANED(hpane), timing_inst_frame, TRUE, FALSE);
	gtk_paned_pack2(GTK_PANED(hpane), timing_dia_frame, TRUE, FALSE);

	/* Scrollbars */
	GtkWidget *hscrollbar = gtk_hscrollbar_new(NULL);
	GtkWidget *vscrollbar = gtk_vscrollbar_new(NULL);
	g_signal_connect(G_OBJECT(hscrollbar), "change-value", G_CALLBACK(timing_dia_scroll_event), compute_unit);
	g_signal_connect(G_OBJECT(vscrollbar), "change-value", G_CALLBACK(timing_dia_scroll_event), compute_unit);

	/* Table */
	GtkWidget *table;
	table = gtk_table_new(2, 2, FALSE);
	gtk_table_attach_defaults(GTK_TABLE(table), hpane, 0, 1, 0, 1);
	gtk_table_attach(GTK_TABLE(table), hscrollbar, 0, 1, 1, 2, GTK_EXPAND | GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0);
	gtk_table_attach(GTK_TABLE(table), vscrollbar, 1, 2, 0, 1, GTK_FILL, GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, 0);

	/* Frame */
	GtkWidget *frame;
	frame = gtk_frame_new(NULL);
	gtk_container_add(GTK_CONTAINER(frame), table);
	gtk_container_add(GTK_CONTAINER(timing_window), frame);

	/* Save widgets and show */
	compute_unit->timing_inst_layout = timing_inst_layout;
	compute_unit->timing_dia_area = timing_dia_area;
	compute_unit->timing_inst_title_area = timing_inst_title_area;
	compute_unit->timing_dia_title_area = timing_dia_title_area;
	compute_unit->timing_dia_hscrollbar = hscrollbar;
	compute_unit->timing_dia_vscrollbar = vscrollbar;
	compute_unit->timing_window = timing_window;
	gtk_widget_show_all(timing_window);

	/* Go to current cycle */
	timing_dia_refresh(compute_unit);
	timing_dia_window_goto(compute_unit, vgpu->cycle);
}
Exemplo n.º 7
0
GtkWidget*
capture_prefs_show(void)
{
	GtkWidget	*main_tb, *main_vb;
	GtkWidget	*if_cbxe, *if_lb, *promisc_cb, *pcap_ng_cb, *sync_cb, *auto_scroll_cb, *show_info_cb;
	GtkWidget	*ifopts_lb, *ifopts_bt;
	GList		*if_list, *combo_list;
	int		err;
	int		row = 0;
	const gchar     *tooltips_text;

	/* Main vertical box */
	main_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 7, FALSE);
	gtk_container_set_border_width(GTK_CONTAINER(main_vb), 5);

	/* Main table */
	main_tb = gtk_table_new(CAPTURE_TABLE_ROWS, 2, FALSE);
	gtk_box_pack_start(GTK_BOX(main_vb), main_tb, FALSE, FALSE, 0);
	gtk_table_set_row_spacings(GTK_TABLE(main_tb), 10);
	gtk_table_set_col_spacings(GTK_TABLE(main_tb), 15);
	gtk_widget_show(main_tb);

	/* Default device */
	if_lb = gtk_label_new("Default interface:");
	gtk_table_attach_defaults(GTK_TABLE(main_tb), if_lb, 0, 1, row, row+1);
	gtk_misc_set_alignment(GTK_MISC(if_lb), 1.0f, 0.5f);
	gtk_widget_show(if_lb);

	if_cbxe = gtk_combo_box_text_new_with_entry();
	/*
	 * XXX - what if we can't get the list?
	 */
	if_list = capture_interface_list(&err, NULL);
	combo_list = build_capture_combo_list(if_list, FALSE);
	free_interface_list(if_list);
	if (combo_list != NULL) {
		GList *combo_entry;
		for (combo_entry = combo_list; combo_entry != NULL; combo_entry = g_list_next(combo_entry)) {
				 gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(if_cbxe), combo_entry->data);
		}
	}
	if (prefs.capture_device) {
		gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(if_cbxe))),
				   prefs.capture_device);
	}
	else if (combo_list != NULL) {
		gtk_combo_box_set_active(GTK_COMBO_BOX(if_cbxe), 0);
	}
	free_capture_combo_list(combo_list);

	gtk_table_attach_defaults(GTK_TABLE(main_tb), if_cbxe, 1, 2, row, row+1);
	tooltips_text = "The default interface to be captured from.";
	gtk_widget_set_tooltip_text(if_lb, tooltips_text);
	gtk_widget_set_tooltip_text(gtk_bin_get_child(GTK_BIN(if_cbxe)), tooltips_text);
	gtk_widget_show(if_cbxe);
	g_object_set_data(G_OBJECT(main_vb), DEVICE_KEY, if_cbxe);
	row++;

	/* Interface properties */
	ifopts_lb = gtk_label_new("Interfaces:");
	gtk_table_attach_defaults(GTK_TABLE(main_tb), ifopts_lb, 0, 1, row, row+1);
	gtk_misc_set_alignment(GTK_MISC(ifopts_lb), 1.0f, 0.5f);
	gtk_widget_show(ifopts_lb);

	ifopts_bt = gtk_button_new_from_stock(WIRESHARK_STOCK_EDIT);
	tooltips_text = "Open a dialog box to set various interface options.";
	gtk_widget_set_tooltip_text(ifopts_lb, tooltips_text);
	gtk_widget_set_tooltip_text(ifopts_bt, tooltips_text);
	g_signal_connect(ifopts_bt, "clicked", G_CALLBACK(ifopts_edit_cb), NULL);
	gtk_table_attach_defaults(GTK_TABLE(main_tb), ifopts_bt, 1, 2, row, row+1);
	row++;

	/* Promiscuous mode */
	promisc_cb = create_preference_check_button(main_tb, row++,
	    "Capture packets in promiscuous mode:",
	    "Usually a network card will only capture the traffic sent to its own network address. "
	    "If you want to capture all traffic that the network card can \"see\", mark this option. "
	    "See the FAQ for some more details of capturing packets from a switched network. ",
	    prefs.capture_prom_mode);
	g_object_set_data(G_OBJECT(main_vb), PROM_MODE_KEY, promisc_cb);

	/* Pcap-NG format */
	pcap_ng_cb = create_preference_check_button(main_tb, row++,
	    "Capture packets in pcap-ng format:",
	    "Capture packets in the next-generation capture file format.",
	    prefs.capture_pcap_ng);
	g_object_set_data(G_OBJECT(main_vb), PCAP_NG_KEY, pcap_ng_cb);

	/* Real-time capture */
	sync_cb = create_preference_check_button(main_tb, row++,
	    "Update list of packets in real time:",
	    "Update the list of packets while capture is in progress. "
	    "Don't use this option if you notice packet drops.",
	    prefs.capture_real_time);
	g_object_set_data(G_OBJECT(main_vb), CAPTURE_REAL_TIME_KEY, sync_cb);

	/* Auto-scroll real-time capture */
	auto_scroll_cb = create_preference_check_button(main_tb, row++,
	    "Automatic scrolling in live capture:",
	    "Automatic scrolling of the packet list while live capture is in progress. ",
	    prefs.capture_auto_scroll);
	g_object_set_data(G_OBJECT(main_vb), AUTO_SCROLL_KEY, auto_scroll_cb);

	/* Show capture info dialog */
	show_info_cb = create_preference_check_button(main_tb, row++,
	    "Hide capture info dialog:",
	    "Hide the capture info dialog while capturing. ",
	    !prefs.capture_show_info);
	g_object_set_data(G_OBJECT(main_vb), SHOW_INFO_KEY, show_info_cb);

	/* Show 'em what we got */
	gtk_widget_show_all(main_vb);

	return(main_vb);
}
Exemplo n.º 8
0
void show_new_game(GtkMenuItem     *menuitem,
		   gpointer         user_data)
{
  GtkWidget *label;
  GtkWidget *frame;
  GtkWidget *vbox,*hbox;
  GtkWidget *table;
  GtkWidget *button;
  GtkWidget *button1;
  GtkWidget *button2;
  GtkAdjustment *adj;
	
  new_game_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  
  g_signal_connect ((gpointer) new_game_window, "destroy",
                    G_CALLBACK (show_new_game_close),
                    GINT_TO_POINTER(FALSE));
  
  gtk_window_set_title(GTK_WINDOW(new_game_window),"Level settings");
  gtk_window_set_position(GTK_WINDOW(new_game_window),GTK_WIN_POS_CENTER);
  gtk_container_border_width(GTK_CONTAINER(new_game_window),3);
  
  vbox = gtk_vbox_new(FALSE,2);
  gtk_container_add(GTK_CONTAINER(new_game_window),vbox);
  
  frame = gtk_frame_new(NULL);
  gtk_box_pack_start(GTK_BOX(vbox),frame,TRUE,TRUE,TRUE);
  
  table = gtk_table_new(3,2,TRUE);
  gtk_container_add(GTK_CONTAINER(frame),table);
  
  label = gtk_label_new("Start level:");
  adj = (GtkAdjustment *)gtk_adjustment_new(options.level,0,
					    NUM_LEVELS-1,1,1,0);
  spin_level = gtk_spin_button_new(adj,0,0);	
  gtk_table_attach_defaults(GTK_TABLE(table),label,0,1,0,1);
  gtk_table_attach_defaults(GTK_TABLE(table),spin_level,1,2,0,1);
  
  label = gtk_label_new("Noise level:");
  adj = (GtkAdjustment *)gtk_adjustment_new(options.noise_l,0,MAX_X-1,1,1,0);
  spin_noise_level = gtk_spin_button_new(adj,0,0);	
  gtk_table_attach_defaults(GTK_TABLE(table),label,0,1,1,2);
  gtk_table_attach_defaults(GTK_TABLE(table),spin_noise_level,1,2,1,2);
  
  label = gtk_label_new("Noise height:");
  adj = (GtkAdjustment *)gtk_adjustment_new(options.noise_h,0,MAX_Y-4,1,1,0);
  spin_noise_height = gtk_spin_button_new(adj,0,0);	
  gtk_table_attach_defaults(GTK_TABLE(table),label,0,1,2,3);
  gtk_table_attach_defaults(GTK_TABLE(table),spin_noise_height,1,2,2,3);
  
  hbox = gtk_hbox_new(TRUE,0);
  gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,TRUE,0);
  
  button = gtk_button_new_with_label("Play");	
  g_signal_connect ((gpointer) button, "clicked",
                    G_CALLBACK (game_new_wrapper),
                    NULL);
  gtk_box_pack_start(GTK_BOX(hbox),button,FALSE,TRUE,0);
  GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
  gtk_widget_grab_default (button);
  
  button1 = gtk_button_new_with_label("Accept");	
  g_signal_connect ((gpointer) button1, "clicked",
                    G_CALLBACK (game_new_accept),
                    NULL);
  gtk_box_pack_start(GTK_BOX(hbox),button1,FALSE,TRUE,0);
  GTK_WIDGET_SET_FLAGS (button1, GTK_CAN_DEFAULT);
  
  button2 = gtk_button_new_with_label("Close");	
  g_signal_connect ((gpointer) button2, "clicked",
                    G_CALLBACK (show_new_game_close),
                    GINT_TO_POINTER(TRUE));
  gtk_box_pack_start(GTK_BOX(hbox),button2,FALSE,TRUE,0);
  GTK_WIDGET_SET_FLAGS (button2, GTK_CAN_DEFAULT);
  
  gtk_widget_set_usize(new_game_window,220,130);
  gtk_widget_show_all(new_game_window);
  gtk_widget_set_sensitive(menu_game_start,FALSE);
  gtk_widget_set_sensitive(menu_game_quick,FALSE);
}
Exemplo n.º 9
0
int main(int argc, char **argv)
{
#ifdef ENABLE_NLS
	gtk_set_locale();
	textdomain(GETTEXT_PACKAGE);
#endif

	GtkWidget *window; /* 主窗口 */
	GtkWidget *vbox; /* 垂直盒子 */
	GtkWidget *hbox; /* 水平盒子 */
	GtkWidget *label; /* 静态标签 */
	GtkWidget *table; /* 表布局 */
	GtkWidget *entry; /* 文本框 */
	GtkWidget *checkButton; /* 复选项 */
	GtkWidget *button; /* 按键 */
	GtkEntryBuffer *buffer; /* 文本框缓存 */

	gtk_init(&argc, &argv);

	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);

	g_signal_connect(window, "delete-event", G_CALLBACK(delete_event), NULL);

	gtk_container_set_border_width(GTK_CONTAINER(window), 10);

	vbox = gtk_vbox_new(FALSE, 5);
	gtk_container_add(GTK_CONTAINER(window), vbox);

	label = gtk_label_new(_("欢迎使用 Mentohust 认证程序"));
	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);

	/* 开始主体表布局 */
	table = gtk_table_new(2, 1, FALSE);
	gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);

	label = gtk_label_new(_("用户名"));
	gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1);

	label = gtk_label_new(_("密码"));
	gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2);

	/* 用户名文本框 */
	buffer = gtk_entry_buffer_new (NULL, 0);
	entry = gtk_entry_new_with_buffer(buffer);
	gtk_table_attach_defaults(GTK_TABLE(table), entry, 1, 2, 0, 1);

	/* 密码文本框 */
	buffer = gtk_entry_buffer_new (NULL, 0);
	entry = gtk_entry_new_with_buffer(buffer);
	gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE);
	gtk_table_attach_defaults(GTK_TABLE(table), entry, 1, 2, 1, 2);
	/* 完成主体表布局 */

	hbox = gtk_hbox_new(FALSE, 5);

	checkButton = gtk_check_button_new_with_label(_("保存密码"));
	gtk_box_pack_end(GTK_BOX(hbox), checkButton, FALSE, FALSE, 0);

	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);

	/* 开始底部按键组 */
	hbox = gtk_hbox_new(FALSE, 5);

	button = gtk_button_new_with_label(_("连接"));
	gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);

	button = gtk_button_new_with_label(_("退出"));
	g_signal_connect (button, "clicked", G_CALLBACK (destroy), NULL);
	gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
	
	button = gtk_button_new_with_label(_("消息记录"));
	gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);

	button = gtk_button_new_with_label(_("高级设置"));
	gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);

	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
	/* 完成底部按键组 */

	gtk_widget_show_all(window);

	gtk_main();

	return 0;
}
Exemplo n.º 10
0
void EntityInfoTab::populateTab() {
	// Set the outer space of the vbox
	gtk_container_set_border_width(GTK_CONTAINER(_widget), 12);

	// Create the list store that contains the eclass => count map 
	_listStore = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT);

	// Create the treeview and pack two columns into it
	_treeView = gtk_tree_view_new_with_model(GTK_TREE_MODEL(_listStore));
	gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(_treeView), TRUE);

	GtkTreeViewColumn* eclassCol = gtkutil::TextColumn(_("Entity Class"), ECLASS_COL);
	gtk_tree_view_column_set_sort_column_id(eclassCol, ECLASS_COL);
	
	GtkTreeViewColumn* countCol = gtkutil::TextColumn(_("Count"), COUNT_COL);
	gtk_tree_view_column_set_sort_column_id(countCol, COUNT_COL);

	gtk_tree_view_append_column(GTK_TREE_VIEW(_treeView), eclassCol);
	gtk_tree_view_append_column(GTK_TREE_VIEW(_treeView), countCol);
	
    gtk_box_pack_start(GTK_BOX(_widget), gtkutil::ScrolledFrame(_treeView), TRUE, TRUE, 0);
    
    // Populate the liststore with the entity count information
    for (map::EntityBreakdown::Map::const_iterator i = _entityBreakdown.begin(); 
		 i != _entityBreakdown.end(); 
		 i++)
	{
		GtkTreeIter iter;
		gtk_list_store_append(_listStore, &iter);
		gtk_list_store_set(_listStore, &iter, 
						   ECLASS_COL, i->first.c_str(),
						   COUNT_COL, i->second, 
						   -1);
	}
	
	// The table containing the primitive statistics
	GtkTable* table = GTK_TABLE(gtk_table_new(3, 2, FALSE));
	gtk_box_pack_start(GTK_BOX(_widget), GTK_WIDGET(table), FALSE, FALSE, 0);
	
	_brushCount = gtkutil::LeftAlignedLabel("");
	_patchCount = gtkutil::LeftAlignedLabel("");
	_entityCount = gtkutil::LeftAlignedLabel("");
	
	GtkWidget* brushLabel = gtkutil::LeftAlignedLabel(_("Brushes:"));
	GtkWidget* patchLabel = gtkutil::LeftAlignedLabel(_("Patches:"));
	GtkWidget* entityLabel = gtkutil::LeftAlignedLabel(_("Entities:"));
	
	gtk_widget_set_size_request(brushLabel, 75, -1);
	gtk_widget_set_size_request(patchLabel, 75, -1);
	gtk_widget_set_size_request(entityLabel, 75, -1);
	
	gtk_table_attach(table, brushLabel, 0, 1, 0, 1,
					(GtkAttachOptions) (0),
					(GtkAttachOptions) (0), 0, 0);
	gtk_table_attach(table, patchLabel, 0, 1, 1, 2,
					(GtkAttachOptions) (0),
					(GtkAttachOptions) (0), 0, 0);
	gtk_table_attach(table, entityLabel, 0, 1, 2, 3,
					(GtkAttachOptions) (0),
					(GtkAttachOptions) (0), 0, 0);
	
	std::string bc = "<b>" + sizetToStr(GlobalCounters().getCounter(counterBrushes).get()) + "</b>";
	std::string pc = "<b>" + sizetToStr(GlobalCounters().getCounter(counterPatches).get()) + "</b>";
	std::string ec = "<b>" + sizetToStr(GlobalCounters().getCounter(counterEntities).get()) + "</b>";
	
	gtk_label_set_markup(GTK_LABEL(_brushCount), bc.c_str());
	gtk_label_set_markup(GTK_LABEL(_patchCount), pc.c_str());
	gtk_label_set_markup(GTK_LABEL(_entityCount), ec.c_str());
	
	gtk_table_attach_defaults(table, _brushCount, 1, 2, 0, 1);
	gtk_table_attach_defaults(table, _patchCount, 1, 2, 1, 2);
	gtk_table_attach_defaults(table, _entityCount, 1, 2, 2, 3);
}
Exemplo n.º 11
0
int main(void){
	
	GThread *theThread;
	GtkWidget *window;
	GtkWidget *save;
	GtkWidget *hbox;
	GtkWidget *theTable;
	GtkWidget *eBox, *eBox2;
	GtkWidget *lsh,*lsl,*lvh,*lvl;
	
	gtk_init(0,NULL);
	
	loadVars("segVals.dat",theVars);
	//int index=getIndex();
	
	window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
	hbox=gtk_hbox_new(FALSE,2);
	image=gtk_image_new();
	gseg=gtk_image_new();
	eBox=gtk_event_box_new();
	eBox2=gtk_event_box_new();
	theTable=gtk_table_new(5,2,TRUE);
  save = gtk_button_new_with_label("Save!");
	spinvh=gtk_spin_button_new_with_range(0,255,1);
	spinvl=gtk_spin_button_new_with_range(0,255,1);
	spinsh=gtk_spin_button_new_with_range(0,255,1);
	spinsl=gtk_spin_button_new_with_range(0,255,1);
	lsh=gtk_label_new_with_mnemonic("sh");
	lsl=gtk_label_new_with_mnemonic("sl");
	lvh=gtk_label_new_with_mnemonic("vh");
	lvl=gtk_label_new_with_mnemonic("vl");
	hval=gtk_label_new_with_mnemonic("Hue=0");
	
	gtk_window_set_title(GTK_WINDOW(window),"gtk application");
	
	g_signal_connect(window,"delete_event",G_CALLBACK(kill_window),NULL);
	g_signal_connect(eBox,"button_press_event",G_CALLBACK(pressed),image);
	g_signal_connect(eBox2,"button_press_event",G_CALLBACK(pressed),image);
	g_signal_connect(save,"button_press_event",G_CALLBACK(theSaver),NULL);
	g_signal_connect(spinsh,"changed",G_CALLBACK(updateValue), (gpointer)1);
	g_signal_connect(spinsl,"changed",G_CALLBACK(updateValue),(gpointer)2);
	g_signal_connect(spinvh,"changed",G_CALLBACK(updateValue),(gpointer)3);
	g_signal_connect(spinvl,"changed",G_CALLBACK(updateValue),(gpointer)4);//*/
	
	gtk_table_attach_defaults(GTK_TABLE(theTable),spinsh,0,1,0,1);
	gtk_table_attach_defaults(GTK_TABLE(theTable),spinsl,0,1,1,2);
	gtk_table_attach_defaults(GTK_TABLE(theTable),spinvh,0,1,2,3);
	gtk_table_attach_defaults(GTK_TABLE(theTable),spinvl,0,1,3,4);
	gtk_table_attach_defaults(GTK_TABLE(theTable),lsh,1,2,0,1);
	gtk_table_attach_defaults(GTK_TABLE(theTable),lsl,1,2,1,2);
	gtk_table_attach_defaults(GTK_TABLE(theTable),lvh,1,2,2,3);
	gtk_table_attach_defaults(GTK_TABLE(theTable),lvl,1,2,3,4);
	gtk_table_attach_defaults(GTK_TABLE(theTable),hval,0,2,4,5);
	
				updateLimits();
				/*gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinsh),theVars[7+theIndex*2].theInt);
				gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinsl),theVars[6+theIndex*2].theInt);
				gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinvh),theVars[13+theIndex*2].theInt);
				gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinvl),theVars[12+theIndex*2].theInt);//*/
	
	gtk_container_add(GTK_CONTAINER(eBox),image);
	gtk_container_add(GTK_CONTAINER(eBox2),gseg);
	//gtk_box_pack_start(GTK_BOX(hbox),gseg,FALSE,FALSE,2);
	gtk_box_pack_start(GTK_BOX(hbox),eBox2,FALSE,FALSE,2);
	gtk_box_pack_start(GTK_BOX(hbox),eBox,FALSE,FALSE,2);
	gtk_box_pack_start(GTK_BOX(hbox),theTable,FALSE,FALSE,2);
	gtk_box_pack_start(GTK_BOX(hbox),save,TRUE,TRUE,2);
	//gtk_box_pack_start(GTK_BOX(hbox),save,FALSE,FALSE,2);
	gtk_container_add(GTK_CONTAINER(window),hbox);
	
	  if( g_thread_supported() )
  {
     g_thread_init(NULL);
     gdk_threads_init();                   // Called to initialize internal mutex "gdk_threads_mutex".
     printf("g_thread supported\n");
  }
  else
  {
     printf("g_thread NOT supported\n");
     exit(0);
  }
  theThread = g_thread_create((GThreadFunc)ocvThread, NULL, TRUE, NULL);
  assert(theThread!=NULL);
  
	gtk_widget_show_all(window);
	
	gtk_main();
	
	return 0;
}	
Exemplo n.º 12
0
/* createWindow
 * Creates the main window
 *
 * @return void
 */
void createWindow () {
	this.mainWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_default_size((GtkWindow*) this.mainWindow, window_width, window_height);
	gtk_window_set_title((GtkWindow*) this.mainWindow, "Threadville");
	gtk_window_set_position((GtkWindow*) this.mainWindow, GTK_WIN_POS_CENTER_ALWAYS);

	/* Principal vbox */
	this.vbox = gtk_vbox_new(FALSE, 10);
	GtkWidget *valign = gtk_alignment_new(0, 1, 0, 0);
	gtk_container_add((GtkContainer*) this.vbox, valign);
	gtk_container_add((GtkContainer*) this.mainWindow, this.vbox);

	/* Parameters Frame */
	GtkWidget *parametersFrame = gtk_frame_new("Parámetros de Ejecucion");
	gtk_frame_set_shadow_type((GtkFrame*) parametersFrame, GTK_SHADOW_ETCHED_IN);
	GtkWidget *parametersTable = gtk_table_new(3, 8, FALSE);
	gtk_table_set_row_spacings((GtkTable*) parametersTable, 5);
	gtk_table_set_col_spacings((GtkTable*) parametersTable, 5);
	
	//Generate car
	GtkWidget *generateCarBtn = gtk_button_new_with_label("Generar carro");
	gtk_table_attach_defaults((GtkTable*) parametersTable, generateCarBtn, 0,1,0,1);
	gtk_signal_connect(GTK_OBJECT(generateCarBtn), "clicked", GTK_SIGNAL_FUNC(generate_car_callback_event), NULL);
	carPathInput = gtk_entry_new();
	gtk_entry_set_text((GtkEntry*) carPathInput, "");
	gtk_table_attach_defaults((GtkTable*) parametersTable, carPathInput, 1,2,0,1);
	carTypeCombo = gtk_combo_box_new_text();
	gtk_combo_box_append_text(GTK_COMBO_BOX(carTypeCombo), "Rojo");
	gtk_combo_box_append_text(GTK_COMBO_BOX(carTypeCombo), "Azul");
	gtk_combo_box_append_text(GTK_COMBO_BOX(carTypeCombo), "Verde");
	gtk_combo_box_append_text(GTK_COMBO_BOX(carTypeCombo), "Negro");
	gtk_combo_box_append_text(GTK_COMBO_BOX(carTypeCombo), "Blanco");
	gtk_combo_box_append_text(GTK_COMBO_BOX(carTypeCombo), "Amarillo");
	gtk_combo_box_set_active(GTK_COMBO_BOX(carTypeCombo), RED);
	gtk_table_attach_defaults((GtkTable*) parametersTable, carTypeCombo, 2,3,0,1);
	carModeCheck = gtk_check_button_new_with_label("auto");
	gtk_table_attach_defaults((GtkTable*) parametersTable, carModeCheck, 3,4,0,1);
	gtk_toggle_button_set_active((GtkToggleButton*) carModeCheck, TRUE);

	// Generate Ambulance
	GtkWidget *generateAmbulanceBtn = gtk_button_new_with_label("Generar Ambulancia");
	gtk_table_attach_defaults((GtkTable*) parametersTable, generateAmbulanceBtn, 4,5,0,1);
	gtk_signal_connect(GTK_OBJECT(generateAmbulanceBtn), "clicked", GTK_SIGNAL_FUNC(generate_ambulance_callback_event), NULL);
	ambulancePathInput = gtk_entry_new();
	gtk_entry_set_text((GtkEntry*) ambulancePathInput, "e.g., A1, B1, C2, C5");
	gtk_table_attach_defaults((GtkTable*) parametersTable, ambulancePathInput, 5,6,0,1);
	ambulanceModeCheck = gtk_check_button_new_with_label("auto");
	gtk_table_attach_defaults((GtkTable*) parametersTable, ambulanceModeCheck, 6,7,0,1);
	gtk_toggle_button_set_active((GtkToggleButton*) ambulanceModeCheck, TRUE);

	// Buses
	redBusModeCheck = gtk_check_button_new_with_label("Bus Rojo");
	gtk_table_attach_defaults((GtkTable*) parametersTable, redBusModeCheck, 0,1,1,2);
	gtk_toggle_button_set_active((GtkToggleButton*) redBusModeCheck, TRUE);
	gtk_signal_connect(GTK_OBJECT(redBusModeCheck), "clicked", GTK_SIGNAL_FUNC(red_bus_checkbox_callback_event), NULL);
	greenBusModeCheck = gtk_check_button_new_with_label("Bus Verde");
	gtk_table_attach_defaults((GtkTable*) parametersTable, greenBusModeCheck, 1,2,1,2);
	gtk_toggle_button_set_active((GtkToggleButton*) greenBusModeCheck, TRUE);
	gtk_signal_connect(GTK_OBJECT(greenBusModeCheck), "clicked", GTK_SIGNAL_FUNC(green_bus_checkbox_callback_event), NULL);
	blueBusModeCheck = gtk_check_button_new_with_label("Bus Azul");
	gtk_table_attach_defaults((GtkTable*) parametersTable, blueBusModeCheck, 2,3,1,2);
	gtk_toggle_button_set_active((GtkToggleButton*) blueBusModeCheck, TRUE);
	gtk_signal_connect(GTK_OBJECT(blueBusModeCheck), "clicked", GTK_SIGNAL_FUNC(blue_bus_checkbox_callback_event), NULL);
	whiteBusModeCheck = gtk_check_button_new_with_label("Bus Blanco");
	gtk_table_attach_defaults((GtkTable*) parametersTable, whiteBusModeCheck, 3,4,1,2);
	gtk_toggle_button_set_active((GtkToggleButton*) whiteBusModeCheck, TRUE);
	gtk_signal_connect(GTK_OBJECT(whiteBusModeCheck), "clicked", GTK_SIGNAL_FUNC(white_bus_checkbox_callback_event), NULL);
	grayBusModeCheck = gtk_check_button_new_with_label("Bus Gris");
	gtk_table_attach_defaults((GtkTable*) parametersTable, grayBusModeCheck, 4,5,1,2);
	gtk_toggle_button_set_active((GtkToggleButton*) grayBusModeCheck, TRUE);
	gtk_signal_connect(GTK_OBJECT(grayBusModeCheck), "clicked", GTK_SIGNAL_FUNC(gray_bus_checkbox_callback_event), NULL);
	blackBusModeCheck = gtk_check_button_new_with_label("Bus Negro");
	gtk_table_attach_defaults((GtkTable*) parametersTable, blackBusModeCheck, 5,6,1,2);
	gtk_toggle_button_set_active((GtkToggleButton*) blackBusModeCheck, TRUE);
	gtk_signal_connect(GTK_OBJECT(blackBusModeCheck), "clicked", GTK_SIGNAL_FUNC(black_bus_checkbox_callback_event), NULL);
	lightBlueBusModeCheck = gtk_check_button_new_with_label("Bus Celeste");
	gtk_table_attach_defaults((GtkTable*) parametersTable, lightBlueBusModeCheck, 6,7,1,2);
	gtk_toggle_button_set_active((GtkToggleButton*) lightBlueBusModeCheck, TRUE);
	gtk_signal_connect(GTK_OBJECT(lightBlueBusModeCheck), "clicked", GTK_SIGNAL_FUNC(lightblue_bus_checkbox_callback_event), NULL);
	pinkBusModeCheck = gtk_check_button_new_with_label("Bus Rosa");
	gtk_table_attach_defaults((GtkTable*) parametersTable, pinkBusModeCheck, 7,8,1,2);
	gtk_toggle_button_set_active((GtkToggleButton*) pinkBusModeCheck, TRUE);
	gtk_signal_connect(GTK_OBJECT(pinkBusModeCheck), "clicked", GTK_SIGNAL_FUNC(pink_bus_checkbox_callback_event), NULL);

	orangeBusModeCheck = gtk_check_button_new_with_label("Bus Naranja");
	gtk_table_attach_defaults((GtkTable*) parametersTable, orangeBusModeCheck, 0,1,2,3);
	gtk_toggle_button_set_active((GtkToggleButton*) orangeBusModeCheck, TRUE);
	gtk_signal_connect(GTK_OBJECT(orangeBusModeCheck), "clicked", GTK_SIGNAL_FUNC(orange_bus_checkbox_callback_event), NULL);
	allBusesModeCheck = gtk_check_button_new_with_label("Todos los Buses");
	gtk_table_attach_defaults((GtkTable*) parametersTable, allBusesModeCheck, 1,2,2,3);
	gtk_toggle_button_set_active((GtkToggleButton*) allBusesModeCheck, TRUE);
	gtk_signal_connect(GTK_OBJECT(allBusesModeCheck), "clicked", GTK_SIGNAL_FUNC(all_buses_checkbox_callback_event), NULL);
	obstaclesModeCheck = gtk_check_button_new_with_label("Obstaculos");
	gtk_table_attach_defaults((GtkTable*) parametersTable, obstaclesModeCheck, 2,3,2,3);
	gtk_toggle_button_set_active((GtkToggleButton*) obstaclesModeCheck, TRUE);
	gtk_signal_connect(GTK_OBJECT(obstaclesModeCheck), "clicked", GTK_SIGNAL_FUNC(obstacles_checkbox_callback_event), NULL);

	// Start/Finish
	GtkWidget *stopBtn = gtk_button_new_with_label("Terminar");
	gtk_table_attach_defaults((GtkTable*) parametersTable, stopBtn, 6,7,2,3);
	gtk_signal_connect(GTK_OBJECT(stopBtn), "clicked", GTK_SIGNAL_FUNC(stop_simulation_callback_event), NULL);
	GtkWidget *startBtn = gtk_button_new_with_label("Simular");
	gtk_table_attach_defaults((GtkTable*) parametersTable, startBtn, 7,8,2,3);
	gtk_signal_connect(GTK_OBJECT(startBtn), "clicked", GTK_SIGNAL_FUNC(start_simulation_callback_event), NULL);
	
	gtk_container_add((GtkContainer*) parametersFrame, parametersTable);
	gtk_box_pack_start((GtkBox*) this.vbox, parametersFrame, FALSE, FALSE, 0);

	// Attach close event to the window
	gtk_signal_connect((GtkObject*) this.mainWindow, "destroy", G_CALLBACK(gtk_main_quit), NULL);
}
Exemplo n.º 13
0
GtkWidget *
doodle_add_images (gchar *dir)
{
    int i;
    gchar *dirname;
    GtkWidget *table;
    GtkWidget *image;
    GtkWidget *ebox;
    GdkPixbuf *pixbuf;
    int r, c=2;
    int left, top;
    int w=50, h;

    dirname = dir;

    GArray *arr = get_files (dirname, FALSE, FALSE);

    r = (arr->len / c) + 1;
    table = gtk_table_new (r, c, TRUE);

    GString *mystr;
    for (i=0; i<arr->len; i++)
    {
        top = i / 2;
        left = i % 2;

        mystr = g_array_index (arr, GString*, i);
        image = gtk_image_new_from_file (mystr->str);
        pixbuf = gtk_image_get_pixbuf (GTK_IMAGE (image));

        h = gdk_pixbuf_get_height (pixbuf) * 50 / (float)gdk_pixbuf_get_width (pixbuf);
        pixbuf = gdk_pixbuf_scale_simple (pixbuf, w, h, GDK_INTERP_BILINEAR);

        gtk_widget_destroy (GTK_WIDGET (image));
        image = gtk_image_new_from_pixbuf (pixbuf);
        ebox = gtk_event_box_new ();
        gtk_widget_add_events (ebox, GDK_BUTTON_PRESS_MASK |
                                     GDK_BUTTON_RELEASE_MASK |
                                     GDK_POINTER_MOTION_MASK);

        //g_signal_connect (ebox, "button_press_event", G_CALLBACK (on_doodle_click_cb), mystr->str);

        // dnd
        gtk_drag_source_set (ebox,
                             GDK_BUTTON1_MASK,
                             TARGET_LIST,
                             N_TARGETS,
                             GDK_ACTION_COPY);
        g_signal_connect (ebox, "drag-data-get", G_CALLBACK (drag_data_get_handl),
                                                mystr->str + tbo_files_prefix_len (mystr->str));
        g_signal_connect (ebox, "drag-begin", G_CALLBACK (drag_begin_handl), mystr->str);
        g_signal_connect (ebox, "drag-end", G_CALLBACK (drag_end_handl), mystr->str);

        gtk_container_add (GTK_CONTAINER (ebox), image);
        gtk_table_attach_defaults (GTK_TABLE (table), ebox, left, left + 1, top, top + 1);
    }

    doodle_add_to_free (arr);

    gtk_widget_show_all (GTK_WIDGET (table));
    return table;
}
Exemplo n.º 14
0
 void StandardGame::CreateTableAndAddEverythingToIt(int y, int x)
 {
	 //Create table!
	Table = gtk_table_new(y,x,true);

	//Add Table to window!
	gtk_container_add(GTK_CONTAINER(Window), Table);

	//Attach Stat Buttons to Table
	gtk_table_attach_defaults (GTK_TABLE (Table), IncLifeButtonP1, 0, 1, 0, 1);
	gtk_table_attach_defaults (GTK_TABLE (Table), IncLifeButtonP2, 2, 3, 0, 1);
	gtk_table_attach_defaults (GTK_TABLE (Table), DecLifeButtonP1, 0, 1, 1, 2);
	gtk_table_attach_defaults (GTK_TABLE (Table), DecLifeButtonP2, 2, 3, 1, 2);
	gtk_table_attach_defaults (GTK_TABLE (Table), IncInfectButtonP1, 0, 1, 2, 3);
	gtk_table_attach_defaults (GTK_TABLE (Table), IncInfectButtonP2, 2, 3, 2, 3);
	gtk_table_attach_defaults (GTK_TABLE (Table), DecInfectButtonP1, 0, 1, 3, 4);
	gtk_table_attach_defaults (GTK_TABLE (Table), DecInfectButtonP2, 2, 3, 3, 4);

	//Attach Labels to Table
	gtk_table_attach_defaults (GTK_TABLE (Table), LifeLabelP1, 0, 1, 4, 5);
	gtk_table_attach_defaults (GTK_TABLE (Table), LifeLabelP2, 2, 3, 4, 5);
	gtk_table_attach_defaults (GTK_TABLE (Table), InfectLabelP1, 0, 1, 5, 6);
	gtk_table_attach_defaults (GTK_TABLE (Table), InfectLabelP2, 2, 3, 5, 6);

	//Attach Misc. Buttons to Table
	gtk_table_attach_defaults(GTK_TABLE (Table), ResetGameButton, 4, 5, 0, 1);
	gtk_table_attach_defaults(GTK_TABLE (Table), RollDiceButton, 4, 5, 2, 3);
	gtk_table_attach_defaults(GTK_TABLE (Table), FlipCoinButton, 4, 5, 4, 5);
	gtk_table_attach_defaults(GTK_TABLE (Table), CreateTokenButton, 4, 5, 6, 7);
	gtk_table_attach_defaults(GTK_TABLE (Table), RecentPlaysButton, 4, 5, 8, 9);
 }
Exemplo n.º 15
0
void initGui(struct GUI *gui){
	
	int i;
	
	gui->c_to = 0;
	gui->c_cc = 0;
	gui->c_bcc = 0;
	gui->c_file = 0;
	
	/* window */
	gui->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title(GTK_WINDOW(gui->window),"SimpleMail");
	g_signal_connect(GTK_OBJECT(gui->window),"destroy",G_CALLBACK(gtk_main_quit),NULL);
	
	/* entry */
	gui->iptFrom = gtk_entry_new();
	gui->iptSubject = gtk_entry_new();
	gui->iptPort = gtk_entry_new();
	gui->iptHost = gtk_entry_new();
	
	
	/* add button */
	gui->btnAddTo = gtk_button_new_with_label("+");
	gui->btnAddCc = gtk_button_new_with_label("+");
	gui->btnAddBcc = gtk_button_new_with_label("+");
	gui->btnAddFile = gtk_button_new_with_label("+");
	gui->btnSend = gtk_button_new_with_label("Send");
	
	/* open file button */
	gui->btnOpenmail = gtk_file_chooser_button_new("Open mail",GTK_FILE_CHOOSER_ACTION_OPEN);
	
	/* connect */
	g_signal_connect(GTK_OBJECT(gui->btnAddTo),"clicked",G_CALLBACK(addTo),gui);
	g_signal_connect(GTK_OBJECT(gui->btnAddCc),"clicked",G_CALLBACK(addCc),gui);
	g_signal_connect(GTK_OBJECT(gui->btnAddBcc),"clicked",G_CALLBACK(addBcc),gui);
	g_signal_connect(GTK_OBJECT(gui->btnAddFile),"clicked",G_CALLBACK(addFile),gui);
	g_signal_connect(GTK_OBJECT(gui->btnSend),"clicked",G_CALLBACK(sendMail),gui);
	
	/* table */
	gui->table = gtk_table_new(9,4,FALSE);
	gui->tableTo = gtk_table_new(1024,1,FALSE);
	gui->tableCc = gtk_table_new(1024,1,FALSE);
	gui->tableBcc = gtk_table_new(1024,1,FALSE);
	gui->tableFile = gtk_table_new(1024,1,FALSE);
	gui->tableCon = gtk_table_new(1,5,FALSE);
	
	//0-1
	gtk_table_attach_defaults(GTK_TABLE(gui->table),gtk_label_new("Host:Port"),0,1,0,1);
	gtk_table_attach_defaults(GTK_TABLE(gui->table),gtk_label_new("From:"),0,1,1,2);
	gtk_table_attach_defaults(GTK_TABLE(gui->table),gtk_label_new("To:"),0,1,2,3);
	gtk_table_attach_defaults(GTK_TABLE(gui->table),gtk_label_new("Cc:"),0,1,3,4);
	gtk_table_attach_defaults(GTK_TABLE(gui->table),gtk_label_new("Bcc:"),0,1,4,5);
	gtk_table_attach_defaults(GTK_TABLE(gui->table),gtk_label_new("Subject:"),0,1,5,6);
	gtk_table_attach_defaults(GTK_TABLE(gui->table),gtk_label_new("Mail body:"),0,1,6,7);
	gtk_table_attach_defaults(GTK_TABLE(gui->table),gtk_label_new("Attachment:"),0,1,7,8);
	
	//1-2
	gtk_table_attach_defaults(GTK_TABLE(gui->table),gui->tableCon,1,3,0,1);
	gtk_table_attach_defaults(GTK_TABLE(gui->table),gui->iptFrom,1,2,1,2);
	gtk_table_attach_defaults(GTK_TABLE(gui->table),gui->tableTo,1,2,2,3);
	gtk_table_attach_defaults(GTK_TABLE(gui->table),gui->tableCc,1,2,3,4);
	gtk_table_attach_defaults(GTK_TABLE(gui->table),gui->tableBcc,1,2,4,5);
	gtk_table_attach_defaults(GTK_TABLE(gui->table),gui->iptSubject,1,2,5,6);
	gtk_table_attach_defaults(GTK_TABLE(gui->table),gui->btnOpenmail,1,2,6,7);
	gtk_table_attach_defaults(GTK_TABLE(gui->table),gui->tableFile,1,2,7,8);

	//2-3
	gtk_table_attach_defaults(GTK_TABLE(gui->table),gui->btnAddTo,2,3,2,3);
	gtk_table_attach_defaults(GTK_TABLE(gui->table),gui->btnAddCc,2,3,3,4);
	gtk_table_attach_defaults(GTK_TABLE(gui->table),gui->btnAddBcc,2,3,4,5);
	gtk_table_attach_defaults(GTK_TABLE(gui->table),gui->btnAddFile,2,3,7,8);
	
	//3-4
	for(i=0;i<8;i++){
		gui->statu[i] = gtk_label_new("-");
		gtk_table_attach_defaults(GTK_TABLE(gui->table),gui->statu[i],3,4,i,i+1);
	}
	gtk_table_attach_defaults(GTK_TABLE(gui->table),gui->btnSend,3,4,8,9);
		
	/* init iptTo */
	gui->iptTo[gui->c_to++] = gtk_entry_new();
	gtk_table_attach_defaults(GTK_TABLE(gui->tableTo),gui->iptTo[gui->c_to-1],0,1,gui->c_to-1,gui->c_to);
	
	/* init tableCon*/
	gtk_table_attach_defaults(GTK_TABLE(gui->tableCon),gui->iptHost,0,3,0,1);
	gtk_table_attach_defaults(GTK_TABLE(gui->tableCon),gtk_label_new(":"),3,4,0,1);
	gtk_table_attach_defaults(GTK_TABLE(gui->tableCon),gui->iptPort,4,5,0,1);
	
	
	gtk_container_add(GTK_CONTAINER(gui->window), gui->table);
	
}
Exemplo n.º 16
0
void gtkui_dhcp_spoofing(void)
{
   GtkWidget *dialog, *table, *hbox, *image, *label, *entry1, *entry2, *entry3, *frame;
   gint response = 0;
   
   DEBUG_MSG("gtk_dhcp_spoofing");
//   memset(params, '\0', PARAMS_LEN+1);
   
   dialog = gtk_dialog_new_with_buttons("MITM Attack: DHCP Spoofing", GTK_WINDOW (window),
                                        GTK_DIALOG_MODAL, GTK_STOCK_OK, GTK_RESPONSE_OK,
                                        GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL);
   gtk_container_set_border_width(GTK_CONTAINER (dialog), 5);
   gtk_dialog_set_has_separator(GTK_DIALOG (dialog), FALSE);

   hbox = gtk_hbox_new (FALSE, 5);
   gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox, FALSE, FALSE, 0);
   gtk_widget_show(hbox);
   
   image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG);
   gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.1);
   gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 5);
   gtk_widget_show(image);

   frame = gtk_frame_new("Server Information");
   gtk_container_set_border_width(GTK_CONTAINER (frame), 5);
   gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
   gtk_widget_show(frame);
      
   table = gtk_table_new(3, 2, FALSE);
   gtk_table_set_row_spacings(GTK_TABLE (table), 5);
   gtk_table_set_col_spacings(GTK_TABLE (table), 5);
   gtk_container_set_border_width(GTK_CONTAINER (table), 8);
   gtk_container_add(GTK_CONTAINER (frame), table);
   gtk_widget_show(table);

   label = gtk_label_new("IP Pool (optional)");
   gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
   gtk_table_attach(GTK_TABLE (table), label, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
   gtk_widget_show(label);

   entry1 = gtk_entry_new(); 
   gtk_table_attach_defaults(GTK_TABLE (table), entry1, 1, 2, 0, 1);
   gtk_widget_show(entry1);
   
   label = gtk_label_new("Netmask"); 
   gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
   gtk_table_attach(GTK_TABLE (table), label, 0, 1, 1, 2, GTK_FILL, GTK_FILL, 0, 0);
   gtk_widget_show(label);

   entry2 = gtk_entry_new();
   gtk_entry_set_max_length(GTK_ENTRY (entry2), IP6_ASCII_ADDR_LEN);
   gtk_table_attach_defaults(GTK_TABLE (table), entry2, 1, 2, 1, 2);
   gtk_widget_show(entry2);

   label = gtk_label_new("DNS Server IP");   
   gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
   gtk_table_attach(GTK_TABLE (table), label, 0, 1, 2, 3, GTK_FILL, GTK_FILL, 0, 0);
   gtk_widget_show(label);

   entry3 = gtk_entry_new();
   gtk_entry_set_max_length(GTK_ENTRY (entry3), IP6_ASCII_ADDR_LEN);
   gtk_table_attach_defaults(GTK_TABLE (table), entry3, 1, 2, 2, 3);
   gtk_widget_show(entry3);

   response = gtk_dialog_run(GTK_DIALOG(dialog));
   if(response == GTK_RESPONSE_OK) {
      gtk_widget_hide(dialog);
//      memset(params, '\0', PARAMS_LEN);

      snprintf(params, PARAMS_LEN+1, "dhcp:%s/%s/%s", gtk_entry_get_text(GTK_ENTRY(entry1)),
                       gtk_entry_get_text(GTK_ENTRY(entry2)), gtk_entry_get_text(GTK_ENTRY(entry3)));

      DEBUG_MSG("ec_gtk_dhcp: DHCP MITM %s", params);
      gtkui_start_mitm();
   }

   gtk_widget_destroy(dialog);

   /* a simpler method:
      gtkui_input_call("Parameters :", params + strlen("dhcp:"), PARAMS_LEN - strlen("dhcp:"), gtkui_start_mitm);
   */
}
Exemplo n.º 17
0
int main (int argc, char *argv[])
{
    static GtkWidget *window;
    GtkWidget *scrolled_window;
    GtkWidget *table;
    GtkWidget *button;
    char buffer[32];
    int i, j;

    gtk_init (&argc, &argv);

    /* スクロールウィンドウをパックするためのダイアログを
     * 新規に作成する。*/
    window = gtk_dialog_new ();
    gtk_signal_connect (GTK_OBJECT (window), "destroy",
                        (GtkSignalFunc) destroy, NULL);
    gtk_window_set_title (GTK_WINDOW (window), "GtkScrolledWindow example");
    gtk_container_set_border_width (GTK_CONTAINER (window), 0);
    gtk_widget_set_usize(window, 300, 300);

    /* 新しくスクロールドウィンドウを作成 */
    scrolled_window = gtk_scrolled_window_new (NULL, NULL);

    gtk_container_set_border_width (GTK_CONTAINER (scrolled_window), 10);

    /* ポリシーは GTK_POLICY AUTOMATIC か GTK_POLICY_ALWAYS のどちらかである。
     * GTK_POLICY_AUTOMATIC は自動的にスクロールバーが必要か判断するのに対し、
     * GTK_POLICY_ALWAYS は常にスクロールバーを表示する。
     * 最初に設定しているのが水平方向で、次が垂直方向である。*/

    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
                                    GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);

    /* ダイアログウィンドウは内部に vbox を持っている */
    gtk_box_pack_start (GTK_BOX (GTK_DIALOG(window)->vbox), scrolled_window,
                        TRUE, TRUE, 0);
    gtk_widget_show (scrolled_window);

    /* 10 x 10 の 正方形の表を作成 */
    table = gtk_table_new (10, 10, FALSE);

    /* x 方向と y 方向のスペーシングを 10 に設定 */
    gtk_table_set_row_spacings (GTK_TABLE (table), 10);
    gtk_table_set_col_spacings (GTK_TABLE (table), 10);

    /* テーブルをスクロールドウィンドウにパック */
    gtk_scrolled_window_add_with_viewport (
                   GTK_SCROLLED_WINDOW (scrolled_window), table);
    gtk_widget_show (table);

    /* これはスクロールドウィンドウのデモ用に、トグルボタンのテーブル
     * を作成しているだけ。*/
    for (i = 0; i < 10; i++)
       for (j = 0; j < 10; j++) {
          sprintf (buffer, "button (%d,%d)\n", i, j);
          button = gtk_toggle_button_new_with_label (buffer);
          gtk_table_attach_defaults (GTK_TABLE (table), button,
                                     i, i+1, j, j+1);
          gtk_widget_show (button);
       }

    /* "close" ボタンをダイアログの下に追加 */
    button = gtk_button_new_with_label ("close");
    gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
                               (GtkSignalFunc) gtk_widget_destroy,
                               GTK_OBJECT (window));

    /* このボタンをデフォルトに指定 */

    GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
    gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->action_area), button, TRUE, TRUE, 0);

    /* この操作でこのボタンをデフォルトのボタンにする。"Enter" キーを
       押すだけでボタンが押される。 */
    gtk_widget_grab_default (button);
    gtk_widget_show (button);

    gtk_widget_show (window);

    gtk_main();

    return(0);
}
void finestra2(struttura *str)
{
 GtkWidget *frame, *winbox, *table;
 GtkWidget **buttonArray;

 int i, x, y;
 char s[NUM_OF_BUTTONS+3][10]={"ctrl","alt","z","r","x","c","v","+","-","a","f","m","f1","f2","f3","f4","f5","f9","nf","f10",".","→","↓","close"};
 

 /* Create window */
 //gtk_init (NULL,NULL);
 
 window = gtk_window_new (GTK_WINDOW_POPUP);
 gtk_window_set_default_size (GTK_WINDOW(window),WINDOW_WIDTH, WINDOW_HEIGHT);

 winbox = gtk_vbox_new (FALSE, 0);
 gtk_container_add (GTK_CONTAINER (window), winbox);
 gtk_widget_show (winbox);

  /* Crea una Frame */
 frame = gtk_frame_new("Special Functions");
 gtk_container_add(GTK_CONTAINER(winbox), frame);
 gtk_widget_show (frame);

 box = gtk_vbox_new (FALSE, 0);
 gtk_container_add (GTK_CONTAINER (frame), box);
 gtk_widget_show (box);

 buttonArray = (GtkWidget**)g_malloc((NUM_OF_BUTTONS+3)*sizeof(GtkButton**));

 table = gtk_table_new(NUM_OF_ROWS+1, NUM_OF_COLUMNS, TRUE);
 gtk_table_set_row_spacings(GTK_TABLE(table), 1);
 gtk_table_set_col_spacings(GTK_TABLE(table), 1);
 x=y=0;
 
 for(i=0; i<NUM_OF_BUTTONS+3;i++)
 {
   buttonArray[i] = gtk_button_new_with_label(s[i]);
   gtk_table_attach_defaults(GTK_TABLE(table), buttonArray[i], x, x+1, y, y+1);
   //gtk_widget_set_name(buttonArray[i],s[i]);
   gtk_widget_set_size_request(buttonArray[i],60,40);

   g_signal_connect(G_OBJECT(buttonArray[i]), "clicked", G_CALLBACK(button_clicked2),str);
   x++;
   if(x==NUM_OF_COLUMNS)
   {
   	x=0;
    	y++;
   }
 }
 gtk_box_pack_start(GTK_BOX(box), table, FALSE, FALSE, 0);

 /* Create label for Shift and Ctrl buttons */
 mylabel = gtk_label_new ("Ctrl and Alt off");
 gtk_container_add(GTK_CONTAINER(box), mylabel);
 gtk_widget_show (mylabel);

 gtk_widget_show_all(window);
 gtk_widget_hide(window);


}
Exemplo n.º 19
0
static void
ifopts_edit_cb(GtkWidget *w, gpointer data _U_)
{
	GtkWidget	  *ifopts_edit_dlg, *cur_scr_win, *main_hb, *main_tb,
			  *cur_opts_fr, *ed_opts_fr, *main_vb,
			  *if_descr_lb,
			  *if_hide_lb,
			  *bbox, *ok_bt, *cancel_bt, *help_bt;

	GtkListStore	  *list_store;
	GtkWidget	  *list;
	GtkTreeViewColumn *column;
	GtkCellRenderer   *renderer;
 	GtkTreeView       *list_view;
	GtkTreeSelection  *selection;

	int row = 0;

	GtkWidget   *caller   = gtk_widget_get_toplevel(w);

	/* Has an edit dialog box already been opened for that top-level
	   widget? */
	ifopts_edit_dlg = g_object_get_data(G_OBJECT(caller), IFOPTS_DIALOG_PTR_KEY);
	if (ifopts_edit_dlg != NULL) {
		/* Yes.  Just re-activate that dialog box. */
		reactivate_window(ifopts_edit_dlg);
		return;
	}

	/* create a new dialog */
	ifopts_edit_dlg = dlg_conf_window_new("Wireshark: Preferences: Interface Options");
	gtk_window_set_default_size(GTK_WINDOW(ifopts_edit_dlg), 1000, 440);

	main_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 1, FALSE);
	gtk_container_set_border_width(GTK_CONTAINER(main_vb), 5);
	gtk_container_add(GTK_CONTAINER(ifopts_edit_dlg), main_vb);
	gtk_widget_show(main_vb);

	/* create current options frame */
	cur_opts_fr = gtk_frame_new("Interfaces");
	gtk_box_pack_start(GTK_BOX(main_vb), cur_opts_fr, TRUE, TRUE, 0);
	gtk_widget_show(cur_opts_fr);

	/* create a scrolled window to pack the current options TreeView widget into */
	cur_scr_win = scrolled_window_new(NULL, NULL);
	gtk_container_set_border_width(GTK_CONTAINER(cur_scr_win), 3);
	gtk_container_add(GTK_CONTAINER(cur_opts_fr), cur_scr_win);
	gtk_widget_show(cur_scr_win);

	/*
	 * Create current options TreeView.
	 */
	list_store = gtk_list_store_new(N_COLUMN,	/* Total number of columns XXX	*/
					G_TYPE_STRING,	/* Device			*/
					G_TYPE_STRING,	/* Description			*/
#ifdef HAVE_PCAP_CREATE
					G_TYPE_BOOLEAN,	/* Monitor mode		*/
#endif
					G_TYPE_STRING,	/* Default link-layer		*/
					G_TYPE_STRING,	/* Comment			*/
					G_TYPE_BOOLEAN,	/* Hide?			*/
					G_TYPE_INT);	/* Dlt 				*/

	list = gtk_tree_view_new_with_model (GTK_TREE_MODEL (list_store));

	list_view = GTK_TREE_VIEW(list);

	/* The view now holds a reference.  We can get rid of our own reference */
	g_object_unref (G_OBJECT (list_store));

	/*
	 * Create the first column packet, associating the "text" attribute of the
	 * cell_renderer to the first column of the model
	 */
	renderer = gtk_cell_renderer_text_new ();
	column = gtk_tree_view_column_new_with_attributes ("Device", renderer,
							   "text", DEVICE_COLUMN,
							   NULL);

	gtk_tree_view_column_set_resizable(column, TRUE);
	gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
#ifdef _WIN32
	gtk_tree_view_column_set_min_width(column, 230);
#else
	gtk_tree_view_column_set_min_width(column, 70);
#endif
	/* Add the column to the view. */
	gtk_tree_view_append_column (list_view, column);

	renderer = gtk_cell_renderer_text_new ();
	column = gtk_tree_view_column_new_with_attributes ("Description", renderer,
							   "text", DESC_COLUMN,
							   NULL);

	gtk_tree_view_column_set_resizable(column, TRUE);
	gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
	gtk_tree_view_column_set_min_width(column, 260);
	/* Add the column to the view. */
	gtk_tree_view_append_column (list_view, column);

#ifdef HAVE_PCAP_CREATE
	/*
	 * XXX - for some reason, this doesn't show up.
	 */
	renderer = gtk_cell_renderer_toggle_new ();
	column = gtk_tree_view_column_new_with_attributes ("Default to monitor mode", renderer,
							   "active", DEF_MONITOR_MODE_COLUMN,
							   NULL);

	gtk_tree_view_column_set_resizable(column, FALSE);
	gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
	/* Add the column to the view. */
	gtk_tree_view_append_column (list_view, column);
#endif

	renderer = gtk_cell_renderer_text_new ();
	column = gtk_tree_view_column_new_with_attributes ("Default link-layer", renderer,
							   "text", DEF_LINK_LAYER_COLUMN,
							   NULL);

	gtk_tree_view_column_set_resizable(column, TRUE);
	gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
	gtk_tree_view_column_set_min_width(column, 230);
	/* Add the column to the view. */
	gtk_tree_view_append_column (list_view, column);

	renderer = gtk_cell_renderer_text_new ();
	column = gtk_tree_view_column_new_with_attributes ("Comment", renderer,
							   "text", COMMENT_COLUMN,
							   NULL);

	gtk_tree_view_column_set_resizable(column, TRUE);
	gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
	gtk_tree_view_column_set_min_width(column, 100);
	/* Add the column to the view. */
	gtk_tree_view_append_column (list_view, column);

	renderer = gtk_cell_renderer_toggle_new ();
	column = gtk_tree_view_column_new_with_attributes ("Hide?", renderer,
							   "active", HIDE_COLUMN,
							   NULL);

	gtk_tree_view_column_set_resizable(column, FALSE);
	gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
	/* Add the column to the view. */
	gtk_tree_view_append_column (list_view, column);

#if 0
	/* Don't show the DLT column */
	renderer = gtk_cell_renderer_text_new ();
	column = gtk_tree_view_column_new_with_attributes ("DLT", renderer,
							   "text", DLT_COLUMN,
							   NULL);

	gtk_tree_view_column_set_resizable(column, TRUE);
	gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
	gtk_tree_view_column_set_min_width(column, 40);
	/* Add the column to the view. */
	gtk_tree_view_append_column (list_view, column);
#endif
	/* Setup the selection handler */
	selection = gtk_tree_view_get_selection(list_view);
	gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);

	cur_list = list;
	gtk_container_add(GTK_CONTAINER(cur_scr_win), cur_list);

	if_selection = selection;

	g_signal_connect (G_OBJECT (selection), "changed", /* select_row */
			  G_CALLBACK (ifopts_edit_ifsel_cb),
			  NULL);

	gtk_widget_show(cur_list);

	/* add interface names to cell */
	ifopts_if_liststore_add();

	/* create edit options frame */
	ed_opts_fr = gtk_frame_new("Properties");
	gtk_box_pack_start(GTK_BOX(main_vb), ed_opts_fr, FALSE, FALSE, 0);
	gtk_widget_show(ed_opts_fr);

	main_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5, TRUE);
	gtk_container_set_border_width(GTK_CONTAINER(main_hb), 3);
	gtk_container_add(GTK_CONTAINER(ed_opts_fr), main_hb);
	gtk_widget_show(main_hb);

	/* table to hold description text entry and hide button */
	main_tb = gtk_table_new(IFOPTS_TABLE_ROWS, 4, FALSE);
	gtk_box_pack_start(GTK_BOX(main_hb), main_tb, TRUE, FALSE, 10);
	gtk_table_set_row_spacings(GTK_TABLE(main_tb), 10);
	gtk_table_set_col_spacings(GTK_TABLE(main_tb), 10);
	gtk_widget_show(main_tb);

	if_dev_lb = gtk_label_new("Device:");
	gtk_table_attach_defaults(GTK_TABLE(main_tb), if_dev_lb, 0, 1, row, row+1);
	gtk_misc_set_alignment(GTK_MISC(if_dev_lb), 1.0f, 0.5f);
	gtk_widget_show(if_dev_lb);

	if_dev_lb = gtk_label_new("");
	gtk_table_attach_defaults(GTK_TABLE(main_tb), if_dev_lb, 1, 2, row, row+1);
	gtk_misc_set_alignment(GTK_MISC(if_dev_lb), 0.0f, 0.5f);
	gtk_widget_show(if_dev_lb);
	row++;

	if_name_lb = gtk_label_new("Description:");
	gtk_table_attach_defaults(GTK_TABLE(main_tb), if_name_lb, 0, 1, row, row+1);
	gtk_misc_set_alignment(GTK_MISC(if_name_lb), 1.0f, 0.5f);
	gtk_widget_show(if_name_lb);

	if_name_lb = gtk_label_new("");
	gtk_table_attach_defaults(GTK_TABLE(main_tb), if_name_lb, 1, 2, row, row+1);
	gtk_misc_set_alignment(GTK_MISC(if_name_lb), 0.0f, 0.5f);
	gtk_widget_show(if_name_lb);
	row++;

#ifdef HAVE_PCAP_CREATE
	/* create "monitor mode" label and button */
	if_monitor_lb = gtk_label_new("Monitor mode:");
	gtk_table_attach_defaults(GTK_TABLE(main_tb), if_monitor_lb, 0, 1, row, row+1);
	gtk_misc_set_alignment(GTK_MISC(if_monitor_lb), 1.0f, 0.5f);
	gtk_widget_show(if_monitor_lb);

	if_monitor_cb = gtk_check_button_new();
	g_signal_connect(if_monitor_cb, "toggled", G_CALLBACK(ifopts_edit_monitor_changed_cb),
			cur_list);
	gtk_table_attach_defaults(GTK_TABLE(main_tb), if_monitor_cb, 1, 2, row, row+1);
	gtk_widget_show(if_monitor_cb);
        row++;
#endif

	if_linktype_lb = gtk_label_new("Default link-layer header type:");
	gtk_table_attach_defaults(GTK_TABLE(main_tb), if_linktype_lb, 0, 1, row, row+1);
	gtk_misc_set_alignment(GTK_MISC(if_linktype_lb), 1.0f, 0.5f);
	gtk_widget_show(if_linktype_lb);

	if_linktype_cb = gtk_combo_box_text_new();
	num_linktypes = 0;
	interfaces_info_nochange = FALSE;
	g_signal_connect(if_linktype_cb, "changed", G_CALLBACK(ifopts_edit_linktype_changed_cb),
			cur_list);
	gtk_table_attach_defaults(GTK_TABLE(main_tb), if_linktype_cb, 1, 2, row, row+1);
	gtk_widget_show(if_linktype_cb);
	row++;

	/* create interface description label and text entry */
	if_descr_lb = gtk_label_new("Comment:");
	gtk_table_attach_defaults(GTK_TABLE(main_tb), if_descr_lb, 0, 1, row, row+1);
	gtk_misc_set_alignment(GTK_MISC(if_descr_lb), 1.0f, 0.5f);
	gtk_widget_show(if_descr_lb);

	if_descr_te = gtk_entry_new();
	g_signal_connect(if_descr_te, "changed", G_CALLBACK(ifopts_edit_descr_changed_cb),
			cur_list);
	gtk_entry_set_max_length(GTK_ENTRY(if_descr_te), IFOPTS_MAX_DESCR_LEN);
	gtk_table_attach_defaults(GTK_TABLE(main_tb), if_descr_te, 1, 2, row, row+1);
	gtk_widget_show(if_descr_te);
	row++;

	/* create "hide interface" label and button */
	if_hide_lb = gtk_label_new("Hide interface?:");
	gtk_table_attach_defaults(GTK_TABLE(main_tb), if_hide_lb, 0, 1, row, row+1);
	gtk_misc_set_alignment(GTK_MISC(if_hide_lb), 1.0f, 0.5f);
	gtk_widget_show(if_hide_lb);

	if_hide_cb = gtk_check_button_new();
	g_signal_connect(if_hide_cb, "toggled", G_CALLBACK(ifopts_edit_hide_changed_cb),
			cur_list);
	gtk_table_attach_defaults(GTK_TABLE(main_tb), if_hide_cb, 1, 2, row, row+1);
	gtk_widget_show(if_hide_cb);

	if_default_if_lb = gtk_label_new("(Default interface cannot be hidden)");
	gtk_table_attach_defaults(GTK_TABLE(main_tb), if_default_if_lb, 1, 3, row, row+1);
	gtk_misc_set_alignment(GTK_MISC(if_default_if_lb), 0.15f, 0.5f);
	row++;

	/* button row: OK and Cancel buttons */
	bbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_CANCEL, GTK_STOCK_HELP, NULL);
	gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 0);
	gtk_widget_show(bbox);

	ok_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_OK);
	gtk_widget_set_tooltip_text(ok_bt, "Save changes and exit dialog");
	g_signal_connect(ok_bt, "clicked", G_CALLBACK(ifopts_edit_ok_cb), ifopts_edit_dlg);

	cancel_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CANCEL);
	gtk_widget_set_tooltip_text(cancel_bt, "Cancel and exit dialog");
        window_set_cancel_button(ifopts_edit_dlg, cancel_bt, window_cancel_button_cb);

	help_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_HELP);
	g_signal_connect(help_bt, "clicked", G_CALLBACK(topic_cb),
			 (gpointer)HELP_CAPTURE_INTERFACE_OPTIONS_DIALOG);
	gtk_widget_set_tooltip_text (help_bt, "Show topic specific help");

	gtk_widget_grab_default(ok_bt);

	g_signal_connect(ifopts_edit_dlg, "delete_event", G_CALLBACK(window_delete_event_cb),
                 NULL);
	/* Call a handler when we're destroyed, so we can inform
	   our caller, if any, that we've been destroyed. */
	g_signal_connect(ifopts_edit_dlg, "destroy", G_CALLBACK(ifopts_edit_destroy_cb), NULL);

	/* Set the key for the new dialog to point to our caller. */
	g_object_set_data(G_OBJECT(ifopts_edit_dlg), IFOPTS_CALLER_PTR_KEY, caller);
	/* Set the key for the caller to point to us */
	g_object_set_data(G_OBJECT(caller), IFOPTS_DIALOG_PTR_KEY, ifopts_edit_dlg);

	gtk_widget_show(ifopts_edit_dlg); /* triggers ifopts_edit_ifsel_cb() with the  */
                                          /*  "interfaces" TreeView first row selected */
	window_present(ifopts_edit_dlg);
}
void finestra(struttura *str)
{
 GtkWidget *frame, *winbox, *box,*table;//nuovo x lista

 GtkWidget **buttonArray;

 int i, x, y;
 char s_i[3];
 /*Definiamo vettore che contiene gli indici delle posizioni possibili dell'interfaccia*/
 char s[NUM_OF_BUTTONS][10]={"1","2 abc","3 def","4 ghi","5 jkl","6 mno","7 pqrs","8 tuv","9 wxyz","⇧ shift","` 0 ","PT","del","space","↵","sf","tab","ins","→","↓","."};
 /* GDK_GRAVITY_SOUTH_WEST is the reference point corresponding at the lower left corner -> position 1
  GDK_GRAVITY_SOUTH is the reference point corresponding at the middle of the lower edge -> position 2
  GDK_GRAVITY_SOUTH_EAST is the reference point corresponding at the lower right corner -> position 3
*/
 str->window = gtk_window_new (GTK_WINDOW_POPUP);
 gtk_window_set_default_size (GTK_WINDOW(str->window),  WINDOW_WIDTH, WINDOW_HEIGHT);
 
 winbox = gtk_vbox_new (FALSE, 0);
 gtk_container_add (GTK_CONTAINER (str->window), winbox);
 gtk_widget_show (winbox);

 /* Crea una Frame */
 frame = gtk_frame_new(NULL);
 gtk_container_add(GTK_CONTAINER(winbox), frame);
 /* Setta l'etichetta della frame */
 gtk_frame_set_label( GTK_FRAME(frame), "Keyboard" );
 gtk_widget_show (frame);

 box = gtk_vbox_new (FALSE, 0);
 gtk_container_add (GTK_CONTAINER (frame), box);
 gtk_widget_show (box);

 buttonArray = (GtkWidget**)g_malloc((NUM_OF_BUTTONS)*sizeof(GtkButton**));

 table = gtk_table_new(NUM_OF_ROWS, NUM_OF_COLUMNS, TRUE);
 gtk_table_set_row_spacings(GTK_TABLE(table), 1);
 gtk_table_set_col_spacings(GTK_TABLE(table), 1);
 x=y=0; 
 for(i=1; i<=NUM_OF_BUTTONS;i++)
 {  
    buttonArray[i] = gtk_button_new_with_label(s[i-1]);
    gtk_widget_set_size_request(buttonArray[i],60,40);
    gtk_table_attach_defaults(GTK_TABLE(table), buttonArray[i], x, x+1, y, y+1);
    supportoButtonTable(s_i,i);
    gtk_widget_set_name(buttonArray[i],s_i);
    g_signal_connect(G_OBJECT(buttonArray[i]), "clicked", G_CALLBACK(button_clicked),str);
    if(++x==NUM_OF_COLUMNS)
     {
      x=0;
      y++;
     }
  }

 gtk_box_pack_start(GTK_BOX(box), table, FALSE, FALSE, 0);

 /* Crea una Label per i tasti Shift e Ctrl */
 str->mylabel = gtk_label_new ("Shift off");
 gtk_widget_set_usize(str->mylabel, 0, 1);
 gtk_container_add(GTK_CONTAINER(box), str->mylabel);
 gtk_widget_show (str->mylabel);


 
 /* Crea una Lista per il T9 */
 str->tp.gtklist=gtk_list_new();
 gtk_list_set_selection_mode((GtkList *)str->tp.gtklist, GTK_SELECTION_SINGLE);
 str->tp.scrolled_window=gtk_scrolled_window_new(NULL,NULL);
 gtk_widget_set_usize(str->tp.scrolled_window, 0,S_W_MAIN);//75//
 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (str->tp.scrolled_window),GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(str->tp.scrolled_window),str->tp.gtklist);
 gtk_container_add(GTK_CONTAINER(box),str->tp.scrolled_window);
 gtk_widget_show(str->tp.scrolled_window);
 gtk_widget_show(str->tp.gtklist);
 gtk_signal_connect(GTK_OBJECT(str->tp.gtklist),"selection_changed",GTK_SIGNAL_FUNC(sigh_print_selection),str);//nuovo x lista
 

 
 
 /* Crea una Label per il T9 */
 str->mylabel2 = gtk_label_new ("PT off");
 gtk_widget_set_usize(str->mylabel2, 0, 1);
 gtk_container_add(GTK_CONTAINER(box),str->mylabel2);
 gtk_widget_show (str->mylabel2);

 /* Crea uno status icon per la minimizzazione */
 str->tray_icon = gtk_status_icon_new();
 g_signal_connect(G_OBJECT(str->tray_icon), "activate",G_CALLBACK(tray_icon_on_click), str);
 gtk_status_icon_set_from_icon_name(str->tray_icon,GTK_STOCK_MEDIA_STOP);
 gtk_status_icon_set_from_file(str->tray_icon,PATH_IMG);
 gtk_status_icon_set_tooltip(str->tray_icon,"Keyboard Tray Icon");
 gtk_status_icon_set_visible(str->tray_icon, FALSE);

 gtk_widget_show_all(str->window);
 /*salviamo le dim massime dello schermo corrente*/
 getMaxScreen(str);
 ins(str);
// gtk_main ();
}
Exemplo n.º 21
0
bool RunLinuxDialog()
{
	GtkWidget *dialog;
	GtkWidget *main_box, *central_box, *advance_box, *res_box, *hw_box, *sw_box, *shader_box;
	GtkWidget  *native_box, *fsaa_box, *resxy_box, *renderer_box, *interlace_box, *threads_box, *filter_box;
	GtkWidget *hw_table, *shader_table, *res_frame, *hw_frame, *sw_frame, *shader_frame;
	GtkWidget *interlace_combo_box, *threads_spin;
	GtkWidget *interlace_label, *threads_label, *native_label,  *fsaa_label, *rexy_label, *render_label, *filter_label;

	GtkWidget *fsaa_combo_box, *render_combo_box, *filter_combo_box;
	GtkWidget *shader, *shader_conf, *shader_label, *shader_conf_label;
	GtkWidget *shadeboost_check, *paltex_check, *fba_check, *aa_check,  *native_res_check, *fxaa_check, *shaderfx_check;
	GtkWidget *sb_contrast, *sb_brightness, *sb_saturation;
	GtkWidget *resx_spin, *resy_spin;

	GtkWidget *hack_table, *hack_skipdraw_label, *hack_box, *hack_frame;
	GtkWidget *hack_alpha_check, *hack_date_check, *hack_offset_check, *hack_skipdraw_spin, *hack_msaa_check, *hack_sprite_check, * hack_wild_check, *hack_enble_check, *hack_logz_check;
	GtkWidget *hack_tco_label, *hack_tco_entry;
	GtkWidget *gl_box, *gl_frame, *gl_table;

	GtkWidget *notebook, *page_label[2];

	int return_value;

	GdkPixbuf* logo_pixmap;
	GtkWidget *logo_image;

	/* Create the widgets */
	dialog = gtk_dialog_new_with_buttons (
		"GSdx Config",
		NULL, /* parent window*/
		(GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
		"OK", GTK_RESPONSE_ACCEPT,
		"Cancel", GTK_RESPONSE_REJECT,
		NULL);

	// The main area for the whole dialog box.
	main_box = gtk_vbox_new(false, 5);
	central_box = gtk_vbox_new(false, 5);
	advance_box = gtk_vbox_new(false, 5);

	// The Internal resolution frame and container.
	res_box = gtk_vbox_new(false, 5);
	res_frame = gtk_frame_new ("OpenGL Internal Resolution (can cause glitches)");
	gtk_container_add(GTK_CONTAINER(res_frame), res_box);

	// The extra shader setting frame/container/table
	shader_box = gtk_vbox_new(false, 5);
	shader_frame = gtk_frame_new("Custom Shader Settings");
	gtk_container_add(GTK_CONTAINER(shader_frame), shader_box);
	shader_table = gtk_table_new(8,2, false);
	gtk_container_add(GTK_CONTAINER(shader_box), shader_table);

	// The hardware mode frame, container, and table.
	hw_box = gtk_vbox_new(false, 5);
	hw_frame = gtk_frame_new ("Hardware Mode Settings");
	gtk_container_add(GTK_CONTAINER(hw_frame), hw_box);
	hw_table = gtk_table_new(5,2, false);
	gtk_container_add(GTK_CONTAINER(hw_box), hw_table);

	// The software mode frame and container. (It doesn't have enough in it for a table.)
	sw_box = gtk_vbox_new(false, 5);
	sw_frame = gtk_frame_new ("Software Mode Settings");
	gtk_container_add(GTK_CONTAINER(sw_frame), sw_box);

	// The hack frame and container.
	hack_box = gtk_hbox_new(false, 5);
	hack_frame = gtk_frame_new ("Hacks");
	gtk_container_add(GTK_CONTAINER(hack_frame), hack_box);
	hack_table = gtk_table_new(3,3, false);
	gtk_container_add(GTK_CONTAINER(hack_box), hack_table);

	// Grab a logo, to make things look nice.
	logo_pixmap = gdk_pixbuf_from_pixdata(&gsdx_ogl_logo, false, NULL);
	logo_image = gtk_image_new_from_pixbuf(logo_pixmap);
	gtk_box_pack_start(GTK_BOX(main_box), logo_image, true, true, 0);

	// Create the renderer combo box and label, and stash them in a box.
	render_label = gtk_label_new ("Renderer:");
	render_combo_box = CreateRenderComboBox();
	renderer_box = gtk_hbox_new(false, 5);
	// Use gtk_box_pack_start instead of gtk_container_add so it lines up nicely.
	gtk_box_pack_start(GTK_BOX(renderer_box), render_label, false, false, 5);
	gtk_box_pack_start(GTK_BOX(renderer_box), render_combo_box, false, false, 5);

	// Create the interlace combo box and label, and stash them in a box.
	interlace_label = gtk_label_new ("Interlacing (F5):");
	interlace_combo_box = CreateInterlaceComboBox();
	interlace_box = gtk_hbox_new(false, 5);
	gtk_box_pack_start(GTK_BOX(interlace_box), interlace_label, false, false, 5);
	gtk_box_pack_start(GTK_BOX(interlace_box), interlace_combo_box, false, false, 5);

	// Create the filter combo box.
	filter_label = gtk_label_new ("Texture Filtering:");
	filter_combo_box = CreateFilterComboBox();
	filter_box = gtk_hbox_new(false, 5);
	gtk_box_pack_start(GTK_BOX(filter_box), filter_label, false, false, 5);
	gtk_box_pack_start(GTK_BOX(filter_box), filter_combo_box, false, false, 0);

	// Create the threading spin box and label, and stash them in a box. (Yes, we do a lot of that.)
	threads_label = gtk_label_new("Extra rendering threads:");
	threads_spin = gtk_spin_button_new_with_range(0,100,1);
	gtk_spin_button_set_value(GTK_SPIN_BUTTON(threads_spin), theApp.GetConfig("extrathreads", 0));
	threads_box = gtk_hbox_new(false, 0);
	gtk_box_pack_start(GTK_BOX(threads_box), threads_label, false, false, 5);
	gtk_box_pack_start(GTK_BOX(threads_box), threads_spin, false, false, 5);

	// A bit of funkiness for the resolution box.
	native_label = gtk_label_new("Original PS2 Resolution: ");
	native_res_check = gtk_check_button_new_with_label("Native");
	native_box = gtk_hbox_new(false, 5);
	gtk_box_pack_start(GTK_BOX(native_box), native_label, false, false, 5);
	gtk_box_pack_start(GTK_BOX(native_box), native_res_check, false, false, 5);

	fsaa_label = gtk_label_new("Or Use Scaling:");
	fsaa_combo_box = CreateMsaaComboBox();
	fsaa_box = gtk_hbox_new(false, 5);
	gtk_box_pack_start(GTK_BOX(fsaa_box), fsaa_label, false, false, 5);
	gtk_box_pack_start(GTK_BOX(fsaa_box), fsaa_combo_box, false, false, 5);

	rexy_label = gtk_label_new("Custom Resolution:");
	resx_spin = gtk_spin_button_new_with_range(256,8192,1);
	gtk_spin_button_set_value(GTK_SPIN_BUTTON(resx_spin), theApp.GetConfig("resx", 1024));
	resy_spin = gtk_spin_button_new_with_range(256,8192,1);
	gtk_spin_button_set_value(GTK_SPIN_BUTTON(resy_spin), theApp.GetConfig("resy", 1024));
	resxy_box = gtk_hbox_new(false, 5);
	gtk_box_pack_start(GTK_BOX(resxy_box), rexy_label, false, false, 5);
	gtk_box_pack_start(GTK_BOX(resxy_box), resx_spin, false, false, 5);
	gtk_box_pack_start(GTK_BOX(resxy_box), resy_spin, false, false, 5);

	// shader fx entry
	shader            = gtk_file_chooser_button_new("Select an external shader", GTK_FILE_CHOOSER_ACTION_OPEN);
	shader_conf       = gtk_file_chooser_button_new("Then select a config", GTK_FILE_CHOOSER_ACTION_OPEN);
	shader_label      = gtk_label_new("External shader glsl");
	shader_conf_label = gtk_label_new("External shader conf");

	// Create our hack settings.
	hack_alpha_check    = gtk_check_button_new_with_label("Alpha Hack");
	hack_date_check     = gtk_check_button_new_with_label("Date Hack");
	hack_offset_check   = gtk_check_button_new_with_label("Offset Hack");
	hack_skipdraw_label = gtk_label_new("Skipdraw:");
	hack_skipdraw_spin  = gtk_spin_button_new_with_range(0,1000,1);
	hack_enble_check    = gtk_check_button_new_with_label("Enable User Hacks");
	hack_wild_check     = gtk_check_button_new_with_label("Wild arm Hack");
	hack_sprite_check   = gtk_check_button_new_with_label("Sprite Hack");
	hack_msaa_check     = gtk_check_button_new_with_label("Msaa Hack");
	hack_tco_label      = gtk_label_new("Texture Offset: 0x");
	hack_tco_entry      = gtk_entry_new();
	hack_logz_check     = gtk_check_button_new_with_label("Log Depth Hack");

	gtk_spin_button_set_value(GTK_SPIN_BUTTON(hack_skipdraw_spin), theApp.GetConfig("UserHacks_SkipDraw", 0));
	set_hex_entry(hack_tco_entry, theApp.GetConfig("UserHacks_TCOffset", 0));

	// Tables are strange. The numbers are for their position: left, right, top, bottom.
	gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_alpha_check, 0, 1, 0, 1);
	gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_offset_check, 1, 2, 0, 1);
	gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_sprite_check, 0, 1, 1, 2);
	gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_wild_check, 1, 2, 1, 2);
	gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_logz_check, 0, 1, 2, 3);
	gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_date_check, 1, 2, 2, 3);
	// Note: MSAA is not implemented yet. I disable it to make the table square
	//gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_msaa_check, 2, 3, 1, 2);
	gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_skipdraw_label, 0, 1, 3, 4);
	gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_skipdraw_spin, 1, 2, 3, 4);
	gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_tco_label, 0, 1, 4, 5);
	gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_tco_entry, 1, 2, 4, 5);

	// Create our checkboxes.
	shadeboost_check = gtk_check_button_new_with_label("Shade boost");
	paltex_check     = gtk_check_button_new_with_label("Allow 8 bits textures");
	fba_check        = gtk_check_button_new_with_label("Alpha correction (FBA)");
	aa_check         = gtk_check_button_new_with_label("Edge anti-aliasing (AA1)");
	fxaa_check       = gtk_check_button_new_with_label("Fxaa shader");
	shaderfx_check   = gtk_check_button_new_with_label("External shader");

	// Set the checkboxes.
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(shadeboost_check), theApp.GetConfig("shadeboost", 1));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(paltex_check), theApp.GetConfig("paltex", 0));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(fba_check), theApp.GetConfig("fba", 1));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(aa_check), theApp.GetConfig("aa1", 0));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(fxaa_check), theApp.GetConfig("fxaa", 0));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(shaderfx_check), theApp.GetConfig("shaderfx", 0));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(native_res_check), theApp.GetConfig("nativeres", 0));

	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_alpha_check), theApp.GetConfig("UserHacks_AlphaHack", 0));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_offset_check), theApp.GetConfig("UserHacks_HalfPixelOffset", 0));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_date_check), theApp.GetConfig("UserHacks_DateGL4", 0));

	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_enble_check), theApp.GetConfig("UserHacks", 0));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_msaa_check), theApp.GetConfig("UserHacks_MSAA", 0));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_wild_check), theApp.GetConfig("UserHacks_WildHack", 0));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_sprite_check), theApp.GetConfig("UserHacks_SpriteHack", 0));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_logz_check), theApp.GetConfig("logz", 1));

	// Shadeboost scale
#if GTK_MAJOR_VERSION < 3
	sb_brightness = gtk_hscale_new_with_range(0, 200, 10);
#else
	sb_brightness = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, 0, 200, 10);
#endif
	GtkWidget* sb_brightness_label = gtk_label_new("Shade Boost Brightness");
	gtk_scale_set_value_pos(GTK_SCALE(sb_brightness), GTK_POS_RIGHT);
	gtk_range_set_value(GTK_RANGE(sb_brightness), theApp.GetConfig("ShadeBoost_Brightness", 50));

#if GTK_MAJOR_VERSION < 3
	sb_contrast = gtk_hscale_new_with_range(0, 200, 10);
#else
	sb_contrast = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, 0, 200, 10);
#endif
	GtkWidget* sb_contrast_label = gtk_label_new("Shade Boost Contrast");
	gtk_scale_set_value_pos(GTK_SCALE(sb_contrast), GTK_POS_RIGHT);
	gtk_range_set_value(GTK_RANGE(sb_contrast), theApp.GetConfig("ShadeBoost_Contrast", 50));

#if GTK_MAJOR_VERSION < 3
	sb_saturation = gtk_hscale_new_with_range(0, 200, 10);
#else
	sb_saturation = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, 0, 200, 10);
#endif
	GtkWidget* sb_saturation_label = gtk_label_new("Shade Boost Saturation");
	gtk_scale_set_value_pos(GTK_SCALE(sb_saturation), GTK_POS_RIGHT);
	gtk_range_set_value(GTK_RANGE(sb_saturation), theApp.GetConfig("ShadeBoost_Saturation", 50));

	// external shader entry
	gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(shader), theApp.GetConfig("shaderfx_glsl", "dummy.glsl").c_str());
	gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(shader_conf), theApp.GetConfig("shaderfx_conf", "dummy.ini").c_str());

	// Populate all those boxes we created earlier with widgets.
	gtk_container_add(GTK_CONTAINER(res_box), native_box);
	gtk_container_add(GTK_CONTAINER(res_box), fsaa_box);
	gtk_container_add(GTK_CONTAINER(res_box), resxy_box);

	gtk_container_add(GTK_CONTAINER(sw_box), threads_box);
	gtk_container_add(GTK_CONTAINER(sw_box), aa_check);

	// Tables are strange. The numbers are for their position: left, right, top, bottom.
	gtk_table_attach_defaults(GTK_TABLE(shader_table), fxaa_check, 0, 1, 0, 1);
	gtk_table_attach_defaults(GTK_TABLE(shader_table), shadeboost_check, 0, 1, 1, 2);
	gtk_table_attach_defaults(GTK_TABLE(shader_table), sb_brightness_label, 0, 1, 2, 3);
	gtk_table_attach_defaults(GTK_TABLE(shader_table), sb_brightness, 1, 2, 2, 3);
	gtk_table_attach_defaults(GTK_TABLE(shader_table), sb_contrast_label, 0, 1, 3, 4);
	gtk_table_attach_defaults(GTK_TABLE(shader_table), sb_contrast, 1, 2, 3, 4);
	gtk_table_attach_defaults(GTK_TABLE(shader_table), sb_saturation_label, 0, 1, 4, 5);
	gtk_table_attach_defaults(GTK_TABLE(shader_table), sb_saturation, 1, 2, 4, 5);
	gtk_table_attach_defaults(GTK_TABLE(shader_table), shaderfx_check, 0, 1, 5, 6);
	gtk_table_attach_defaults(GTK_TABLE(shader_table), shader_label, 0, 1, 6, 7);
	gtk_table_attach_defaults(GTK_TABLE(shader_table), shader, 1, 2, 6, 7);
	gtk_table_attach_defaults(GTK_TABLE(shader_table), shader_conf_label, 0, 1, 7, 8);
	gtk_table_attach_defaults(GTK_TABLE(shader_table), shader_conf, 1, 2, 7, 8);

	// Tables are strange. The numbers are for their position: left, right, top, bottom.
	gtk_table_attach_defaults(GTK_TABLE(hw_table), filter_box, 0, 1, 0, 1);
	gtk_table_attach_defaults(GTK_TABLE(hw_table), paltex_check, 0, 1, 1, 2);
	gtk_table_attach_defaults(GTK_TABLE(hw_table), fba_check, 1, 2, 1, 2);

	// The GL advance options
	gl_box = gtk_vbox_new(false, 5);
	gl_frame = gtk_frame_new ("OpenGL Very Advanced Custom Settings");
	gtk_container_add(GTK_CONTAINER(gl_frame), gl_box);
	gl_table = gtk_table_new(10, 2, false);
	gtk_container_add(GTK_CONTAINER(gl_box), gl_table);

	GtkWidget* gl_bs_label = gtk_label_new("Buffer Storage:");
	GtkWidget* gl_bs_combo = CreateGlComboBox("override_GL_ARB_buffer_storage");
	GtkWidget* gl_bt_label = gtk_label_new("Bindless Texture:");
	GtkWidget* gl_bt_combo = CreateGlComboBox("override_GL_ARB_bindless_texture");
	GtkWidget* gl_sso_label = gtk_label_new("Separate Shader:");
	GtkWidget* gl_sso_combo = CreateGlComboBox("override_GL_ARB_separate_shader_objects");
	GtkWidget* gl_ss_label = gtk_label_new("Shader Subroutine:");
	GtkWidget* gl_ss_combo = CreateGlComboBox("override_GL_ARB_shader_subroutine");
	GtkWidget* gl_gs_label = gtk_label_new("Geometry Shader:");
	GtkWidget* gl_gs_combo = CreateGlComboBox("override_geometry_shader");
	GtkWidget* gl_ils_label = gtk_label_new("Image Load Store:");
	GtkWidget* gl_ils_combo = CreateGlComboBox("override_GL_ARB_shader_image_load_store");
	GtkWidget* gl_cc_label = gtk_label_new("Clip Control (depth accuracy):");
	GtkWidget* gl_cc_combo = CreateGlComboBox("override_GL_ARB_clip_control");
	GtkWidget* gl_ct_label = gtk_label_new("Clear Texture:");
	GtkWidget* gl_ct_combo = CreateGlComboBox("override_GL_ARB_clear_texture");

	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_gs_label, 0, 1, 0, 1);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_gs_combo, 1, 2, 0, 1);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_bs_label, 0, 1, 1, 2);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_bs_combo, 1, 2, 1, 2);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_bt_label, 0, 1, 2, 3);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_bt_combo, 1, 2, 2, 3);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_sso_label, 0, 1, 3, 4);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_sso_combo, 1, 2, 3, 4);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_ss_label, 0, 1, 4, 5);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_ss_combo, 1, 2, 4, 5);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_ils_label, 0, 1, 5, 6);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_ils_combo, 1, 2, 5, 6);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_cc_label, 0, 1, 6, 7);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_cc_combo, 1, 2, 6, 7);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_ct_label, 0, 1, 7, 8);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_ct_combo, 1, 2, 7, 8);
	// those one are properly detected so no need a gui
#if 0
override_GL_ARB_copy_image = -1
override_GL_ARB_explicit_uniform_location = -1
override_GL_ARB_gpu_shader5 = -1
override_GL_ARB_shading_language_420pack = -1
#endif

	// Handle some nice tab
	notebook = gtk_notebook_new();
	page_label[0] = gtk_label_new("Global Setting");
	page_label[1] = gtk_label_new("Advance Setting");

	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), central_box, page_label[0]);
	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), advance_box, page_label[1]);

	// Put everything in the big box.
	gtk_container_add(GTK_CONTAINER(main_box), renderer_box);
	gtk_container_add(GTK_CONTAINER(main_box), interlace_box);
	gtk_container_add(GTK_CONTAINER(main_box), notebook);

	gtk_container_add(GTK_CONTAINER(central_box), res_frame);
	gtk_container_add(GTK_CONTAINER(central_box), shader_frame);
	gtk_container_add(GTK_CONTAINER(central_box), hw_frame);
	gtk_container_add(GTK_CONTAINER(central_box), sw_frame);

	gtk_container_add(GTK_CONTAINER(advance_box), hack_frame);
	gtk_container_add(GTK_CONTAINER(advance_box), gl_frame);

	// Put the box in the dialog and show it to the world.
	gtk_container_add (GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), main_box);
	gtk_widget_show_all (dialog);
	return_value = gtk_dialog_run (GTK_DIALOG (dialog));

	if (return_value == GTK_RESPONSE_ACCEPT)
	{
		int mode_height = 0, mode_width = 0;

		mode_width = theApp.GetConfig("ModeWidth", 640);
		mode_height = theApp.GetConfig("ModeHeight", 480);
		theApp.SetConfig("ModeHeight", mode_height);
		theApp.SetConfig("ModeWidth", mode_width);

		// Get all the settings from the dialog box.
		if (gtk_combo_box_get_active(GTK_COMBO_BOX(render_combo_box)) != -1) {
			// Note the value are based on m_gs_renderers vector on GSdx.cpp
			switch (gtk_combo_box_get_active(GTK_COMBO_BOX(render_combo_box))) {
				case 0: theApp.SetConfig("renderer", 10); break;
				case 1: theApp.SetConfig("renderer", 16); break;
				case 2: theApp.SetConfig("renderer", 11); break;
				case 3: theApp.SetConfig("renderer", 12); break;
				case 4: theApp.SetConfig("renderer", 13); break;
				case 5: theApp.SetConfig("renderer", 17); break;

				// Fallback to SW opengl
				default: theApp.SetConfig("renderer", 13); break;
			}
		}

		if (gtk_combo_box_get_active(GTK_COMBO_BOX(interlace_combo_box)) != -1)
			theApp.SetConfig( "interlace", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(interlace_combo_box)));

		theApp.SetConfig("extrathreads", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(threads_spin)));

		theApp.SetConfig("filter", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(filter_combo_box)));
		theApp.SetConfig("shadeboost", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(shadeboost_check)));
		theApp.SetConfig("paltex", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(paltex_check)));
		theApp.SetConfig("fba", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(fba_check)));
		theApp.SetConfig("aa1", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(aa_check)));
		theApp.SetConfig("fxaa", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(fxaa_check)));
		theApp.SetConfig("shaderfx", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(shaderfx_check)));
		theApp.SetConfig("nativeres", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(native_res_check)));

		theApp.SetConfig("shaderfx_glsl", gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(shader)));
		theApp.SetConfig("shaderfx_conf", gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(shader_conf)));

		theApp.SetConfig("ShadeBoost_Saturation", (int)gtk_range_get_value(GTK_RANGE(sb_saturation)));
		theApp.SetConfig("ShadeBoost_Brightness", (int)gtk_range_get_value(GTK_RANGE(sb_brightness)));
		theApp.SetConfig("ShadeBoost_Contrast", (int)gtk_range_get_value(GTK_RANGE(sb_contrast)));

		theApp.SetConfig("upscale_multiplier", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(fsaa_combo_box))+1);
		theApp.SetConfig("resx", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(resx_spin)));
		theApp.SetConfig("resy", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(resy_spin)));

		theApp.SetConfig("UserHacks_SkipDraw", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(hack_skipdraw_spin)));
		theApp.SetConfig("UserHacks_HalfPixelOffset", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_offset_check)));
		theApp.SetConfig("UserHacks_AlphaHack", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_alpha_check)));
		theApp.SetConfig("logz", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_logz_check)));
		theApp.SetConfig("UserHacks_DateGL4", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_date_check)));

		theApp.SetConfig("UserHacks_MSAA", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_msaa_check)));
		theApp.SetConfig("UserHacks_WildHack", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_wild_check)));
		theApp.SetConfig("UserHacks_SpriteHack", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_sprite_check)));
		theApp.SetConfig("UserHacks", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_enble_check)));
		theApp.SetConfig("UserHacks_TCOffset", get_hex_entry(hack_tco_entry));

		theApp.SetConfig("override_GL_ARB_clear_texture", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(gl_ct_combo)) - 1);
		theApp.SetConfig("override_GL_ARB_bindless_texture", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(gl_bt_combo)) - 1);
		theApp.SetConfig("override_GL_ARB_buffer_storage", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(gl_bs_combo)) - 1);
		theApp.SetConfig("override_GL_ARB_separate_shader_objects", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(gl_sso_combo)) - 1);
		theApp.SetConfig("override_GL_ARB_shader_subroutine", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(gl_ss_combo)) - 1);
		theApp.SetConfig("override_geometry_shader", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(gl_gs_combo)) - 1);
		theApp.SetConfig("override_GL_ARB_shader_image_load_store", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(gl_ils_combo)) - 1);
		theApp.SetConfig("override_GL_ARB_clip_control", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(gl_cc_combo)) - 1);

		// NOT supported yet
		theApp.SetConfig("msaa", 0);

		// Let's just be windowed for the moment.
		theApp.SetConfig("windowed", 1);

		gtk_widget_destroy (dialog);

		return true;
	}

	gtk_widget_destroy (dialog);

	return false;
}
Exemplo n.º 22
0
static void
contact_widget_contact_setup (EmpathyContactWidget *information)
{
  /* Setup label_status as a KludgeLabel */
  information->label_status = empathy_kludge_label_new ("");
  gtk_label_set_line_wrap_mode (GTK_LABEL (information->label_status),
                                PANGO_WRAP_WORD_CHAR);
  gtk_label_set_line_wrap (GTK_LABEL (information->label_status),
                           TRUE);

  if (!(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP))
    gtk_label_set_selectable (GTK_LABEL (information->label_status), TRUE);

  gtk_box_pack_start (GTK_BOX (information->hbox_presence),
        information->label_status, TRUE, TRUE, 0);
  gtk_widget_show (information->label_status);

  /* Setup account label/chooser */
  if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT)
    {
      information->widget_account = empathy_account_chooser_new ();

      g_signal_connect_swapped (information->widget_account, "changed",
            G_CALLBACK (contact_widget_change_contact),
            information);
    }
  else
    {
      /* Pack the protocol icon with the account name in an hbox */
      information->widget_account = gtk_hbox_new (FALSE, 6);

      information->label_account = gtk_label_new (NULL);
      if (!(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP)) {
        gtk_label_set_selectable (GTK_LABEL (information->label_account), TRUE);
      }
      gtk_misc_set_alignment (GTK_MISC (information->label_account), 0, 0.5);
      gtk_widget_show (information->label_account);

      information->image_account = gtk_image_new ();
      gtk_widget_show (information->image_account);

      gtk_box_pack_start (GTK_BOX (information->widget_account),
          information->image_account, FALSE, FALSE, 0);
      gtk_box_pack_start (GTK_BOX (information->widget_account),
          information->label_account, FALSE, TRUE, 0);
    }
  gtk_table_attach_defaults (GTK_TABLE (information->table_contact),
           information->widget_account,
           1, 2, 0, 1);
  gtk_widget_show (information->widget_account);

  /* Set up avatar chooser/display */
  if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_AVATAR)
    {
      information->widget_avatar = empathy_avatar_chooser_new ();
      g_signal_connect (information->widget_avatar, "changed",
            G_CALLBACK (contact_widget_avatar_changed_cb),
            information);
      if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT)
        {
          g_signal_connect (information->widget_account, "changed",
              G_CALLBACK (update_avatar_chooser_account_cb),
              information->widget_avatar);
          update_avatar_chooser_account_cb (
              EMPATHY_ACCOUNT_CHOOSER (information->widget_account),
              EMPATHY_AVATAR_CHOOSER (information->widget_avatar));
        }
    }
  else
    {
      information->widget_avatar = empathy_avatar_image_new ();

      g_signal_connect (information->widget_avatar, "popup-menu",
          G_CALLBACK (widget_avatar_popup_menu_cb), information);
      g_signal_connect (information->widget_avatar, "button-press-event",
          G_CALLBACK (widget_avatar_button_press_event_cb), information);
    }

  gtk_box_pack_start (GTK_BOX (information->vbox_avatar),
          information->widget_avatar,
          FALSE, FALSE,
          6);
  gtk_widget_show (information->widget_avatar);

  /* Setup id label/entry */
  if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ID)
    {
      information->widget_id = gtk_entry_new ();
      g_signal_connect (information->widget_id, "focus-out-event",
            G_CALLBACK (contact_widget_id_focus_out_cb),
            information);
      g_signal_connect (information->widget_id, "changed",
            G_CALLBACK (contact_widget_id_changed_cb),
            information);
    }
  else
    {
      information->widget_id = gtk_label_new (NULL);
      if (!(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP)) {
        gtk_label_set_selectable (GTK_LABEL (information->widget_id), TRUE);
      }
      gtk_misc_set_alignment (GTK_MISC (information->widget_id), 0, 0.5);
    }
  gtk_table_attach_defaults (GTK_TABLE (information->table_contact),
           information->widget_id,
           1, 2, 1, 2);
  gtk_widget_show (information->widget_id);

  /* Setup alias label/entry */
  if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ALIAS)
    {
      information->widget_alias = gtk_entry_new ();

      if (!(information->flags & EMPATHY_CONTACT_WIDGET_NO_SET_ALIAS))
        g_signal_connect (information->widget_alias, "focus-out-event",
              G_CALLBACK (contact_widget_entry_alias_focus_event_cb),
              information);

      /* Make return activate the window default (the Close button) */
      gtk_entry_set_activates_default (GTK_ENTRY (information->widget_alias),
          TRUE);
    }
  else
    {
      information->widget_alias = gtk_label_new (NULL);
      if (!(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP)) {
        gtk_label_set_selectable (GTK_LABEL (information->widget_alias), TRUE);
      }
      gtk_misc_set_alignment (GTK_MISC (information->widget_alias), 0, 0.5);
    }
  gtk_table_attach_defaults (GTK_TABLE (information->table_contact),
           information->widget_alias,
           1, 2, 2, 3);
  if (information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP) {
    gtk_label_set_selectable (GTK_LABEL (information->label_status), FALSE);
  }
  gtk_widget_show (information->widget_alias);

#if HAVE_FAVOURITE_CONTACTS
  /* Favorite */
  if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_FAVOURITE)
    {
      information->favourite_checkbox = gtk_check_button_new_with_label (
          _("Favorite"));

      g_signal_connect (information->favourite_checkbox, "toggled",
          G_CALLBACK (favourite_toggled_cb), information);

      gtk_table_attach_defaults (GTK_TABLE (information->table_contact),
           information->favourite_checkbox, 0, 2, 3, 4);

      information->fav_sig_id = g_signal_connect (information->manager,
          "favourites-changed",
          G_CALLBACK (contact_widget_favourites_changed_cb), information);

      gtk_widget_show (information->favourite_checkbox);
    }
#endif
}
Exemplo n.º 23
0
extern void get_info_resv(GtkTable *table, display_data_t *display_data)
{
	int error_code = SLURM_SUCCESS;
	List info_list = NULL;
	static int view = -1;
	static reserve_info_msg_t *resv_info_ptr = NULL;
	char error_char[100];
	GtkWidget *label = NULL;
	GtkTreeView *tree_view = NULL;
	static GtkWidget *display_widget = NULL;
	int j=0;
	ListIterator itr = NULL;
	sview_resv_info_t *sview_resv_info_ptr = NULL;
	reserve_info_t *resv_ptr = NULL;
	time_t now = time(NULL);
	GtkTreePath *path = NULL;
	static bool set_opts = FALSE;

	if (!set_opts)
		set_page_opts(RESV_PAGE, display_data_resv,
			      SORTID_CNT, _initial_page_opts);
	set_opts = TRUE;

	/* reset */
	if (!table && !display_data) {
		if (display_widget)
			gtk_widget_destroy(display_widget);
		display_widget = NULL;
		resv_info_ptr = NULL;
		goto reset_curs;
	}

	if (display_data)
		local_display_data = display_data;
	if (!table) {
		display_data_resv->set_menu = local_display_data->set_menu;
		goto reset_curs;
	}
	if (display_widget && toggled) {
		gtk_widget_destroy(display_widget);
		display_widget = NULL;
		goto display_it;
	}

	error_code = get_new_info_resv(&resv_info_ptr, force_refresh);
	if (error_code == SLURM_NO_CHANGE_IN_DATA) {
	} else if (error_code != SLURM_SUCCESS) {
		if (view == ERROR_VIEW)
			goto end_it;
		if (display_widget)
			gtk_widget_destroy(display_widget);
		view = ERROR_VIEW;
		sprintf(error_char, "slurm_load_reservations: %s",
			slurm_strerror(slurm_get_errno()));
		label = gtk_label_new(error_char);
		gtk_table_attach_defaults(table, label, 0, 1, 0, 1);
		gtk_widget_show(label);
		display_widget = gtk_widget_ref(GTK_WIDGET(label));
		goto end_it;
	}

display_it:
	info_list = _create_resv_info_list(resv_info_ptr);
	if (!info_list)
		goto reset_curs;
	/* set up the grid */
	if (display_widget && GTK_IS_TREE_VIEW(display_widget)
	    && gtk_tree_selection_count_selected_rows(
		    gtk_tree_view_get_selection(
			    GTK_TREE_VIEW(display_widget)))) {
		GtkTreeViewColumn *focus_column = NULL;
		/* highlight the correct nodes from the last selection */
		gtk_tree_view_get_cursor(GTK_TREE_VIEW(display_widget),
					 &path, &focus_column);
	}
	if (!path) {
		itr = list_iterator_create(info_list);
		while ((sview_resv_info_ptr = list_next(itr))) {
			resv_ptr = sview_resv_info_ptr->resv_ptr;
			if ((resv_ptr->start_time > now) ||
			    (resv_ptr->end_time   < now))
				continue;/* only map current reservations */
			j=0;
			while (resv_ptr->node_inx[j] >= 0) {
				change_grid_color(grid_button_list,
						  resv_ptr->node_inx[j],
						  resv_ptr->node_inx[j+1],
						  sview_resv_info_ptr->
						  color_inx,
						  true, 0);
				j += 2;
			}
		}
		list_iterator_destroy(itr);
		change_grid_color(grid_button_list, -1, -1,
				  MAKE_WHITE, true, 0);
	} else {
		highlight_grid(GTK_TREE_VIEW(display_widget),
			       SORTID_NODE_INX, SORTID_COLOR_INX,
			       grid_button_list);
		gtk_tree_path_free(path);
	}

	if (view == ERROR_VIEW && display_widget) {
		gtk_widget_destroy(display_widget);
		display_widget = NULL;
	}
	if (!display_widget) {
		tree_view = create_treeview(local_display_data,
					    &grid_button_list);
		gtk_tree_selection_set_mode(
			gtk_tree_view_get_selection(tree_view),
			GTK_SELECTION_MULTIPLE);
		display_widget = gtk_widget_ref(GTK_WIDGET(tree_view));
		gtk_table_attach_defaults(table,
					  GTK_WIDGET(tree_view),
					  0, 1, 0, 1);
		/* since this function sets the model of the tree_view
		   to the treestore we don't really care about
		   the return value */
		create_treestore(tree_view, display_data_resv,
				 SORTID_CNT, SORTID_TIME_START, SORTID_COLOR);
	}

	view = INFO_VIEW;
	_update_info_resv(info_list, GTK_TREE_VIEW(display_widget));
end_it:
	toggled = FALSE;
	force_refresh = FALSE;
reset_curs:
	if (main_window && main_window->window)
		gdk_window_set_cursor(main_window->window, NULL);
	return;
}
Exemplo n.º 24
0
static void
contact_widget_location_update (EmpathyContactWidget *information)
{
  GHashTable *location;
  GValue *value;
  gdouble lat = 0.0, lon = 0.0;
  gboolean has_position = TRUE;
  GtkWidget *label;
  guint row = 0;
  static const gchar* ordered_geolocation_keys[] = {
    EMPATHY_LOCATION_TEXT,
    EMPATHY_LOCATION_URI,
    EMPATHY_LOCATION_DESCRIPTION,
    EMPATHY_LOCATION_BUILDING,
    EMPATHY_LOCATION_FLOOR,
    EMPATHY_LOCATION_ROOM,
    EMPATHY_LOCATION_STREET,
    EMPATHY_LOCATION_AREA,
    EMPATHY_LOCATION_LOCALITY,
    EMPATHY_LOCATION_REGION,
    EMPATHY_LOCATION_COUNTRY,
    NULL
  };
  int i;
  const gchar *skey;
  gboolean display_map = FALSE;

  if (!(information->flags & EMPATHY_CONTACT_WIDGET_SHOW_LOCATION))
    {
      gtk_widget_hide (information->vbox_location);
      return;
    }

  location = empathy_contact_get_location (information->contact);
  if (location == NULL || g_hash_table_size (location) == 0)
    {
      gtk_widget_hide (information->vbox_location);
      return;
    }

  value = g_hash_table_lookup (location, EMPATHY_LOCATION_LAT);
  if (value == NULL)
      has_position = FALSE;
  else
      lat = g_value_get_double (value);

  value = g_hash_table_lookup (location, EMPATHY_LOCATION_LON);
  if (value == NULL)
      has_position = FALSE;
  else
      lon = g_value_get_double (value);

  value = g_hash_table_lookup (location, EMPATHY_LOCATION_TIMESTAMP);
  if (value == NULL)
    {
      gchar *loc = g_strdup_printf ("<b>%s</b>", _("Location"));
      gtk_label_set_markup (GTK_LABEL (information->label_location), loc);
      g_free (loc);
    }
  else
    {
      gchar *user_date;
      gchar *text;
      gint64 stamp;
      time_t time_;

      stamp = g_value_get_int64 (value);
      time_ = stamp;

      user_date = empathy_time_to_string_relative (time_);

      text = g_strconcat ( _("<b>Location</b>, "), user_date, NULL);
      gtk_label_set_markup (GTK_LABEL (information->label_location), text);
      g_free (text);
    }


  /* Prepare the location information table */
  if (information->table_location != NULL)
    {
      gtk_widget_destroy (information->table_location);
    }

  information->table_location = gtk_table_new (1, 2, FALSE);
  gtk_box_pack_start (GTK_BOX (information->subvbox_location),
      information->table_location, FALSE, FALSE, 5);


  for (i = 0; (skey = ordered_geolocation_keys[i]); i++)
    {
      const gchar* user_label;
      GValue *gvalue;
      char *svalue = NULL;

      gvalue = g_hash_table_lookup (location, (gpointer) skey);
      if (gvalue == NULL)
        continue;

      user_label = location_key_to_label (skey);

      label = gtk_label_new (user_label);
      gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
      gtk_table_attach (GTK_TABLE (information->table_location),
          label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, 10, 0);
      gtk_widget_show (label);

      if (G_VALUE_TYPE (gvalue) == G_TYPE_DOUBLE)
        {
          gdouble dvalue;
          dvalue = g_value_get_double (gvalue);
          svalue = g_strdup_printf ("%f", dvalue);
        }
      else if (G_VALUE_TYPE (gvalue) == G_TYPE_STRING)
        {
          svalue = g_value_dup_string (gvalue);
        }
      else if (G_VALUE_TYPE (gvalue) == G_TYPE_INT64)
        {
          time_t time_;

          time_ = g_value_get_int64 (value);
          svalue = empathy_time_to_string_utc (time_, _("%B %e, %Y at %R UTC"));
        }

      if (svalue != NULL)
        {
          label = gtk_label_new (svalue);
          gtk_table_attach_defaults (GTK_TABLE (information->table_location),
              label, 1, 2, row, row + 1);
          gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
          gtk_widget_show (label);

          if (!(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP))
            gtk_label_set_selectable (GTK_LABEL (label), TRUE);
        }

      g_free (svalue);
      row++;
    }

#if HAVE_LIBCHAMPLAIN
  if (has_position &&
      !(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP))
    {
      /* Cannot be displayed in tooltips until Clutter-Gtk can deal with such
       * windows */
      display_map = TRUE;
    }
#endif

  if (row > 0)
    {
      /* We can display some fields */
      gtk_widget_show (information->table_location);
    }
  else if (!display_map)
    {
      /* Can't display either fields or map */
      gtk_widget_hide (information->vbox_location);
      return;
    }

#if HAVE_LIBCHAMPLAIN
  if (display_map)
    {
      ClutterActor *marker;
      ChamplainLayer *layer;

      information->map_view_embed = gtk_champlain_embed_new ();
      information->map_view = gtk_champlain_embed_get_view (
          GTK_CHAMPLAIN_EMBED (information->map_view_embed));

      gtk_container_add (GTK_CONTAINER (information->viewport_map),
          information->map_view_embed);
      g_object_set (G_OBJECT (information->map_view),
          "show-license", TRUE,
          "scroll-mode", CHAMPLAIN_SCROLL_MODE_KINETIC,
          "zoom-level", 10,
          NULL);

      layer = champlain_layer_new ();
      champlain_view_add_layer (information->map_view, layer);

      marker = champlain_marker_new_with_text (
          empathy_contact_get_name (information->contact), NULL, NULL, NULL);
      champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker), lat, lon);
      clutter_container_add (CLUTTER_CONTAINER (layer), marker, NULL);

      champlain_view_center_on (information->map_view, lat, lon);
      gtk_widget_show_all (information->viewport_map);
    }
#endif

    gtk_widget_show (information->vbox_location);
}
Exemplo n.º 25
0
/*  public functions  */
GtkWidget * 
asgtk_gradient_new ()
{
	ASGtkGradient *ge;
    GtkWidget *main_vbox, *main_hbox;
	GtkWidget *scrolled_window ;
	GtkWidget *list_vbox ;
	GtkWidget *frame, *hbox, *vbox, *btn, *table;
	GtkWidget *label ; 

    ge = g_object_new (ASGTK_TYPE_GRADIENT, NULL);
	colorize_gtk_window( GTK_WIDGET(ge) );	
	gtk_container_set_border_width( GTK_CONTAINER (ge), 5 );
	
	main_vbox = GTK_DIALOG(ge)->vbox ; 

	main_hbox = gtk_hbox_new (FALSE, 5);
  	gtk_widget_show (main_hbox);
	gtk_box_pack_start (GTK_BOX (main_vbox), main_hbox, TRUE, TRUE, 0);
	
	list_vbox = gtk_vbox_new (FALSE, 0);
	gtk_box_pack_start (GTK_BOX (main_hbox), list_vbox, FALSE, FALSE, 0);

	frame = gtk_frame_new("Gradient direction : ");
	gtk_box_pack_start (GTK_BOX (list_vbox), frame, FALSE, FALSE, 5);
	
	table = gtk_table_new( 2, 2, FALSE );
	gtk_container_add (GTK_CONTAINER (frame), table);
	gtk_container_set_border_width (GTK_CONTAINER (table), 3);

	ge->l2r_radio = gtk_radio_button_new_with_label( NULL, "Left to Right" );
	gtk_table_attach_defaults (GTK_TABLE (table), ge->l2r_radio, 0, 1, 0, 1);
	ge->t2b_radio = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(ge->l2r_radio), "Top to Bottom" );
	gtk_table_attach_defaults (GTK_TABLE (table), ge->t2b_radio, 0, 1, 1, 2);
	ge->tl2br_radio = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(ge->t2b_radio), "Top-Left to Bottom-Right" );
	gtk_table_attach_defaults (GTK_TABLE (table), ge->tl2br_radio, 1, 2, 0, 1);
	ge->bl2tr_radio = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(ge->tl2br_radio), "Bottom-Left to Top-Right" );
	gtk_table_attach_defaults (GTK_TABLE (table), ge->bl2tr_radio, 1, 2, 1, 2);
	gtk_widget_show_all (table);
	gtk_widget_show (table);
	colorize_gtk_widget( frame, get_colorschemed_style_normal() );

	g_signal_connect ((gpointer) ge->l2r_radio, "clicked", G_CALLBACK (on_direction_clicked), ge);
	g_signal_connect ((gpointer) ge->tl2br_radio, "clicked", G_CALLBACK (on_direction_clicked), ge);
	g_signal_connect ((gpointer) ge->t2b_radio, "clicked", G_CALLBACK (on_direction_clicked), ge);
	g_signal_connect ((gpointer) ge->bl2tr_radio, "clicked", G_CALLBACK (on_direction_clicked), ge);


	ge->screen_width_check = gtk_check_button_new_with_label("Use screen width");
	gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(ge->screen_width_check), TRUE );
	ge->width_entry = gtk_spin_button_new_with_range( 1, 10000, 1 );
	gtk_widget_set_sensitive( ge->width_entry, FALSE );
	ge->screen_height_check = gtk_check_button_new_with_label("Use screen height");
	gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(ge->screen_height_check), TRUE );
	ge->height_entry = gtk_spin_button_new_with_range( 1, 10000, 1 );
	gtk_widget_set_sensitive( ge->height_entry, FALSE );

   	g_signal_connect ((gpointer) ge->screen_width_check, "clicked", G_CALLBACK (on_size_clicked), ge);
	g_signal_connect ((gpointer) ge->screen_height_check, "clicked", G_CALLBACK (on_size_clicked), ge);


	ge->size_frame = gtk_frame_new("Rendered gradient size : ");
	gtk_box_pack_start (GTK_BOX (list_vbox), ge->size_frame, FALSE, FALSE, 5);
	colorize_gtk_tree_view_window( GTK_WIDGET(ge->size_frame) );

	table = gtk_table_new( 2, 4, FALSE );
	gtk_container_set_border_width( GTK_CONTAINER (table), 3 );
	gtk_container_add( GTK_CONTAINER(ge->size_frame), table );

	gtk_table_attach_defaults (GTK_TABLE (table), gtk_label_new("Width : "), 0, 1, 0, 1);   
	gtk_table_attach_defaults (GTK_TABLE (table), ge->width_entry, 1, 2, 0, 1);   
	gtk_table_attach_defaults (GTK_TABLE (table), gtk_label_new("Height : "), 2, 3, 0, 1);   
	gtk_table_attach_defaults (GTK_TABLE (table), ge->height_entry, 3, 4, 0, 1);  
	gtk_table_attach (GTK_TABLE (table), ge->screen_width_check, 0, 2, 1, 2, GTK_FILL, GTK_FILL, 10, 0);    
	gtk_table_attach (GTK_TABLE (table), ge->screen_height_check, 2, 4, 1, 2, GTK_FILL, GTK_FILL, 10, 0);    
	
	gtk_widget_show_all (table);
	gtk_widget_show (table);
	colorize_gtk_widget( ge->size_frame, get_colorschemed_style_normal() );

	scrolled_window = asgtk_gradient_create_color_list( ge );
	gtk_box_pack_start (GTK_BOX (list_vbox), scrolled_window, FALSE, FALSE, 0);
	
	ge->color_entry = gtk_entry_new_with_max_length(24);
	gtk_entry_set_width_chars( GTK_ENTRY(ge->color_entry), 16 );
#if 0
	ge->color_preview = gtk_color_button_new();
	g_signal_connect ((gpointer) ge->color_preview, "clicked", G_CALLBACK (on_color_preview_clicked), ge);
#else
	ge->color_preview = gtk_image_new();
	update_color_preview( ge, DEFAULT_COLOR_STR );
#endif

	ge->offset_entry = gtk_spin_button_new_with_range( 0., 1., 0.05 );


	frame = gtk_frame_new("Change point attributes : ");
	gtk_box_pack_end (GTK_BOX (list_vbox), frame, FALSE, FALSE, 5);
	colorize_gtk_tree_view_window( GTK_WIDGET(frame) );

	vbox = gtk_vbox_new( FALSE, 5 );			   
	gtk_container_add( GTK_CONTAINER(frame), vbox );
	
	table = gtk_table_new( 4, 2, FALSE );
	gtk_container_set_border_width( GTK_CONTAINER (table), 3 );


//	hbox = gtk_hbox_new( FALSE, 5 );			   
//	gtk_container_set_border_width( GTK_CONTAINER (hbox), 3 );
	gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
	label = gtk_label_new("Color : ");
	gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
    gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 0, 1);   	
	label = gtk_label_new("Offset : ");
	gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
	gtk_table_attach_defaults (GTK_TABLE (table), label, 2, 3, 0, 1);   	   
	gtk_table_attach (GTK_TABLE (table), ge->color_entry, 1, 2, 0, 1, GTK_SHRINK, GTK_SHRINK, 2, 2);   	   
	gtk_table_attach (GTK_TABLE (table), ge->offset_entry, 3, 4, 0, 1, GTK_SHRINK, GTK_SHRINK, 2, 2);

	frame = gtk_frame_new(NULL);
	colorize_gtk_tree_view_window( GTK_WIDGET(frame) );
	gtk_widget_set_size_request( frame, COLOR_PREVIEW_WIDTH, COLOR_PREVIEW_HEIGHT );
	gtk_container_set_border_width( GTK_CONTAINER (table), 0 );
	gtk_container_add( GTK_CONTAINER(frame), ge->color_preview );
	gtk_widget_show( ge->color_preview );
	
	btn = gtk_button_new();
	gtk_container_set_border_width( GTK_CONTAINER (btn), 0 );
	//btn = gtk_button_new_with_label(" Color selector ");
	colorize_gtk_widget( GTK_WIDGET(btn), get_colorschemed_style_button());
	gtk_container_add (GTK_CONTAINER (btn), frame);
	gtk_widget_show (frame);
	g_signal_connect ((gpointer) frame, "size-allocate",
                       G_CALLBACK (color_preview_size_alloc), ge);

	gtk_table_attach (GTK_TABLE (table), btn, 0, 2, 1, 2, GTK_FILL, GTK_SHRINK, 2, 2);
	g_signal_connect ((gpointer) btn, "clicked", G_CALLBACK (on_color_clicked), ge);	
	
	gtk_widget_show_all (table);
	gtk_widget_show (table);

	hbox = gtk_hbox_new( FALSE, 5 );			   
	gtk_container_set_border_width( GTK_CONTAINER (hbox), 3 );
	gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
	
	ge->delete_btn = btn = gtk_button_new_from_stock(GTK_STOCK_DELETE);
	gtk_widget_set_sensitive( ge->delete_btn, FALSE );
	colorize_gtk_widget( GTK_WIDGET(btn), get_colorschemed_style_button());
	gtk_box_pack_end (GTK_BOX (hbox), btn, FALSE, FALSE, 0);
	g_signal_connect ((gpointer) btn, "clicked", G_CALLBACK (on_delete_point_clicked), ge);	   
	
	btn = gtk_button_new_from_stock(GTK_STOCK_ADD);
	colorize_gtk_widget( GTK_WIDGET(btn), get_colorschemed_style_button());
	gtk_box_pack_end (GTK_BOX (hbox), btn, FALSE, FALSE, 0);
	g_signal_connect ((gpointer) btn, "clicked", G_CALLBACK (on_add_point_clicked), ge);	   
	
	ge->apply_btn = btn = gtk_button_new_from_stock(GTK_STOCK_APPLY);
	gtk_widget_set_sensitive( ge->apply_btn, FALSE );
	colorize_gtk_widget( GTK_WIDGET(btn), get_colorschemed_style_button());
	gtk_box_pack_end (GTK_BOX (hbox), btn, FALSE, FALSE, 0);
	g_signal_connect ((gpointer) btn, "clicked", G_CALLBACK (on_apply_point_clicked), ge);	   

	gtk_widget_show_all (hbox);
	gtk_widget_show (hbox);

	/* The preview : */
	ge->image_view = ASGTK_IMAGE_VIEW(asgtk_image_view_new());
	gtk_widget_set_size_request (GTK_WIDGET(ge->image_view), PREVIEW_WIDTH, PREVIEW_HEIGHT);
	gtk_box_pack_end (GTK_BOX (main_hbox), GTK_WIDGET(ge->image_view), TRUE, TRUE, 0);
	asgtk_image_view_set_aspect ( ge->image_view,
							   	  get_screen_width(NULL), get_screen_height(NULL) );
	asgtk_image_view_set_resize ( ge->image_view, 
								  ASGTK_IMAGE_VIEW_SCALE_TO_VIEW|
							 	  ASGTK_IMAGE_VIEW_TILE_TO_ASPECT, 
								  ASGTK_IMAGE_VIEW_RESIZE_ALL );



  	gtk_widget_show_all (list_vbox);
  	gtk_widget_show_all (main_hbox);
	gtk_widget_hide(ge->image_view->details_label);
	
	btn = gtk_check_button_new_with_label( "Use screen aspect ratio" );
	gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(btn), TRUE );
	gtk_widget_show (btn);
	colorize_gtk_widget( btn, get_colorschemed_style_normal() );  
	g_signal_connect (G_OBJECT (btn), "toggled",
	              	  G_CALLBACK (asgtk_image_view_screen_aspect_toggle), (gpointer) ge->image_view);
	gtk_button_set_alignment( GTK_BUTTON(btn), 1.0, 0.5);
	asgtk_image_view_add_detail( ge->image_view, btn, 0 );

	btn = gtk_check_button_new_with_label( "Scale to fit this view" );
	gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(btn), TRUE );
	gtk_widget_show (btn);
	colorize_gtk_widget( btn, get_colorschemed_style_normal() );  
	g_signal_connect (G_OBJECT (btn), "toggled",
	              	  G_CALLBACK (asgtk_image_view_scale_to_view_toggle), (gpointer) ge->image_view);
	gtk_button_set_alignment( GTK_BUTTON(btn), 1.0, 0.5);
	asgtk_image_view_add_detail( ge->image_view, btn, 0 );

	btn = asgtk_add_button_to_box( NULL, GTK_STOCK_REFRESH, NULL, G_CALLBACK(on_refresh_clicked), ge );
	asgtk_image_view_add_tool( ge->image_view, btn, 3 );


	LOCAL_DEBUG_OUT( "created image ASGtkGradient object %p", ge );	
	return GTK_WIDGET (ge);
}
Exemplo n.º 26
0
gint run_dialog_search(GtkWidget *textview, gint mode)
{
	GtkWidget *dialog;
	GtkWidget *table;
	GtkWidget *label_find, *label_replace;
	GtkWidget *entry_find, *entry_replace = NULL;
	GtkWidget *check_case, *check_all;
	gint res;
	
	if (mode)
		dialog = gtk_dialog_new_with_buttons(_("Replace"),
			GTK_WINDOW(gtk_widget_get_toplevel(textview)),
			GTK_DIALOG_DESTROY_WITH_PARENT,
			GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
			GTK_STOCK_FIND_AND_REPLACE, GTK_RESPONSE_OK,
			NULL);
	else
		dialog = gtk_dialog_new_with_buttons(_("Find"),
			GTK_WINDOW(gtk_widget_get_toplevel(textview)),
			GTK_DIALOG_DESTROY_WITH_PARENT,
			GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
			GTK_STOCK_FIND, GTK_RESPONSE_OK,
			NULL);
	gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
	
	table = gtk_table_new(mode + 2, 2, FALSE);
	 gtk_table_set_row_spacings(GTK_TABLE(table), 8);
	 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
	 gtk_container_set_border_width(GTK_CONTAINER(table), 8);
	 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), table, FALSE, FALSE, 0);
	label_find = gtk_label_new_with_mnemonic(_("Fi_nd what:"));
	 gtk_misc_set_alignment(GTK_MISC(label_find), 0, 0.5);
	 gtk_table_attach_defaults(GTK_TABLE(table), label_find, 0, 1, 0, 1);
	entry_find = gtk_entry_new();
	 gtk_table_attach_defaults(GTK_TABLE(table), entry_find, 1, 2, 0, 1);
	 gtk_label_set_mnemonic_widget(GTK_LABEL(label_find), entry_find);
	 gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog),
		GTK_RESPONSE_OK, FALSE);
	 entry_len = 0;
	 g_signal_connect(G_OBJECT(entry_find), "insert-text",
		G_CALLBACK(toggle_sensitivity), NULL);
	 g_signal_connect(G_OBJECT(entry_find), "delete-text",
		G_CALLBACK(toggle_sensitivity), NULL);
	 if (string_find) {
		 gtk_entry_set_text(GTK_ENTRY(entry_find), string_find);
		 gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog),
			GTK_RESPONSE_OK, TRUE);
	 }
	if (mode) {
		label_replace = gtk_label_new_with_mnemonic(_("Re_place with:"));
		 gtk_misc_set_alignment(GTK_MISC(label_replace), 0, 0.5);
		 gtk_table_attach_defaults(GTK_TABLE(table), label_replace, 0, 1, 1, 2);
		entry_replace = gtk_entry_new();
		 gtk_table_attach_defaults(GTK_TABLE(table), entry_replace, 1, 2, 1, 2);
		 gtk_label_set_mnemonic_widget(GTK_LABEL(label_replace), entry_replace);
		 if (string_replace)
			 gtk_entry_set_text(GTK_ENTRY(entry_replace), string_replace);
	}
	gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
	gtk_entry_set_activates_default(GTK_ENTRY(entry_find), TRUE);
	if (mode)
		gtk_entry_set_activates_default(GTK_ENTRY(entry_replace), TRUE);
	
	check_case = gtk_check_button_new_with_mnemonic(_("_Match case"));
	 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_case), match_case);
	 g_signal_connect(GTK_OBJECT(check_case), "toggled", G_CALLBACK(toggle_check_case), NULL);
	 gtk_table_attach_defaults (GTK_TABLE(table), check_case, 0, 2, 1 + mode, 2 + mode);
	if (mode) {
	check_all = gtk_check_button_new_with_mnemonic(_("Replace _all at once"));
	 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_all), replace_all);
	 g_signal_connect(GTK_OBJECT(check_all), "toggled", G_CALLBACK(toggle_check_all), NULL);
	 gtk_table_attach_defaults(GTK_TABLE(table), check_all, 0, 2, 2 + mode, 3 + mode);
	}
	gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
	gtk_widget_show_all(table);	
	
	res = gtk_dialog_run(GTK_DIALOG(dialog));
	if (res == GTK_RESPONSE_OK) {
		g_free(string_find);
		string_find = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry_find)));
		if (mode) {
			g_free(string_replace);
			string_replace = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry_replace)));
		}
	}
	
	gtk_widget_destroy(dialog);
	
	if (res == GTK_RESPONSE_OK) {
		if (strlen(string_find)) {
			if (mode)
				document_replace_real(textview);
			else
				document_search_real(textview, 0);
		}
	}
	
	return res;
}
Exemplo n.º 27
0
int main(int argc, char *argv[])
{
    int has_rc=0;

    GtkWidget *mainWin;
    GtkWidget *table;
    GtkWidget *menu_bar;
    GtkWidget *index_page;
    GtkWidget *button;
    GtkWidget *label, *box, *sbox, *pbox;
    GtkWidget *vseparator;
    GtkWidget *post_process_button;
    GtkStyle *style;

    GtkWidget *gpixmap;
    GdkPixmap *pixmap;
    GdkBitmap *bitmap;
    char title[256];
    char *envhome;

#ifdef ENABLE_NLS
    bindtextdomain (PACKAGE, PACKAGE_LOCALE_DIR);
    textdomain (PACKAGE);
#endif

    signal(SIGSEGV, crash);

#ifdef sun
    __progname = argv[0];
#endif

    Thumbnails.next = NULL;
    Images.next=NULL;

    /* Set the priority (taken from PhotoPC photopc.c) */
#ifdef linux
    if (geteuid() == 0) {
        struct sched_param sp;
        int rc,minp,maxp;

        minp=sched_get_priority_min(SCHED_FIFO);
        maxp=sched_get_priority_max(SCHED_FIFO);
        sp.sched_priority=minp+(maxp-minp)/2;
        if ((rc=sched_setscheduler(0,SCHED_FIFO,&sp)) == -1)
            fprintf(stderr,"failed to set priority\n");
    }
#endif

    filesel_cwd = (char *)malloc(sizeof(char)*1024);
    getcwd(filesel_cwd, 1024);
    strcat(filesel_cwd, "/");

    /* Make sure there's a .gphoto directory in their home ---- */

    envhome = getenv("HOME");
    gphotoDir = (char *)malloc(sizeof(char)*(strlen(envhome)+9));
    memset(gphotoDir, 0, sizeof(char)*(strlen(envhome)+9));
    sprintf(gphotoDir, "%s/.gphoto", envhome);
    (void)mkdir(gphotoDir, 0744);

    /* Command line mode anyone? ----------------------------- */
    if (argc > 1) {
        command_line_mode = 1;
        has_rc = load_config();
        command_line(argc, argv);
    } else
        command_line_mode = 0;


    /* Check for DISPLAY. If not set, exit */
    if (!getenv("DISPLAY")) {
        printf(N_("Error: $DISPLAY variable is not set\n"));
        printf(N_("Please run \"gphoto -h\" for command-line options.\n"));
        _exit(0);
    }

    fprintf(stdout,
            N_("gPhoto %s (%s)\n"),
            VERSION, __DATE__);
    fprintf(stdout,
            N_("Copyright (C) 1998-2000 Scott Fritzinger <[email protected]>\n\n"));
    fprintf(stdout,
            N_("Usage: gphoto [-h] [-c] [-n] [-s # filename] [-t # filename]\n"));
    fprintf(stdout, N_("              [-d #] [-p filename] [-l filename]\n"));

    gtk_init(&argc, &argv);
#if 1 /* by fujisawa */
    gdk_imlib_init();
#endif
    gtk_widget_push_visual(gdk_imlib_get_visual());
    gtk_widget_push_colormap(gdk_imlib_get_colormap());

    library_name = gtk_label_new("");

    has_rc = load_config();

    /* set up the main window -------------------------------- */
    mainWin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_container_border_width(GTK_CONTAINER(mainWin), 0);
    sprintf(title, "gPhoto %s", VERSION);
    gtk_window_set_title(GTK_WINDOW(mainWin), title);
    gtk_signal_connect(GTK_OBJECT(mainWin), "delete_event",
                       GTK_SIGNAL_FUNC(delete_event), NULL);
    gtk_widget_set_usize(mainWin, 730, 480);
    gtk_widget_realize(mainWin);

    /* set up the menu --------------------------------------- */
    menu_bar = gtk_vbox_new(FALSE, 0);
    create_menu(menu_bar);
    gtk_widget_show_all(menu_bar);

    /* button bar -------------------------------------------- */
    box = gtk_hbox_new(FALSE, 0);
    create_toolbar(box, mainWin);
    gtk_widget_show(box);
    gtk_container_border_width(GTK_CONTAINER(box), 5);

    /* accelerator keys--------------------------------------- */
    gtk_accel_group_attach(mainag,GTK_OBJECT(mainWin));

    /* Index Page notebook ----------------------------------- */
    index_page = gtk_table_new(1,1,FALSE);
    gtk_widget_show(index_page);
    index_window = gtk_scrolled_window_new(NULL,NULL);
    index_vp=gtk_viewport_new(NULL,NULL);
    gtk_container_add(GTK_CONTAINER(index_window), index_vp);
    gtk_widget_show(index_vp);
    gtk_widget_show(index_window);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(index_window),
                                   GTK_POLICY_AUTOMATIC,
                                   GTK_POLICY_AUTOMATIC);
    gtk_table_attach_defaults(GTK_TABLE(index_page),index_window,0,1,0,1);

    notebook = gtk_notebook_new();
    gtk_widget_show(notebook);
    gtk_notebook_set_scrollable(GTK_NOTEBOOK(notebook), TRUE);

    label = gtk_label_new(N_("Image Index"));
    gtk_notebook_append_page(GTK_NOTEBOOK(notebook), index_page,
                             label);

    sbox = gtk_hbox_new(FALSE, 5);
    gtk_widget_show(sbox);

    status_bar = gtk_label_new("");
    gtk_widget_show(status_bar);
    gtk_label_set_justify(GTK_LABEL(status_bar), GTK_JUSTIFY_LEFT);
    gtk_box_pack_start(GTK_BOX(sbox), status_bar, FALSE, FALSE, 0);
    update_status("Select \"Camera->Download Index->Thumbnails\" to begin.");
    progress = gtk_progress_bar_new();

    gtk_widget_show(progress);
    gtk_box_pack_end(GTK_BOX(sbox), progress, FALSE, FALSE, 0);

    vseparator = gtk_vseparator_new();
    gtk_widget_show(vseparator);
    gtk_box_pack_end(GTK_BOX(sbox), vseparator, FALSE, FALSE, 0);

    post_process = 0;
    post_process_button = gtk_button_new();
    gtk_widget_show(post_process_button);
    gtk_button_set_relief(GTK_BUTTON(post_process_button),GTK_RELIEF_NONE);
    gtk_signal_connect (GTK_OBJECT(post_process_button), "clicked",
                        GTK_SIGNAL_FUNC(post_process_change), mainWin);
    gtk_box_pack_end(GTK_BOX(sbox), post_process_button, FALSE, FALSE, 0);

    pbox = gtk_hbox_new(FALSE, 3);
    gtk_widget_show(pbox);
    gtk_container_add(GTK_CONTAINER(post_process_button), pbox);

    style = gtk_widget_get_style(mainWin);
    pixmap = gdk_pixmap_create_from_xpm_d(mainWin->window, &bitmap,
                                          &style->bg[GTK_STATE_NORMAL],(gchar **)post_processing_off_xpm);
    post_process_pixmap = gtk_pixmap_new(pixmap, bitmap);
    gtk_widget_show(post_process_pixmap);
    gtk_box_pack_start(GTK_BOX(pbox),post_process_pixmap,FALSE,FALSE,0);

    label = gtk_label_new("Post Process");
    gtk_widget_show(label);
    gtk_box_pack_start(GTK_BOX(pbox),label,FALSE,FALSE,0);

    vseparator = gtk_vseparator_new();
    gtk_widget_show(vseparator);
    gtk_box_pack_end(GTK_BOX(sbox), vseparator, FALSE, FALSE, 0);

    gtk_widget_show(library_name);
    /*	gtk_widget_set_usize(library_name, 200, 16);*/
    gtk_label_set_justify(GTK_LABEL(library_name), GTK_JUSTIFY_LEFT);
    button = gtk_button_new();
    gtk_widget_show(button);
    gtk_button_set_relief(GTK_BUTTON(button),GTK_RELIEF_NONE);
    gtk_signal_connect_object(GTK_OBJECT(button), "clicked",
                              GTK_SIGNAL_FUNC(port_dialog), NULL);
    gtk_container_add(GTK_CONTAINER(button), library_name);
    gtk_box_pack_end(GTK_BOX(sbox), button, FALSE, FALSE, 0);

    pixmap = gdk_pixmap_create_from_xpm_d(mainWin->window, &bitmap,
                                          &style->bg[GTK_STATE_NORMAL],
                                          (gchar **)splash_xpm);
    gpixmap = gtk_pixmap_new(pixmap, bitmap);
    gtk_widget_show(gpixmap);

    /* Main window layout ------------------------------------ */
    table =gtk_table_new(4,1,FALSE);
    gtk_container_add(GTK_CONTAINER(mainWin), table);
    gtk_widget_show(table);
    gtk_table_attach(GTK_TABLE(table),menu_bar, 0, 1, 0, 1,
                     GTK_FILL|GTK_EXPAND, GTK_FILL, 0 , 0);
    gtk_table_attach(GTK_TABLE(table), box, 0, 1, 1, 2,
                     GTK_FILL|GTK_EXPAND, GTK_FILL, 0, 0);
    gtk_table_attach_defaults(GTK_TABLE(table),notebook, 0, 1, 2, 3);
    gtk_table_attach(GTK_TABLE(table),sbox, 0, 1, 3, 4,
                     GTK_FILL|GTK_EXPAND, GTK_FILL, 0 , 0);

    index_table = gtk_hbox_new(FALSE, 0);
    gtk_widget_show(index_table);
    gtk_container_add( GTK_CONTAINER(index_vp), index_table);

    gtk_box_pack_start(GTK_BOX(index_table), gpixmap, TRUE, FALSE, 0);

    /* If not command-line mode... --------------------------- */
    gtk_widget_show(mainWin);
    if (!has_rc) {
        /* put anything here to do on the first run */
        developer_dialog_create();
        error_dialog(
            "Could not load config file.\n"
            "Resetting to defaults.\n"
            "Click on \"Select Port-Camera Model\n"
            "in the Configure menu to set your\n"
            "camera model and serial port\n");
    }
    gtk_main();
    return 0;
}
Exemplo n.º 28
0
/* Create the fingerprint UI, and pack it into the vbox */
static void make_fingerprints_ui(GtkWidget *vbox)
{
    GtkWidget *hbox;
    GtkWidget *table;
    GtkWidget *label;
    char *titles[5];

    titles[0] = _("Screenname");
    titles[1] = _("Status");
    titles[2] = _("Verified");
    titles[3] = _("Fingerprint");
    titles[4] = _("Account");

    ui_layout.scrollwin = gtk_scrolled_window_new(0, 0);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(ui_layout.scrollwin),
	    GTK_POLICY_ALWAYS, GTK_POLICY_ALWAYS);

    ui_layout.keylist = gtk_clist_new_with_titles(5, titles);
    gtk_clist_set_column_width(GTK_CLIST(ui_layout.keylist), 0, 90);
    gtk_clist_set_column_width(GTK_CLIST(ui_layout.keylist), 1, 90);
    gtk_clist_set_column_width(GTK_CLIST(ui_layout.keylist), 2, 60);
    gtk_clist_set_column_width(GTK_CLIST(ui_layout.keylist), 3, 400);
    gtk_clist_set_column_width(GTK_CLIST(ui_layout.keylist), 4, 200);
    gtk_clist_set_selection_mode(GTK_CLIST(ui_layout.keylist),
	    GTK_SELECTION_SINGLE);
    gtk_clist_column_titles_active(GTK_CLIST(ui_layout.keylist));

    gtk_container_add(GTK_CONTAINER(ui_layout.scrollwin), ui_layout.keylist);
    gtk_box_pack_start(GTK_BOX(vbox), ui_layout.scrollwin,
	    TRUE, TRUE, 0);

    otrg_gtk_ui_update_keylist();

    hbox = gtk_hbox_new(FALSE, 5);
    gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);

    table = gtk_table_new(2, 2, TRUE);
    gtk_table_set_row_spacings(GTK_TABLE(table), 5);
    gtk_table_set_col_spacings(GTK_TABLE(table), 20);

    gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new(""), TRUE, TRUE, 0);
    gtk_box_pack_start(GTK_BOX(hbox), table, FALSE, FALSE, 0);
    gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new(""), TRUE, TRUE, 0);

    ui_layout.connect_button = gtk_button_new();
    gtk_signal_connect(GTK_OBJECT(ui_layout.connect_button), "clicked",
	    GTK_SIGNAL_FUNC(connect_connection), NULL);
    label = gtk_label_new(_("Start private connection"));
    gtk_container_add(GTK_CONTAINER(ui_layout.connect_button), label);
    gtk_table_attach_defaults(GTK_TABLE(table), ui_layout.connect_button,
	    0, 1, 0, 1);

    ui_layout.disconnect_button = gtk_button_new();
    gtk_signal_connect(GTK_OBJECT(ui_layout.disconnect_button), "clicked",
	    GTK_SIGNAL_FUNC(disconnect_connection), NULL);
    label = gtk_label_new(_("End private connection"));
    gtk_container_add(GTK_CONTAINER(ui_layout.disconnect_button), label);
    gtk_table_attach_defaults(GTK_TABLE(table), ui_layout.disconnect_button,
	    0, 1, 1, 2);

    ui_layout.verify_button = gtk_button_new();
    gtk_signal_connect(GTK_OBJECT(ui_layout.verify_button), "clicked",
	    GTK_SIGNAL_FUNC(verify_fingerprint), NULL);
    label = gtk_label_new(_("Verify fingerprint"));
    gtk_container_add(GTK_CONTAINER(ui_layout.verify_button), label);
    gtk_table_attach_defaults(GTK_TABLE(table), ui_layout.verify_button,
	    1, 2, 0, 1);

    ui_layout.forget_button = gtk_button_new();
    gtk_signal_connect(GTK_OBJECT(ui_layout.forget_button), "clicked",
	    GTK_SIGNAL_FUNC(forget_fingerprint), NULL);
    label = gtk_label_new(_("Forget fingerprint"));
    gtk_container_add(GTK_CONTAINER(ui_layout.forget_button), label);
    gtk_table_attach_defaults(GTK_TABLE(table), ui_layout.forget_button,
	    1, 2, 1, 2);

    gtk_signal_connect(GTK_OBJECT(vbox), "destroy",
	    GTK_SIGNAL_FUNC(ui_destroyed), NULL);

    /* Handle selections and deselections */
    gtk_signal_connect(GTK_OBJECT(ui_layout.keylist), "select_row",
	    GTK_SIGNAL_FUNC(clist_selected), NULL);
    gtk_signal_connect(GTK_OBJECT(ui_layout.keylist), "unselect_row",
	    GTK_SIGNAL_FUNC(clist_unselected), NULL);

    /* Handle column sorting */
    gtk_signal_connect(GTK_OBJECT(ui_layout.keylist), "click-column",
	    GTK_SIGNAL_FUNC(clist_click_column), NULL);
    ui_layout.sortcol = 0;
    ui_layout.sortdir = 1;

    clist_all_unselected();
}
Exemplo n.º 29
0
int main(int argc, char *argv[])
{
    if(argc > 1)
    {
        if(strequ(argv[1], "--version"))
        {
            printf("Boggle Solver version 2.0\nBuild number %X\n", BUILDNUMBER);
            return 0;
        }
    }

    gdk_threads_init();

    // Load dictionary
    pthread_t dictThread;
    pthread_create(&dictThread, NULL, load_dict_threaded, NULL);
    pthread_detach(dictThread);

    GtkWidget *textbox_table, *solve_b, *clear_b, *list_scroll;

    gtk_init(&argc, &argv); //140

    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
    gtk_container_set_border_width(GTK_CONTAINER(window), 10);
    gtk_widget_set_size_request(window, 653, 485);
    gtk_window_set_title(GTK_WINDOW(window), "Boggle Solver");

    gtk_signal_connect(GTK_OBJECT(window), "delete_event", GTK_SIGNAL_FUNC(delete_event), NULL);

    textbox_table = gtk_table_new(6, 5, FALSE);
    list = gtk_tree_view_new();

    list_scroll = gtk_scrolled_window_new(NULL, NULL);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(list_scroll), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);

    gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list), FALSE);
    gtk_widget_set_size_request(list_scroll, 190, -1);
    gtk_container_add(GTK_CONTAINER(list_scroll), list);
    gtk_table_attach_defaults(GTK_TABLE(textbox_table), list_scroll, 4, 5, 0, 5);
    gtk_table_set_col_spacings(GTK_TABLE(textbox_table), 10);
    gtk_table_set_row_spacings(GTK_TABLE(textbox_table), 10);

    solve_b = gtk_button_new_with_label("Solve");
    clear_b = gtk_button_new_with_label("Clear");

    gtk_widget_set_size_request(solve_b, 100, 27);
    gtk_widget_set_size_request(clear_b, 100, 27);

    gtk_table_attach_defaults(GTK_TABLE(textbox_table), solve_b, 0, 1, 4, 5);
    gtk_table_attach_defaults(GTK_TABLE(textbox_table), clear_b, 3, 4, 4, 5);

    gtk_signal_connect(GTK_OBJECT(solve_b), "clicked", GTK_SIGNAL_FUNC(solve_clicked), NULL);
    gtk_signal_connect(GTK_OBJECT(clear_b), "clicked", GTK_SIGNAL_FUNC(clear_clicked), NULL);

    int x, y;
    for(x = 0; x < 4; x++)
    {
        for(y = 0; y < 4; y++)
        {
            textboxes[x][y] = gtk_entry_new();
            GtkWidget *tb = textboxes[x][y];
            int *idx = malloc(sizeof(int));
            *idx = y * 4 + x;
            gtk_entry_set_max_length(GTK_ENTRY(tb), 1);
            gtk_table_attach_defaults(GTK_TABLE(textbox_table), tb, x, x + 1, y, y + 1);
            gtk_entry_set_width_chars(GTK_ENTRY(tb), 5);
            gtk_entry_set_alignment(GTK_ENTRY(tb), 0.5);
            gtk_widget_set_size_request(tb, 100, 100);
            gtk_widget_modify_font(tb, pango_font_description_from_string("Ubuntu 55"));
            gtk_signal_connect(GTK_OBJECT(tb), "backspace", GTK_SIGNAL_FUNC(backspace_pressed), NULL);
            gtk_signal_connect(GTK_OBJECT(tb), "key-press-event", GTK_SIGNAL_FUNC(key_pressed), NULL);
            gtk_signal_connect(GTK_OBJECT(tb), "button-press-event", GTK_SIGNAL_FUNC(tb_focus), idx);
        }
    }

    gtk_container_add(GTK_CONTAINER(window), textbox_table);

    init_list(list);

    gtk_widget_show_all(window);

    gtk_main();

    dict_clean_up();

    gdk_threads_leave();

    return 0;
}
Exemplo n.º 30
0
/*
 * display the statistics windows
 */
void gtkui_show_stats(void)
{
   GtkWidget *table, *label;

   DEBUG_MSG("gtkui_show_stats");

   /* if the object already exist, set the focus to it */
   if (stats_window) {
      /* show stats window */
      if(GTK_IS_WINDOW (stats_window))
         gtk_window_present(GTK_WINDOW (stats_window));
      else
         gtkui_page_present(stats_window);
      return;
   }
   
   stats_window = gtkui_page_new("Statistics", &gtkui_stop_stats, &gtkui_stats_detach);

   /* alright, this is a lot of code but it'll keep everything lined up nicely */
   /* if you need to add a row, don't forget to increase the number in gtk_table_new */
   table = gtk_table_new(12, 2, FALSE); /* rows, cols, size */
   gtk_table_set_col_spacings(GTK_TABLE (table), 10);
   gtk_container_add(GTK_CONTAINER (stats_window), table);

   packets_recv = gtk_label_new("      ");
   gtk_label_set_selectable(GTK_LABEL (packets_recv), TRUE);
   gtk_misc_set_alignment(GTK_MISC (packets_recv), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), packets_recv, 1, 2, 0, 1);
   label        = gtk_label_new( "Received packets:");
   gtk_label_set_selectable(GTK_LABEL (label), TRUE);
   gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1);

   packets_drop = gtk_label_new("      ");
   gtk_label_set_selectable(GTK_LABEL (packets_drop), TRUE);
   gtk_misc_set_alignment(GTK_MISC (packets_drop), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), packets_drop, 1, 2, 1, 2);
   label        = gtk_label_new("Dropped packets:");
   gtk_label_set_selectable(GTK_LABEL (label), TRUE);
   gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2);

   packets_forw = gtk_label_new("       0  bytes:        0 ");
   gtk_label_set_selectable(GTK_LABEL (packets_forw), TRUE);
   gtk_misc_set_alignment(GTK_MISC (packets_forw), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), packets_forw, 1, 2, 2, 3);
   label        = gtk_label_new("Forwarded packets:");
   gtk_label_set_selectable(GTK_LABEL (label), TRUE);
   gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 2, 3);

   queue_len    = gtk_label_new("0/0 ");
   gtk_label_set_selectable(GTK_LABEL (queue_len), TRUE);
   gtk_misc_set_alignment(GTK_MISC (queue_len), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), queue_len, 1, 2, 3, 4);
   label        = gtk_label_new("Current queue length:");
   gtk_label_set_selectable(GTK_LABEL (label), TRUE);
   gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 3, 4);

   sample_rate  = gtk_label_new("0     ");
   gtk_label_set_selectable(GTK_LABEL (sample_rate), TRUE);
   gtk_misc_set_alignment(GTK_MISC (sample_rate), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), sample_rate, 1, 2, 4, 5);
   label        = gtk_label_new("Sampling rate:");
   gtk_label_set_selectable(GTK_LABEL (label), TRUE);
   gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 4, 5);

   recv_bottom  = gtk_label_new("pck:        0  bytes:        0");
   gtk_label_set_selectable(GTK_LABEL (recv_bottom), TRUE);
   gtk_misc_set_alignment(GTK_MISC (recv_bottom), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), recv_bottom, 1, 2, 5, 6);
   label        = gtk_label_new("Bottom Half received packet:");
   gtk_label_set_selectable(GTK_LABEL (label), TRUE);
   gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 5, 6);

   recv_top     = gtk_label_new("pck:        0  bytes:        0");
   gtk_label_set_selectable(GTK_LABEL (recv_top), TRUE);
   gtk_misc_set_alignment(GTK_MISC (recv_top), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), recv_top, 1, 2, 6, 7);
   label        = gtk_label_new("Top Half received packet:");
   gtk_label_set_selectable(GTK_LABEL (label), TRUE);
   gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 6, 7);

   interesting  = gtk_label_new("0.00 %");
   gtk_label_set_selectable(GTK_LABEL (interesting), TRUE);
   gtk_misc_set_alignment(GTK_MISC (interesting), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), interesting, 1, 2, 7, 8);
   label        = gtk_label_new("Interesting packets:");
   gtk_label_set_selectable(GTK_LABEL (label), TRUE);
   gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 7, 8);

   rate_bottom  = gtk_label_new("worst:        0  adv:        0 b/s");
   gtk_label_set_selectable(GTK_LABEL (rate_bottom), TRUE);
   gtk_misc_set_alignment(GTK_MISC (rate_bottom), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), rate_bottom, 1, 2, 8, 9);
   label        = gtk_label_new("Bottom Half packet rate:");
   gtk_label_set_selectable(GTK_LABEL (label), TRUE);
   gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 8, 9);

   rate_top     = gtk_label_new("worst:        0  adv:        0 b/s");
   gtk_label_set_selectable(GTK_LABEL (rate_top), TRUE);
   gtk_misc_set_alignment(GTK_MISC (rate_top), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), rate_top, 1, 2, 9, 10);
   label        = gtk_label_new("Top Half packet rate:");
   gtk_label_set_selectable(GTK_LABEL (label), TRUE);
   gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 9, 10);

   through_bottom = gtk_label_new("worst:        0  adv:        0 b/s");
   gtk_label_set_selectable(GTK_LABEL (through_bottom), TRUE);
   gtk_misc_set_alignment(GTK_MISC (through_bottom), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), through_bottom, 1, 2, 10, 11);
   label        = gtk_label_new("Bottom Half throughput:");
   gtk_label_set_selectable(GTK_LABEL (label), TRUE);
   gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 10, 11);

   through_top  = gtk_label_new("worst:        0  adv:        0 b/s");
   gtk_label_set_selectable(GTK_LABEL (through_top), TRUE);
   gtk_misc_set_alignment(GTK_MISC (through_top), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), through_top, 1, 2, 11, 12);
   label        = gtk_label_new("Top Half throughput:");
   gtk_label_set_selectable(GTK_LABEL (label), TRUE);
   gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 11, 12);

   gtk_widget_show_all(table);
   gtk_widget_show(stats_window);
  
   /* display the stats */
   refresh_stats(NULL); 

   /* refresh the stats window every 200 ms */
   /* GTK has a gtk_idle_add also but it calls too much and uses 100% cpu */
   stats_idle = gtk_timeout_add(200, refresh_stats, NULL);
}