Exemple #1
0
int main (int   argc,
	  char *argv[])
{
        gchar *defaultfile = NULL;
	GOptionContext *ctx;
	GError *err = NULL;
	GOptionEntry entries[] = {
		{ NULL }
	};
	
	GtkWidget * recent_menu = NULL;
        gchar     * size_str = NULL;

#ifdef ENABLE_NLS
	bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);
#endif

	g_set_application_name (PACKAGE);
	g_set_prgname (PACKAGE);

	tls_init ();

	g_thread_init (NULL);
	gtk_init (&argc, &argv);
	
	preferences_gui_set_csr_visible_callback (ca_update_csr_view);
	preferences_gui_set_revoked_visible_callback (ca_update_revoked_view);

        preferences_init (argc, argv);

	ctx = g_option_context_new (_("- A graphical Certification Authority manager"));
	g_option_context_add_main_entries (ctx, entries, GETTEXT_PACKAGE);
	if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
		g_print (_("Failed to initialize: %s\n"), err->message);
		g_error_free (err);
		return 1;
	}
	
	main_window_gtkb = gtk_builder_new();
	gtk_builder_add_from_file (main_window_gtkb, 
				   g_build_filename (PACKAGE_DATA_DIR, "gnomint", "main_window.ui", NULL),
				   NULL);

	csr_popup_menu_gtkb = gtk_builder_new();
	gtk_builder_add_from_file (csr_popup_menu_gtkb, 
				   g_build_filename (PACKAGE_DATA_DIR, "gnomint", "csr_popup_menu.ui", NULL),
				   NULL);

	cert_popup_menu_gtkb = gtk_builder_new();
	gtk_builder_add_from_file (cert_popup_menu_gtkb, 
				   g_build_filename (PACKAGE_DATA_DIR, "gnomint", "certificate_popup_menu.ui", NULL),
				   NULL);


        size_str = preferences_get_size ();
        if (size_str) {
                gchar ** result = NULL;
                guint width, height;

                result = g_strsplit_set (size_str, "(,)", -1);
                
                if (result[0] && result[1]) {
                        width = atoi (result[1]);
                        if (result[2]) {
                                height = atoi (result[2]);
                                gtk_window_resize (GTK_WINDOW(gtk_builder_get_object(main_window_gtkb, "main_window1")), width, height);
                        }

                }

                g_free (size_str);
                g_strfreev (result);
        }
        ca_update_revoked_view (preferences_get_revoked_visible(), FALSE);
        ca_update_csr_view (preferences_get_crq_visible(), FALSE);
        

	gtk_builder_connect_signals (main_window_gtkb, NULL);	       	
	gtk_builder_connect_signals (cert_popup_menu_gtkb, NULL);	       	
	gtk_builder_connect_signals (csr_popup_menu_gtkb, NULL);	       	

	recent_manager = gtk_recent_manager_get_default ();
	recent_menu = __recent_create_menu();
	g_signal_connect (G_OBJECT (recent_menu), "item-activated",
			  G_CALLBACK (on_open_recent_activate), NULL);
	gtk_menu_item_set_submenu (GTK_MENU_ITEM (gtk_builder_get_object (main_window_gtkb, "openrecentsmenuitem")), recent_menu);


	__disable_widget ("new_certificate1");
	__disable_widget ("save_as1");
	__disable_widget ("properties1");
	__disable_widget ("preferences1");

	dialog_establish_refresh_function (ca_refresh_model_callback);
	

	if (argc >= 2 && ca_open (g_strdup(argv[1]), TRUE)) {
                /* The file has opened OK */
		__recent_add_utf8_filename (argv[1]);
        } else {
                /* No arguments, or failure when opening file */
                defaultfile = g_build_filename (g_get_home_dir(), ".gnomint", "default.gnomint", NULL);
		__recent_add_utf8_filename (defaultfile);
                ca_open (defaultfile, TRUE);
        }

	gtk_main ();

	return 0;
}
static GtkWidget * fmcomms2adv_init(GtkWidget *notebook, const char *ini_fn)
{
	GtkWidget *fmcomms2adv_panel;

	ctx = osc_create_context();
	if (!ctx)
		return NULL;

	dev = iio_context_find_device(ctx, PHY_DEVICE);
	dev_slave = iio_context_find_device(ctx, PHY_SLAVE_DEVICE);

	if (dev_slave) {
		cf_ad9361_lpc = iio_context_find_device(ctx, CAP_DEVICE_ALT);
		cf_ad9361_hpc = iio_context_find_device(ctx, CAP_SLAVE_DEVICE);

		dev_dds_master = iio_context_find_device(ctx, DDS_DEVICE);
		dev_dds_slave = iio_context_find_device(ctx, DDS_SLAVE_DEVICE);
		if (get_dds_channels())
			return NULL;
	}

	if (ini_fn) {
		load_profile(ini_fn);
		calibrate_from_ini(ini_fn);
	}

	builder = gtk_builder_new();
	nbook = GTK_NOTEBOOK(notebook);

	if (!gtk_builder_add_from_file(builder, "fmcomms2_adv.glade", NULL))
		gtk_builder_add_from_file(builder, OSC_GLADE_FILE_PATH "fmcomms2_adv.glade", NULL);

	fmcomms2adv_panel = GTK_WIDGET(gtk_builder_get_object(builder, "fmcomms2adv_panel"));

	connect_widgets(builder);

	gtk_combo_box_set_active(GTK_COMBO_BOX(
		GTK_WIDGET(gtk_builder_get_object(builder, "bist_tone"))), 0);
	gtk_combo_box_set_active(GTK_COMBO_BOX(
		GTK_WIDGET(gtk_builder_get_object(builder, "bist_tone_frequency"))), 0);
	gtk_combo_box_set_active(GTK_COMBO_BOX(
		GTK_WIDGET(gtk_builder_get_object(builder, "tone_level"))), 0);
	gtk_combo_box_set_active(GTK_COMBO_BOX(
		GTK_WIDGET(gtk_builder_get_object(builder, "bist_prbs"))), 0);
	gtk_combo_box_set_active(GTK_COMBO_BOX(
		GTK_WIDGET(gtk_builder_get_object(builder, "loopback"))), 0);

	g_builder_connect_signal(builder, "bist_tone", "changed",
		G_CALLBACK(bist_tone_cb), builder);

	g_builder_connect_signal(builder, "bist_tone_frequency", "changed",
		G_CALLBACK(bist_tone_cb), builder);

	g_builder_connect_signal(builder, "tone_level", "changed",
		G_CALLBACK(bist_tone_cb), builder);

	g_builder_connect_signal(builder, "c2q", "toggled",
		G_CALLBACK(bist_tone_cb), builder);

	g_builder_connect_signal(builder, "c1q", "toggled",
		G_CALLBACK(bist_tone_cb), builder);

	g_builder_connect_signal(builder, "c2i", "toggled",
		G_CALLBACK(bist_tone_cb), builder);

	g_builder_connect_signal(builder, "c1i", "toggled",
		G_CALLBACK(bist_tone_cb), builder);

	if (dev_slave) {
		g_builder_connect_signal(builder, "mcs_sync", "clicked",
			G_CALLBACK(mcs_cb), builder);

		gtk_combo_box_set_active(
				GTK_COMBO_BOX(gtk_builder_get_object(builder, "calibration_switch_control")), 0);
		__cal_switch_ports_enable_cb(0);

		g_builder_connect_signal(builder, "calibration_switch_control", "changed",
			G_CALLBACK(cal_switch_ports_enable_cb), builder);

		g_builder_connect_signal(builder, "tx_phase", "value-changed",
			G_CALLBACK(tx_phase_hscale_value_changed), 0);


		g_builder_connect_signal(builder, "do_fmcomms5_cal", "clicked",
				G_CALLBACK(do_calibration), gtk_builder_get_object(builder, "do_fmcomms5_cal"));

		g_builder_connect_signal(builder, "undo_fmcomms5_cal", "clicked",
				G_CALLBACK(undo_calibration), NULL);

		g_object_bind_property(gtk_builder_get_object(builder, "silent_calibration"), "active",
		gtk_builder_get_object(builder, "progress_calibration"), "visible", G_BINDING_DEFAULT);
	} else {
		gtk_widget_hide(GTK_WIDGET(gtk_builder_get_object(builder, "mcs_sync")));
		gtk_widget_hide(GTK_WIDGET(gtk_builder_get_object(builder, "frame_fmcomms5")));
	}

	g_builder_connect_signal(builder, "notebook1", "switch-page",
		G_CALLBACK(change_page_cb),
		GTK_WIDGET(gtk_builder_get_object(builder, "initialize")));

	return fmcomms2adv_panel;
}
Exemple #3
0
int main (int argc, char *argv[])
{
	GtkBuilder *builder;
	GObject *item;
	GtkWidget *dlg;
	int maj, min, sub;

#ifdef ENABLE_NLS
    setlocale (LC_ALL, "");
    bindtextdomain ( GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR );
    bind_textdomain_codeset ( GETTEXT_PACKAGE, "UTF-8" );
    textdomain ( GETTEXT_PACKAGE );
#endif

	// check to see if lxsession will auto-refresh - version 0.4.9 or later
	read_version ("lxsession", &maj, &min, &sub);
	if (min >= 5) needs_refresh = 0;
	else if (min == 4 && sub == 9) needs_refresh = 0;
	else needs_refresh = 1;

	// load data from config files
	check_themes ();
	load_lxsession_settings ();
	load_obpix_settings ();
	load_pcman_settings ();
	load_lxpanel_settings ();
	backup_values ();

	// GTK setup
	gtk_init (&argc, &argv);
	gtk_icon_theme_prepend_search_path (gtk_icon_theme_get_default(), PACKAGE_DATA_DIR);

	// build the UI
	builder = gtk_builder_new ();
	gtk_builder_add_from_file (builder, PACKAGE_DATA_DIR "/pipanel.ui", NULL);
	dlg = (GtkWidget *) gtk_builder_get_object (builder, "dialog1");
	gtk_dialog_set_alternative_button_order (GTK_DIALOG (dlg), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1);

	font = gtk_builder_get_object (builder, "fontbutton1");
	gtk_font_button_set_font_name (GTK_FONT_BUTTON (font), desktop_font);
	g_signal_connect (font, "font-set", G_CALLBACK (on_desktop_font_set), NULL);

	dpic = gtk_builder_get_object (builder, "filechooserbutton1");
	gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (dpic), desktop_picture);
	g_signal_connect (dpic, "file-set", G_CALLBACK (on_desktop_picture_set), NULL);
	if (!strcmp (desktop_mode, "color")) gtk_widget_set_sensitive (GTK_WIDGET (dpic), FALSE);
	else gtk_widget_set_sensitive (GTK_WIDGET (dpic), TRUE);

	hcol = gtk_builder_get_object (builder, "colorbutton1");
	gtk_color_button_set_color (GTK_COLOR_BUTTON (hcol), &theme_colour);
	g_signal_connect (hcol, "color-set", G_CALLBACK (on_theme_colour_set), NULL);

	dcol = gtk_builder_get_object (builder, "colorbutton2");
	gtk_color_button_set_color (GTK_COLOR_BUTTON (dcol), &desktop_colour);
	g_signal_connect (dcol, "color-set", G_CALLBACK (on_desktop_colour_set), NULL);

	bcol = gtk_builder_get_object (builder, "colorbutton3");
	gtk_color_button_set_color (GTK_COLOR_BUTTON (bcol), &bar_colour);
	g_signal_connect (bcol, "color-set", G_CALLBACK (on_bar_colour_set), NULL);

	btcol = gtk_builder_get_object (builder, "colorbutton4");
	gtk_color_button_set_color (GTK_COLOR_BUTTON (btcol), &bartext_colour);
	g_signal_connect (btcol, "color-set", G_CALLBACK (on_bartext_colour_set), NULL);

	htcol = gtk_builder_get_object (builder, "colorbutton5");
	gtk_color_button_set_color (GTK_COLOR_BUTTON (htcol), &themetext_colour);
	g_signal_connect (htcol, "color-set", G_CALLBACK (on_themetext_colour_set), NULL);

	dtcol = gtk_builder_get_object (builder, "colorbutton6");
	gtk_color_button_set_color (GTK_COLOR_BUTTON (dtcol), &desktoptext_colour);
	g_signal_connect (dtcol, "color-set", G_CALLBACK (on_desktoptext_colour_set), NULL);

	dmod = gtk_builder_get_object (builder, "comboboxtext1");
	if (!strcmp (desktop_mode, "center")) gtk_combo_box_set_active (GTK_COMBO_BOX (dmod), 1);
	else if (!strcmp (desktop_mode, "fit")) gtk_combo_box_set_active (GTK_COMBO_BOX (dmod), 2);
	else if (!strcmp (desktop_mode, "crop")) gtk_combo_box_set_active (GTK_COMBO_BOX (dmod), 3);
	else if (!strcmp (desktop_mode, "stretch")) gtk_combo_box_set_active (GTK_COMBO_BOX (dmod), 4);
	else if (!strcmp (desktop_mode, "tile")) gtk_combo_box_set_active (GTK_COMBO_BOX (dmod), 5);
	else gtk_combo_box_set_active (GTK_COMBO_BOX (dmod), 0);
	g_signal_connect (dmod, "changed", G_CALLBACK (on_desktop_mode_set), gtk_builder_get_object (builder, "filechooserbutton1"));

	item = gtk_builder_get_object (builder, "button3");
	g_signal_connect (item, "clicked", G_CALLBACK (on_set_defaults), gtk_builder_get_object (builder, "button3"));

	rb1 = gtk_builder_get_object (builder, "radiobutton1");
	g_signal_connect (rb1, "toggled", G_CALLBACK (on_bar_pos_set), NULL);
	rb2 = gtk_builder_get_object (builder, "radiobutton2");
	g_signal_connect (rb2, "toggled", G_CALLBACK (on_bar_pos_set), NULL);
	if (barpos) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rb2), TRUE);
	else gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rb1), TRUE);

	rb3 = gtk_builder_get_object (builder, "radiobutton3");
	g_signal_connect (rb3, "toggled", G_CALLBACK (on_menu_size_set), NULL);
	rb4 = gtk_builder_get_object (builder, "radiobutton4");
	g_signal_connect (rb4, "toggled", G_CALLBACK (on_menu_size_set), NULL);
	rb5 = gtk_builder_get_object (builder, "radiobutton5");
	g_signal_connect (rb5, "toggled", G_CALLBACK (on_menu_size_set), NULL);
	if (icon_size <= 20) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rb5), TRUE);
	else if (icon_size <= 28) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rb4), TRUE);
	else gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rb3), TRUE);

	cb1 = gtk_builder_get_object (builder, "checkbutton1");
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cb1), show_docs);
	g_signal_connect (cb1, "toggled", G_CALLBACK (on_toggle_docs), NULL);
	cb2 = gtk_builder_get_object (builder, "checkbutton2");
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cb2), show_trash);
	g_signal_connect (cb2, "toggled", G_CALLBACK (on_toggle_trash), NULL);
	cb3 = gtk_builder_get_object (builder, "checkbutton3");
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cb3), show_mnts);
	g_signal_connect (cb3, "toggled", G_CALLBACK (on_toggle_mnts), NULL);

	g_object_unref (builder);

	if (gtk_dialog_run (GTK_DIALOG (dlg)) == GTK_RESPONSE_CANCEL)
	{
		if (restore_values ())
		{
			save_lxsession_settings ();
			save_pcman_settings ();
			save_obconf_settings ();
			save_obpix_settings ();
			save_gtk3_settings ();
			save_lxpanel_settings ();
			if (needs_refresh) system (RELOAD_LXSESSION);
			system (RELOAD_LXPANEL);
			system (RELOAD_OPENBOX);
			system (RELOAD_PCMANFM);
		}
	}
	else save_greeter_settings ();
	gtk_widget_destroy (dlg);

	return 0;
}
static void
subversion_commit_dialog (GtkAction* action, Subversion* plugin, 
						  gchar *filename)
{
	GtkBuilder* bxml = gtk_builder_new ();
	GtkWidget* dialog; 
	GtkWidget *logtext; 
	GtkWidget *commit_select_all_button;
	GtkWidget *commit_clear_button;
	GtkWidget *commit_status_view;
	GtkWidget *commit_status_progress_bar;
	GtkWidget *commit_prev_msg_enable;
	GtkWidget *commit_prev_msg_combo;
	GtkCellRenderer *cell;
  	GtkListStore *store;
	SvnStatusCommand *status_command;
	SubversionData* data;
	GError* error = NULL;

	if (!gtk_builder_add_from_file (bxml, GLADE_FILE, &error))
	{
		g_warning ("Couldn't load builder file: %s", error->message);
		g_error_free (error);
	}
	
	dialog = GTK_WIDGET (gtk_builder_get_object (bxml, "subversion_commit"));
	commit_select_all_button = GTK_WIDGET (gtk_builder_get_object (bxml, 
													 "commit_select_all_button"));
	commit_clear_button = GTK_WIDGET (gtk_builder_get_object (bxml,
												"commit_clear_button"));
	commit_status_view = GTK_WIDGET (gtk_builder_get_object (bxml, "commit_status_view"));
	commit_status_progress_bar = GTK_WIDGET (gtk_builder_get_object (bxml,
													   "commit_status_progress_bar"));
	logtext = GTK_WIDGET (gtk_builder_get_object (bxml, "subversion_log_view"));
	status_command = svn_status_command_new (plugin->project_root_dir, 
											 TRUE, TRUE);
	commit_prev_msg_enable = GTK_WIDGET (gtk_builder_get_object (bxml,
													   "commit_prev_msg_enable"));
	commit_prev_msg_combo = GTK_WIDGET (gtk_builder_get_object (bxml,
													   "commit_prev_msg_combo"));
													   
	g_signal_connect (G_OBJECT (commit_select_all_button), "clicked",
					  G_CALLBACK (select_all_status_items),
					  commit_status_view);
	
	g_signal_connect (G_OBJECT (commit_clear_button), "clicked",
					  G_CALLBACK (clear_all_status_selections),
					  commit_status_view);
	
	g_signal_connect (G_OBJECT (status_command), "command-finished",
					  G_CALLBACK (select_all_files),
					  commit_status_view);
	
	g_signal_connect(G_OBJECT (commit_prev_msg_enable), "toggled",
	                 G_CALLBACK(on_prev_message_enable_clicked),
	                 logtext);

	pulse_progress_bar (GTK_PROGRESS_BAR (commit_status_progress_bar));
	
	g_signal_connect (G_OBJECT (status_command), "command-finished",
					  G_CALLBACK (cancel_data_arrived_signal_disconnect),
					  commit_status_view);
	
	g_signal_connect (G_OBJECT (status_command), "command-finished",
					  G_CALLBACK (hide_pulse_progress_bar),
					  commit_status_progress_bar);
	
	g_signal_connect (G_OBJECT (status_command), "command-finished",
					  G_CALLBACK (on_status_command_finished),
					  NULL);
	
	g_signal_connect (G_OBJECT (status_command), "data-arrived",
					  G_CALLBACK (on_status_command_data_arrived),
					  commit_status_view);
	
	g_object_weak_ref (G_OBJECT (commit_status_view),
					   (GWeakNotify) disconnect_data_arrived_signals,
					   status_command);
	
	anjuta_command_start (ANJUTA_COMMAND (status_command));
	
	data = subversion_data_new(plugin, bxml);
	g_signal_connect(G_OBJECT(dialog), "response", 
		G_CALLBACK(on_subversion_commit_response), data);
	
	store = gtk_list_store_new (1, G_TYPE_STRING);
	cell = gtk_cell_renderer_text_new ();
  	gtk_cell_layout_clear(GTK_CELL_LAYOUT(commit_prev_msg_combo));
    gtk_combo_box_set_model(GTK_COMBO_BOX(commit_prev_msg_combo), NULL);                              
	gtk_combo_box_set_model(GTK_COMBO_BOX(commit_prev_msg_combo), GTK_TREE_MODEL(store));
	
	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (commit_prev_msg_combo), cell, FALSE);
	gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (commit_prev_msg_combo), cell,
                                  "text", 0,
                                  NULL);
	g_object_unref (store);
	
	gtk_widget_show_all (dialog);
	
	
	
	g_list_foreach(plugin->svn_commit_logs, subversion_commit_dialog_populate_logs, commit_prev_msg_combo);
	gtk_combo_box_set_active(GTK_COMBO_BOX(commit_prev_msg_combo), 0);
}
GtkWidget *
ipsec_dialog_new (GHashTable *hash)
{
	GtkBuilder *builder;
	GtkWidget *dialog = NULL;
	char *ui_file = NULL;
	GtkWidget *widget;
	const char *value;
	GError *error = NULL;

	g_return_val_if_fail (hash != NULL, NULL);

	ui_file = g_strdup_printf ("%s/%s", UIDIR, "nm-l2tp-dialog.ui");
	builder = gtk_builder_new ();

	if (!gtk_builder_add_from_file(builder, ui_file, &error)) {
		g_warning("Couldn't load builder file: %s", error ? error->message
				: "(unknown)");
		g_clear_error(&error);
		g_object_unref(G_OBJECT(builder));
		goto out;
	}
	gtk_builder_set_translation_domain(builder, GETTEXT_PACKAGE);


	dialog = GTK_WIDGET (gtk_builder_get_object (builder, "l2tp-ipsec-dialog"));
	if (!dialog) {
		g_object_unref (G_OBJECT (builder));
		goto out;
	}
	gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);

	g_object_set_data_full (G_OBJECT (dialog), "gtkbuilder-xml",
			builder, (GDestroyNotify) g_object_unref);

	value = g_hash_table_lookup (hash, NM_L2TP_KEY_IPSEC_ENABLE);
	if (value && !strcmp (value, "yes")) {
		widget = GTK_WIDGET (gtk_builder_get_object (builder, "ipsec_enable"));
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
	}

	widget = GTK_WIDGET (gtk_builder_get_object (builder, "ipsec_group_name"));
	value = g_hash_table_lookup (hash, NM_L2TP_KEY_IPSEC_GROUP_NAME);
	if (!value) value="GroupVPN";
	gtk_entry_set_text(GTK_ENTRY(widget), value);

	widget = GTK_WIDGET (gtk_builder_get_object (builder, "ipsec_gateway_id"));
	if((value = g_hash_table_lookup (hash, NM_L2TP_KEY_IPSEC_GATEWAY_ID)))
		gtk_entry_set_text(GTK_ENTRY(widget), value);

	widget = GTK_WIDGET (gtk_builder_get_object (builder, "ipsec_psk"));
	if((value = g_hash_table_lookup (hash, NM_L2TP_KEY_IPSEC_PSK)))
		gtk_entry_set_text(GTK_ENTRY(widget), value);

	widget = GTK_WIDGET (gtk_builder_get_object (builder,"ipsec_enable"));
	handle_enable_changed (widget, TRUE, builder);
	g_signal_connect (G_OBJECT (widget), "toggled", G_CALLBACK (enable_toggled_cb), builder);

out:
	g_free (ui_file);
	return dialog;
}
Exemple #6
0
/**
 * terminal_profile_edit:
 * @profile: a #TerminalProfile
 * @transient_parent: a #GtkWindow, or %NULL
 * @widget_name: a widget name in the profile editor's UI, or %NULL
 *
 * Shows the profile editor with @profile, anchored to @transient_parent.
 * If @widget_name is non-%NULL, focuses the corresponding widget and
 * switches the notebook to its containing page.
 */
void
terminal_profile_edit (TerminalProfile *profile,
                       GtkWindow       *transient_parent,
                       const char      *widget_name)
{
	char *path;
	GtkBuilder *builder;
	GError *error = NULL;
	GtkWidget *editor, *w;
	guint i;

	editor = g_object_get_data (G_OBJECT (profile), "editor-window");
	if (editor)
	{
		terminal_profile_editor_focus_widget (editor, widget_name);

		gtk_window_set_transient_for (GTK_WINDOW (editor),
		                              GTK_WINDOW (transient_parent));
		gtk_window_present (GTK_WINDOW (editor));
		return;
	}

	path = g_build_filename (TERM_PKGDATADIR, "profile-preferences.ui", NULL);
	builder = gtk_builder_new ();
	if (!gtk_builder_add_from_file (builder, path, &error))
	{
		g_warning ("Failed to load %s: %s\n", path, error->message);
		g_error_free (error);
		g_free (path);
		g_object_unref (builder);
		return;
	}
	g_free (path);

	editor = (GtkWidget *) gtk_builder_get_object  (builder, "profile-editor-dialog");
	g_object_set_data_full (G_OBJECT (editor), "builder",
	                        builder, (GDestroyNotify) g_object_unref);

	/* Store the dialogue on the profile, so we can acccess it above to check if
	 * there's already a profile editor for this profile.
	 */
	g_object_set_data (G_OBJECT (profile), "editor-window", editor);

	g_signal_connect (editor, "destroy",
	                  G_CALLBACK (profile_editor_destroyed),
	                  profile);

	g_signal_connect (editor, "response",
	                  G_CALLBACK (editor_response_cb),
	                  NULL);

	w = (GtkWidget *) gtk_builder_get_object  (builder, "color-scheme-combobox");
	init_color_scheme_menu (w);

	w = (GtkWidget *) gtk_builder_get_object  (builder, "darken-background-scale");
	init_background_darkness_scale (w);

	w = (GtkWidget *) gtk_builder_get_object  (builder, "background-image-filechooser");
	setup_background_filechooser (w, profile);

	/* Hook up the palette colorpickers and combo box */

	for (i = 0; i < TERMINAL_PALETTE_SIZE; ++i)
	{
		char name[32];
		char *text;

		g_snprintf (name, sizeof (name), "palette-colorpicker-%u", i + 1);
		w = (GtkWidget *) gtk_builder_get_object  (builder, name);

		g_object_set_data (G_OBJECT (w), "palette-entry-index", GUINT_TO_POINTER (i));

		text = g_strdup_printf (_("Choose Palette Color %d"), i + 1);
		gtk_color_button_set_title (GTK_COLOR_BUTTON (w), text);
		g_free (text);

		text = g_strdup_printf (_("Palette entry %d"), i + 1);
		gtk_widget_set_tooltip_text (w, text);
		g_free (text);

		g_signal_connect (w, "notify::color",
		                  G_CALLBACK (palette_color_notify_cb),
		                  profile);
	}

	profile_palette_notify_colorpickers_cb (profile, NULL, editor);
	g_signal_connect (profile, "notify::" TERMINAL_PROFILE_PALETTE,
	                  G_CALLBACK (profile_palette_notify_colorpickers_cb),
	                  editor);

	w = (GtkWidget *) gtk_builder_get_object  (builder, "palette-combobox");
	g_signal_connect (w, "notify::active",
	                  G_CALLBACK (palette_scheme_combo_changed_cb),
	                  profile);

	profile_palette_notify_scheme_combo_cb (profile, NULL, GTK_COMBO_BOX (w));
	g_signal_connect (profile, "notify::" TERMINAL_PROFILE_PALETTE,
	                  G_CALLBACK (profile_palette_notify_scheme_combo_cb),
	                  w);

	/* Hook up the color scheme pickers and combo box */
	w = (GtkWidget *) gtk_builder_get_object  (builder, "color-scheme-combobox");
	g_signal_connect (w, "notify::active",
	                  G_CALLBACK (color_scheme_combo_changed_cb),
	                  profile);

	profile_colors_notify_scheme_combo_cb (profile, NULL, GTK_COMBO_BOX (w));
	g_signal_connect (profile, "notify::" TERMINAL_PROFILE_FOREGROUND_COLOR,
	                  G_CALLBACK (profile_colors_notify_scheme_combo_cb),
	                  w);
	g_signal_connect (profile, "notify::" TERMINAL_PROFILE_BACKGROUND_COLOR,
	                  G_CALLBACK (profile_colors_notify_scheme_combo_cb),
	                  w);

#define CONNECT_WITH_FLAGS(name, prop, flags) terminal_util_bind_object_property_to_widget (G_OBJECT (profile), prop, (GtkWidget *) gtk_builder_get_object (builder, name), flags)
#define CONNECT(name, prop) CONNECT_WITH_FLAGS (name, prop, 0)
#define SET_ENUM_VALUE(name, value) g_object_set_data (gtk_builder_get_object (builder, name), "enum-value", GINT_TO_POINTER (value))

	w = GTK_WIDGET (gtk_builder_get_object (builder, "custom-command-entry"));
	custom_command_entry_changed_cb (GTK_ENTRY (w));
	g_signal_connect (w, "changed",
	                  G_CALLBACK (custom_command_entry_changed_cb), NULL);
	w = GTK_WIDGET (gtk_builder_get_object (builder, "profile-name-entry"));
	g_signal_connect (w, "changed",
	                  G_CALLBACK (visible_name_entry_changed_cb), editor);

	g_signal_connect (gtk_builder_get_object  (builder, "reset-compat-defaults-button"),
	                  "clicked",
	                  G_CALLBACK (reset_compat_defaults_cb),
	                  profile);

	SET_ENUM_VALUE ("image-radiobutton", TERMINAL_BACKGROUND_IMAGE);
	SET_ENUM_VALUE ("solid-radiobutton", TERMINAL_BACKGROUND_SOLID);
	SET_ENUM_VALUE ("transparent-radiobutton", TERMINAL_BACKGROUND_TRANSPARENT);
	CONNECT ("allow-bold-checkbutton", TERMINAL_PROFILE_ALLOW_BOLD);
	CONNECT ("background-colorpicker", TERMINAL_PROFILE_BACKGROUND_COLOR);
	CONNECT ("background-image-filechooser", TERMINAL_PROFILE_BACKGROUND_IMAGE_FILE);
	CONNECT ("backspace-binding-combobox", TERMINAL_PROFILE_BACKSPACE_BINDING);
	CONNECT ("bold-color-same-as-fg-checkbox", TERMINAL_PROFILE_BOLD_COLOR_SAME_AS_FG);
	CONNECT ("bold-colorpicker", TERMINAL_PROFILE_BOLD_COLOR);
	CONNECT ("cursor-shape-combobox", TERMINAL_PROFILE_CURSOR_SHAPE);
	CONNECT ("cursor-blink-combobox", TERMINAL_PROFILE_CURSOR_BLINK_MODE);
	CONNECT ("custom-command-entry", TERMINAL_PROFILE_CUSTOM_COMMAND);
	CONNECT ("darken-background-scale", TERMINAL_PROFILE_BACKGROUND_DARKNESS);
	CONNECT ("default-size-columns-spinbutton", TERMINAL_PROFILE_DEFAULT_SIZE_COLUMNS);
	CONNECT ("default-size-rows-spinbutton", TERMINAL_PROFILE_DEFAULT_SIZE_ROWS);
	CONNECT ("delete-binding-combobox", TERMINAL_PROFILE_DELETE_BINDING);
	CONNECT ("exit-action-combobox", TERMINAL_PROFILE_EXIT_ACTION);
	CONNECT ("font-selector", TERMINAL_PROFILE_FONT);
	CONNECT ("foreground-colorpicker", TERMINAL_PROFILE_FOREGROUND_COLOR);
	CONNECT ("image-radiobutton", TERMINAL_PROFILE_BACKGROUND_TYPE);
	CONNECT ("login-shell-checkbutton", TERMINAL_PROFILE_LOGIN_SHELL);
	CONNECT ("profile-name-entry", TERMINAL_PROFILE_VISIBLE_NAME);
	CONNECT ("scrollback-lines-spinbutton", TERMINAL_PROFILE_SCROLLBACK_LINES);
	CONNECT ("scrollback-unlimited-checkbutton", TERMINAL_PROFILE_SCROLLBACK_UNLIMITED);
	CONNECT ("scroll-background-checkbutton", TERMINAL_PROFILE_SCROLL_BACKGROUND);
	CONNECT ("scrollbar-position-combobox", TERMINAL_PROFILE_SCROLLBAR_POSITION);
	CONNECT ("scroll-on-keystroke-checkbutton", TERMINAL_PROFILE_SCROLL_ON_KEYSTROKE);
	CONNECT ("scroll-on-output-checkbutton", TERMINAL_PROFILE_SCROLL_ON_OUTPUT);
	CONNECT ("show-menubar-checkbutton", TERMINAL_PROFILE_DEFAULT_SHOW_MENUBAR);
	CONNECT ("solid-radiobutton", TERMINAL_PROFILE_BACKGROUND_TYPE);
	CONNECT ("system-font-checkbutton", TERMINAL_PROFILE_USE_SYSTEM_FONT);
	CONNECT ("title-entry", TERMINAL_PROFILE_TITLE);
	CONNECT ("title-mode-combobox", TERMINAL_PROFILE_TITLE_MODE);
	CONNECT ("transparent-radiobutton", TERMINAL_PROFILE_BACKGROUND_TYPE);
	CONNECT ("update-records-checkbutton", TERMINAL_PROFILE_UPDATE_RECORDS);
	CONNECT ("use-custom-command-checkbutton", TERMINAL_PROFILE_USE_CUSTOM_COMMAND);
	CONNECT ("use-custom-default-size-checkbutton", TERMINAL_PROFILE_USE_CUSTOM_DEFAULT_SIZE);
	CONNECT ("use-theme-colors-checkbutton", TERMINAL_PROFILE_USE_THEME_COLORS);
	CONNECT ("word-chars-entry", TERMINAL_PROFILE_WORD_CHARS);
	CONNECT_WITH_FLAGS ("bell-checkbutton", TERMINAL_PROFILE_SILENT_BELL, FLAG_INVERT_BOOL);

#undef CONNECT
#undef CONNECT_WITH_FLAGS
#undef SET_ENUM_VALUE

	profile_notify_sensitivity_cb (profile, NULL, editor);
	g_signal_connect (profile, "notify",
	                  G_CALLBACK (profile_notify_sensitivity_cb),
	                  editor);
	g_signal_connect (profile,
	                  "forgotten",
	                  G_CALLBACK (profile_forgotten_cb),
	                  editor);

	terminal_profile_editor_focus_widget (editor, widget_name);

	gtk_window_set_transient_for (GTK_WINDOW (editor),
	                              GTK_WINDOW (transient_parent));
	gtk_window_present (GTK_WINDOW (editor));
}
/**
 * main:
 **/
int
main (int argc, char *argv[])
{
	GOptionContext *context;
	GConfClient *gconf_client;
	GtkWidget *widget;
	GtkTreeSelection *selection;
	GtkEntryCompletion *completion;
	UniqueApp *unique_app;
	gboolean ret;
	guint retval;
	guint xid = 0;
	GError *error = NULL;

	const GOptionEntry options[] = {
		{ "filter", 'f', 0, G_OPTION_ARG_STRING, &filter,
		  /* TRANSLATORS: preset the GtktextBox with this filter text */
		  N_("Set the filter to this value"), NULL },
		{ "parent-window", 'p', 0, G_OPTION_ARG_INT, &xid,
		  /* TRANSLATORS: we can make this modal (stay on top of) another window */
		  _("Set the parent window to make this modal"), NULL },
		{ NULL}
	};

	setlocale (LC_ALL, "");

	bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);

	if (! g_thread_supported ())
		g_thread_init (NULL);
	g_type_init ();
	gtk_init (&argc, &argv);

	context = g_option_context_new (NULL);
	g_option_context_set_summary (context, _("Software Log Viewer"));
	g_option_context_add_main_entries (context, options, NULL);
	g_option_context_add_group (context, egg_debug_get_option_group ());
	g_option_context_add_group (context, gtk_get_option_group (TRUE));
	g_option_context_parse (context, &argc, &argv, NULL);
	g_option_context_free (context);

	/* are we running privileged */
	ret = gpk_check_privileged_user (_("Log viewer"), TRUE);
	if (!ret)
		return 1;

	/* are we already activated? */
	unique_app = unique_app_new ("org.freedesktop.PackageKit.LogViewer", NULL);
	if (unique_app_is_running (unique_app)) {
		egg_debug ("You have another instance running. This program will now close");
		unique_app_send_message (unique_app, UNIQUE_ACTIVATE, NULL);
		goto unique_out;
	}
	g_signal_connect (unique_app, "message-received",
			  G_CALLBACK (gpk_log_message_received_cb), NULL);

	/* add application specific icons to search path */
	gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
					   GPK_DATA G_DIR_SEPARATOR_S "icons");

	client = pk_client_new ();
	g_object_set (client,
		      "background", FALSE,
		      NULL);

	/* get UI */
	builder = gtk_builder_new ();
	retval = gtk_builder_add_from_file (builder, GPK_DATA "/gpk-log.ui", &error);
	if (retval == 0) {
		egg_warning ("failed to load ui: %s", error->message);
		g_error_free (error);
		goto out_build;
	}

	widget = GTK_WIDGET (gtk_builder_get_object (builder, "dialog_simple"));
	gtk_window_set_icon_name (GTK_WINDOW (widget), GPK_ICON_SOFTWARE_LOG);

	/* set a size, if the screen allows */
	gpk_window_set_size_request (GTK_WINDOW (widget), 900, 300);

	/* if command line arguments are set, then setup UI */
	if (filter != NULL) {
		widget = GTK_WIDGET (gtk_builder_get_object (builder, "entry_package"));
		gtk_entry_set_text (GTK_ENTRY(widget), filter);
	}

	/* Get the main window quit */
	g_signal_connect_swapped (widget, "delete_event", G_CALLBACK (gtk_main_quit), NULL);

	widget = GTK_WIDGET (gtk_builder_get_object (builder, "button_close"));
	g_signal_connect_swapped (widget, "clicked", G_CALLBACK (gtk_main_quit), NULL);
	gtk_widget_grab_default (widget);

	widget = GTK_WIDGET (gtk_builder_get_object (builder, "button_help"));
	g_signal_connect (widget, "clicked", G_CALLBACK (gpk_log_button_help_cb), NULL);
	widget = GTK_WIDGET (gtk_builder_get_object (builder, "button_refresh"));
	g_signal_connect (widget, "clicked", G_CALLBACK (gpk_log_button_refresh_cb), NULL);
	gtk_widget_hide (widget);
	widget = GTK_WIDGET (gtk_builder_get_object (builder, "button_filter"));
	g_signal_connect (widget, "clicked", G_CALLBACK (gpk_log_button_filter_cb), NULL);

	/* hit enter in the search box for filter */
	widget = GTK_WIDGET (gtk_builder_get_object (builder, "entry_package"));
	g_signal_connect (widget, "activate", G_CALLBACK (gpk_log_button_filter_cb), NULL);

	/* autocompletion can be turned off as it's slow */
	gconf_client = gconf_client_get_default ();
	ret = gconf_client_get_bool (gconf_client, GPK_CONF_AUTOCOMPLETE, NULL);
	if (ret) {
		/* create the completion object */
		completion = gpk_package_entry_completion_new ();
		widget = GTK_WIDGET (gtk_builder_get_object (builder, "entry_package"));
		gtk_entry_set_completion (GTK_ENTRY (widget), completion);
		g_object_unref (completion);
	} else {
		/* use search as you type */
		g_signal_connect (widget, "key-release-event", G_CALLBACK (gpk_log_entry_filter_cb), NULL);
	}
	g_object_unref (gconf_client);

	/* create list stores */
	list_store = gtk_list_store_new (GPK_LOG_COLUMN_LAST, G_TYPE_STRING, G_TYPE_STRING,
					 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
					 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN);

	/* create transaction_id tree view */
	widget = GTK_WIDGET (gtk_builder_get_object (builder, "treeview_simple"));
	gtk_tree_view_set_model (GTK_TREE_VIEW (widget),
				 GTK_TREE_MODEL (list_store));

	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget));
	g_signal_connect (selection, "changed",
			  G_CALLBACK (gpk_log_treeview_clicked_cb), NULL);

	/* add columns to the tree view */
	pk_treeview_add_general_columns (GTK_TREE_VIEW (widget));
	gtk_tree_view_columns_autosize (GTK_TREE_VIEW (widget));

	gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (list_store),
					      GPK_LOG_COLUMN_TIMESPEC, GTK_SORT_DESCENDING);

	/* show */
	widget = GTK_WIDGET (gtk_builder_get_object (builder, "dialog_simple"));
	gtk_widget_show (widget);

	/* set the parent window if it is specified */
	if (xid != 0) {
		egg_debug ("Setting xid %i", xid);
		gpk_window_set_parent_xid (GTK_WINDOW (widget), xid);
	}

	/* get the update list */
	gpk_log_refresh ();

	gtk_main ();

out_build:
	g_object_unref (builder);
	g_object_unref (list_store);
	g_object_unref (client);
	g_free (transaction_id);
	g_free (filter);
	if (transactions != NULL)
		g_ptr_array_unref (transactions);
unique_out:
	g_object_unref (unique_app);
	return 0;
}
int main(int argc, char* argv[]) 
{
    GError* err = NULL;
    
    gtk_init(&argc, &argv);

    gBuilder = gtk_builder_new();

    if (!gtk_builder_add_from_file(gBuilder, gTemplatePath, &err)) 
    {
        printf("Erro ao carregar layout: %s\n", err->message);
        g_free(err);
        return 0;
    }

    gWindow = GTK_WIDGET(gtk_builder_get_object(gBuilder, "window"));
    g_signal_connect(gWindow, "destroy", G_CALLBACK(gtk_main_quit), NULL);    

    { // Setting up Spin Buttons
        set_spin_btn(&gSpinCF, "spinCF");
        set_spin_btn(&gSpinPH, "spinPH");
        set_spin_btn(&gSpinDBO, "spinDBO");
        set_spin_btn(&gSpinNT, "spinNT");
        set_spin_btn(&gSpinFT, "spinFT");
        set_spin_btn(&gSpinDT, "spinDT");
        set_spin_btn(&gSpinTU, "spinTU");
        set_spin_btn(&gSpinOD, "spinOD");
        set_spin_btn(&gSpinST, "spinST");

        set_spin_btn_value(&gSpinCF, IQA_CF_WEIGHT);
        set_spin_btn_value(&gSpinPH, IQA_PH_WEIGHT);
        set_spin_btn_value(&gSpinDBO, IQA_DBO_WEIGHT);
        set_spin_btn_value(&gSpinNT, IQA_NT_WEIGHT);
        set_spin_btn_value(&gSpinFT, IQA_FT_WEIGHT);
        set_spin_btn_value(&gSpinDT, IQA_DT_WEIGHT);
        set_spin_btn_value(&gSpinTU, IQA_TU_WEIGHT);
        set_spin_btn_value(&gSpinOD, IQA_O2_WEIGHT);
        set_spin_btn_value(&gSpinST, IQA_ST_WEIGHT);    
    }

    { // Setting up Entries
        set_entry(&gEntryCF, "entryCF");
        set_entry(&gEntryPH, "entryPH");
        set_entry(&gEntryDBO, "entryDBO");
        set_entry(&gEntryNT, "entryNT");
        set_entry(&gEntryFT, "entryFT");
        set_entry(&gEntryDT, "entryDT");
        set_entry(&gEntryTU, "entryTU");
        set_entry(&gEntryOD, "entryOD");
        set_entry(&gEntryST, "entryST");

        set_entry(&gEntryIQA, "entryIQA");
        set_entry(&gEntryIQAIndex, "entryIQAIndex");
    }

    { // Setting up buttons
        set_btn(&gBtnCalculate, "btnCalculate");
        set_btn(&gBtnClean, "btnClean");
        set_btn(&gBtnReport, "btnReport");
        set_btn(&gBtnAbout, "btnAbout");

        // Button actions
        g_signal_connect(gBtnCalculate, "clicked", G_CALLBACK(calculate_iqa), NULL);
    }

    gtk_widget_show_all(gWindow);

    gtk_main();

    return 0;
}
static void
cc_screen_panel_init (CcScreenPanel *self)
{
  GError     *error;
  GtkWidget  *widget;

  self->priv = SCREEN_PANEL_PRIVATE (self);

  self->priv->builder = gtk_builder_new ();

  error = NULL;
  gtk_builder_add_from_file (self->priv->builder,
                             CINNAMONCC_UI_DIR "/screen.ui",
                             &error);

  if (error != NULL)
    {
      g_warning ("Could not load interface file: %s", error->message);
      g_error_free (error);
      return;
    }

  self->priv->cancellable = g_cancellable_new ();

  /* get initial brightness version */
  g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION,
                            G_DBUS_PROXY_FLAGS_NONE,
                            NULL,
                            "org.gnome.SettingsDaemon",
                            "/org/gnome/SettingsDaemon/Power",
                            "org.gnome.SettingsDaemon.Power.Screen",
                            self->priv->cancellable,
                            got_power_proxy_cb,
                            self);

  self->priv->lock_settings = g_settings_new ("org.gnome.desktop.screensaver");
  g_signal_connect (self->priv->lock_settings,
                    "changed",
                    G_CALLBACK (on_lock_settings_changed),
                    self);
  self->priv->gsd_settings = g_settings_new ("org.gnome.settings-daemon.plugins.power");
  self->priv->session_settings = g_settings_new ("org.gnome.desktop.session");
  self->priv->lockdown_settings = g_settings_new ("org.gnome.desktop.lockdown");
  g_signal_connect (self->priv->lockdown_settings,
                    "changed",
                    G_CALLBACK (on_lockdown_settings_changed),
                    self);

  /* bind the auto dim checkbox */
  widget = WID ("screen_auto_reduce_checkbutton");
  g_settings_bind (self->priv->gsd_settings,
                   "idle-dim-battery",
                   widget, "active",
                   G_SETTINGS_BIND_DEFAULT);

  /* display off time */
  widget = WID ("screen_brightness_combobox");
  GtkListStore *store = LS ("screen_brightness_liststore");
  gtk_combo_box_set_model (GTK_COMBO_BOX (widget), store);
  set_dpms_value_for_combo (GTK_COMBO_BOX (widget), self);
  g_signal_connect (widget, "changed",
                    G_CALLBACK (dpms_combo_changed_cb),
                    self);

  /* bind the screen lock checkbox */
  widget = WID ("screen_lock_on_switch");
  g_settings_bind (self->priv->lock_settings,
                   "lock-enabled",
                   widget, "active",
                   G_SETTINGS_BIND_DEFAULT);

  /* lock time */
  widget = WID ("screen_lock_combobox");
  store = LS ("lock_liststore");
  gtk_combo_box_set_model (GTK_COMBO_BOX (widget), store);
  set_lock_value_for_combo (GTK_COMBO_BOX (widget), self);
  g_signal_connect (widget, "changed",
                    G_CALLBACK (lock_combo_changed_cb),
                    self);

  widget = WID ("screen_lock_hbox");
  g_settings_bind (self->priv->lock_settings,
                   "lock-enabled",
                   widget, "sensitive",
                   G_SETTINGS_BIND_GET);

  update_lock_screen_sensitivity (self);

  /* bind the screen lock suspend checkbutton */
  widget = WID ("screen_lock_suspend_checkbutton");
  g_settings_bind (self->priv->lock_settings,
                   "ubuntu-lock-on-suspend",
                   widget, "active",
                   G_SETTINGS_BIND_DEFAULT);

  widget = WID ("screen_vbox");
  gtk_widget_reparent (widget, (GtkWidget *) self);
  g_object_set (self, "valign", GTK_ALIGN_START, NULL);
}
/**
 * main:
 **/
int
main (int argc, char *argv[])
{
	GMainLoop *loop;
	gboolean program_version = FALSE;
	GOptionContext *context;
	GtkWidget *widget;
	PkControl *control;
	guint retval;
	GError *error = NULL;

	const GOptionEntry options[] = {
		{ "version", '\0', 0, G_OPTION_ARG_NONE, &program_version,
		  _("Show the program version and exit"), NULL },
		{ NULL}
	};

	setlocale (LC_ALL, "");

	bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);

	if (! g_thread_supported ())
		g_thread_init (NULL);
	g_type_init ();
	gtk_init (&argc, &argv);

	context = g_option_context_new (NULL);
	g_option_context_set_summary (context, _("PackageKit Backend Details Viewer"));
	g_option_context_add_main_entries (context, options, NULL);
	g_option_context_add_group (context, egg_debug_get_option_group ());
	g_option_context_add_group (context, gtk_get_option_group (TRUE));
	g_option_context_parse (context, &argc, &argv, NULL);
	g_option_context_free (context);

	if (program_version) {
		g_print (VERSION "\n");
		return 0;
	}

	loop = g_main_loop_new (NULL, FALSE);
	control = pk_control_new ();

	/* get UI */
	builder = gtk_builder_new ();
	retval = gtk_builder_add_from_file (builder, GPK_DATA "/gpk-backend-status.ui", &error);
	if (retval == 0) {
		egg_warning ("failed to load ui: %s", error->message);
		g_error_free (error);
		goto out;
	}

	widget = GTK_WIDGET (gtk_builder_get_object (builder, "button_close"));
	g_signal_connect (widget, "clicked",
			  G_CALLBACK (gpk_backend_status_close_cb), loop);

	widget = GTK_WIDGET (gtk_builder_get_object (builder, "dialog_backend"));
	g_signal_connect (widget, "delete_event",
			  G_CALLBACK (gpk_backend_status_delete_event_cb), loop);
	gtk_window_set_icon_name (GTK_WINDOW (widget), GPK_ICON_SOFTWARE_LOG);
	gtk_widget_show (GTK_WIDGET (widget));

	/* get properties */
	pk_control_get_properties_async (control, NULL, (GAsyncReadyCallback) gpk_backend_status_get_properties_cb, loop);

	/* wait for results */
	g_main_loop_run (loop);
out:
	g_object_unref (builder);
	g_object_unref (control);
	g_main_loop_unref (loop);
	return 0;
}
Exemple #11
0
G_MODULE_EXPORT gboolean create_warning_span_event(GtkWidget * widget, gpointer data)
{
	GtkBuilder *warnings;
	GtkWidget *dialog = NULL;
	GtkWidget *spinner = NULL;
	GtkWidget *tmpwidget = NULL;
	GtkWidget *cbutton = NULL;
	MtxWarningRange *range = NULL;
	gfloat lbound = 0.0;
	gfloat ubound = 0.0;
	gchar * filename = NULL;
	gint result = 0;
	GError *error = NULL;
	gchar *pathstub = NULL;


	if (!GTK_IS_WIDGET(gauge))
		return FALSE;

	pathstub = g_build_filename(GAUGEDESIGNER_GLADE_DIR,"w_range.ui",NULL);
	filename = get_file(NULL,pathstub,NULL);
	g_free(pathstub);
	if (filename)
	{
		warnings = gtk_builder_new();
		if(!gtk_builder_add_from_file(warnings,filename,&error))
		{
			g_warning ("Couldn't load builder file: %s", error->message);
			g_error_free(error);
			exit(-1);
		}
		g_free(filename);
	}
	else
	{
		printf("Can't locate primary ui file!!!!\n");
		exit(-1);
	}

	gtk_builder_connect_signals(warnings,NULL);
	dialog = GTK_WIDGET (gtk_builder_get_object(warnings,"w_range_dialog"));
	cbutton = GTK_WIDGET (gtk_builder_get_object(warnings,"range_day_colorbutton"));
	gtk_color_button_set_color(GTK_COLOR_BUTTON(cbutton),&white);
	cbutton = GTK_WIDGET (gtk_builder_get_object(warnings,"range_nite_colorbutton"));
	gtk_color_button_set_color(GTK_COLOR_BUTTON(cbutton),&black);
	if (!GTK_IS_WIDGET(dialog))
	{
		return FALSE;
	}

	/* Set the controls to sane ranges corresponding to the gauge */
	mtx_gauge_face_get_attribute(MTX_GAUGE_FACE(gauge), LBOUND, &lbound);
	mtx_gauge_face_get_attribute(MTX_GAUGE_FACE(gauge), UBOUND, &ubound);
	spinner = GTK_WIDGET (gtk_builder_get_object(warnings,"range_lowpoint_spin"));
	OBJ_SET(spinner,"builder",warnings);
	gtk_spin_button_set_range(GTK_SPIN_BUTTON(spinner),lbound,ubound);
	gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinner),(ubound-lbound)/2.0);
	spinner = GTK_WIDGET (gtk_builder_get_object(warnings,"range_highpoint_spin"));
	OBJ_SET(spinner,"builder",warnings);
	gtk_spin_button_set_range(GTK_SPIN_BUTTON(spinner),lbound,ubound);
	gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinner),ubound);

	result = gtk_dialog_run(GTK_DIALOG(dialog));
	switch (result)
	{
		case GTK_RESPONSE_APPLY:
			range = g_new0(MtxWarningRange, 1);
			range->lowpoint = gtk_spin_button_get_value(GTK_SPIN_BUTTON(gtk_builder_get_object(warnings,"range_lowpoint_spin")));
			range->highpoint = gtk_spin_button_get_value(GTK_SPIN_BUTTON(gtk_builder_get_object(warnings,"range_highpoint_spin")));
			range->inset = gtk_spin_button_get_value(GTK_SPIN_BUTTON(gtk_builder_get_object(warnings,"range_inset_spin")));
			range->lwidth = gtk_spin_button_get_value(GTK_SPIN_BUTTON(gtk_builder_get_object(warnings,"range_lwidth_spin")));
			gtk_color_button_get_color(GTK_COLOR_BUTTON(gtk_builder_get_object(warnings,"range_day_colorbutton")),&range->color[MTX_DAY]);
			gtk_color_button_get_color(GTK_COLOR_BUTTON(gtk_builder_get_object(warnings,"range_nite_colorbutton")),&range->color[MTX_NITE]);
			changed = TRUE;
			mtx_gauge_face_set_warning_range_struct(MTX_GAUGE_FACE(gauge),range);
			g_free(range);
			update_onscreen_w_ranges();

			break;
		default:
			break;
	}
	if (GTK_IS_WIDGET(dialog))
		gtk_widget_destroy(dialog);

	return (FALSE);
}
Exemple #12
0
int main (int argc, char *argv[])
{
        GtkWidget *main_window = NULL;
        int width, height;
	char *ui_xml_filename;
	GError *err;

#if 0
#ifdef ENABLE_NLS
        bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
        bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
        textdomain (GETTEXT_PACKAGE);
#endif

        gtk_set_locale ();
#endif
	if (!g_thread_supported ()) g_thread_init (NULL);
        gdk_threads_init ();
        GDK_THREADS_ENTER ();

	// calls g_option_context_parse, which initializes gtk
        parse_arguments (argc, argv);

	// initialize gtk builder data
	ui_xml_filename = g_build_filename (PACKAGE_DATA_DIR, PACKAGE,
			"warlock.ui", NULL);
	err = NULL;
        warlock_xml = gtk_builder_new ();
	if (!gtk_builder_add_from_file (warlock_xml, ui_xml_filename, &err)) {
		g_warning ("Couldn't load builder file: %s", err->message);
		g_error_free (err);
		exit (1);
	}
	g_free (ui_xml_filename);

        warlock_init ();

        gtk_builder_connect_signals (warlock_xml, NULL);

        main_window = warlock_get_widget ("main_window");

        /* read window width from config */
        width = preferences_get_int (preferences_get_key (PREF_WINDOW_WIDTH));

        /* read window height from config */
        height = preferences_get_int (preferences_get_key
                        (PREF_WINDOW_HEIGHT));

        gtk_window_set_default_size (GTK_WINDOW (main_window), width, height);

        gtk_widget_show (main_window);
	warlock_connection_init ();

        gtk_main ();

        /* save the height an width */
        gtk_window_get_size (GTK_WINDOW (main_window), &width, &height);
        preferences_set_int (preferences_get_key (PREF_WINDOW_WIDTH), width);
        preferences_set_int (preferences_get_key (PREF_WINDOW_HEIGHT), height);
        GDK_THREADS_LEAVE ();

        debug ("waiting for connection to close\n");
        if (connection != NULL && connection->thread != NULL) {
                g_thread_join (connection->thread);
        }

        return 0;
}
Exemple #13
0
void
com_irontec_evosugar(void *ep, EMPopupTargetSelect *t) {

   CamelException ex = {0};


   gchar *folder_name =  camel_folder_get_name(t->folder);
   gboolean folder_is_sent = FALSE;
   BREAKPOINT;
   gui.gtkBuilder = gtk_builder_new();
   gtk_builder_set_translation_domain(gui.gtkBuilder, GETTEXT_PACKAGE);
   gtk_builder_add_from_file(gui.gtkBuilder, g_build_filename(PLUGIN_INSTALL_DIR, UI_FILE, NULL), NULL);


   gui.entry_search = GTK_WIDGET(gtk_builder_get_object(gui.gtkBuilder, "entrySearch"));
   gui.button_search = GTK_WIDGET(gtk_builder_get_object(gui.gtkBuilder, "buttonSearch"));
   gui.radio_button_from = GTK_WIDGET(gtk_builder_get_object(gui.gtkBuilder, "radiobuttonFrom"));
   gui.radio_button_to = GTK_WIDGET(gtk_builder_get_object(gui.gtkBuilder, "radiobuttonTo"));
   gui.button_submit = GTK_WIDGET(gtk_builder_get_object(gui.gtkBuilder, "buttonAddToSugarCRM"));

   gui.entry_subject_edit = GTK_WIDGET(gtk_builder_get_object(gui.gtkBuilder, "entryEditSubject"));

   BREAKPOINT;
   g_signal_connect(gui.button_search, "clicked",
         G_CALLBACK(on_button_search_clicked), GTK_ENTRY(gui.entry_search));
   g_signal_connect(gui.button_submit, "clicked",
         G_CALLBACK(on_button_AddToSugarCRM_clicked), NULL);

   scrm_session.id = scrm_login(gconf_get_username(), gconf_get_password(), gconf_get_server());

   if ((g_strcmp0(folder_name, "Sent") == 0) || (g_strcmp0(folder_name, _("Sent")) == 0) ) {
      folder_is_sent = TRUE;
   }

   if (scrm_session.id == NULL || g_strcmp0(scrm_session.id, "-1") == 0) {
      gui_show_message(_("SugarCRM"), _("Unable to connect: check your connection and settings please."));
   } else {


      BREAKPOINT;

      msg = camel_folder_get_message(t->folder, t->uids->pdata[0], &ex);
      util_get_msg_body(msg, &msg_body);

      if (msg == NULL) {
         camel_exception_clear(&ex);
         return;
      }
      BREAKPOINT;

      subject = camel_mime_message_get_subject(msg);
      gtk_entry_set_text(gui.entry_subject_edit, subject);

      gui.body_text_view = gtk_builder_get_object(gui.gtkBuilder, "bodyTextView");
      model.body_text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gui.body_text_view));

      gtk_text_buffer_set_text(model.body_text_buffer, msg_body, -1);

      from = camel_mime_message_get_from(msg);
      to = camel_mime_message_get_recipients(msg, CAMEL_RECIPIENT_TYPE_TO);

      BREAKPOINT;
      msg_date = camel_mime_message_get_date(msg, NULL);
      camel_internet_address_get(from, 0, &from_name, &from_addr);
      camel_internet_address_get(to, 0, &to_name, &to_addr);
      g_signal_connect(gui.radio_button_from, "pressed",
            G_CALLBACK(on_radio_group_search_changed), from_addr);

      gchar *to_search = to_addr;


      g_signal_connect(gui.radio_button_to, "pressed",
            G_CALLBACK(on_radio_group_search_changed), to_search);
      if (folder_is_sent) {
         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gui.radio_button_to),TRUE);
      }

      BREAKPOINT;

      GtkWidget *content_box = GTK_WIDGET(gtk_builder_get_object(gui.gtkBuilder, "vboxContents"));
      GtkWidget *frame_attach = GTK_WIDGET(gtk_builder_get_object(gui.gtkBuilder, "frameAttach"));

      if (folder_is_sent) {
         gtk_entry_set_text(gui.entry_search, to_addr);
      } else {
         gtk_entry_set_text(gui.entry_search, from_addr);
      }

      GtkScrolledWindow *scrolledwindow = GTK_SCROLLED_WINDOW(gtk_scrolled_window_new(NULL, NULL));
      gtk_scrolled_window_set_policy(scrolledwindow,
            GTK_POLICY_AUTOMATIC,
            GTK_POLICY_AUTOMATIC);
      GtkScrolledWindow *scrolledwindow2 = GTK_SCROLLED_WINDOW(gtk_scrolled_window_new(NULL, NULL));
      gtk_scrolled_window_set_policy(scrolledwindow2,
            GTK_POLICY_AUTOMATIC,
            GTK_POLICY_AUTOMATIC);



      BREAKPOINT;
      gtk_container_add(GTK_CONTAINER(content_box), scrolledwindow);
      gtk_container_add(GTK_CONTAINER(frame_attach), scrolledwindow2);
      BREAKPOINT;
      gui.treeview_search = gtk_tree_view_new();
      gui.treeview_attach = gtk_tree_view_new();


      add_columns_search(GTK_TREE_VIEW(gui.treeview_search));
      add_columns_attachment(GTK_TREE_VIEW(gui.treeview_attach));
      model.model_attach = util_get_msg_attachments(msg);


      //gtk_tree_view_set_model (GTK_TREE_VIEW (treeview), model_search);
      BREAKPOINT;
      //g_object_unref (G_OBJECT (model_search));

      gtk_builder_connect_signals(gui.gtkBuilder, NULL);
      gtk_tree_view_set_model(GTK_TREE_VIEW(gui.treeview_attach), model.model_attach);
      gtk_container_add(scrolledwindow, gui.treeview_search);
      gtk_container_add(scrolledwindow2, gui.treeview_attach);

      gui.mainwin =
         GTK_WIDGET(gtk_builder_get_object
               (gui.gtkBuilder, "addToSugarCRMwindow"));


      /*
       * Show the application window
       */
      gtk_widget_show_all(gui.mainwin);

      //trigger
      on_button_search_clicked(NULL, gui.entry_search);
      if (DEBUG_ON) {
         //g_mem_profile ();
      }

   } // end-else comprobar conexion
}
static void
enroll_fingerprints (GtkWindow *parent,
                     GtkWidget *label1,
                     GtkWidget *label2,
                     UmUser    *user)
{
        GDBusProxy *device;
        GtkBuilder *dialog;
        EnrollData *data;
        GtkWidget *ass;
        const char *filename;
        char *msg;
        GVariant *result;
        GError *error = NULL;

        device = NULL;

        if (manager == NULL) {
                create_manager ();
                if (manager != NULL)
                        device = get_first_device ();
        } else {
                device = get_first_device ();
        }

        if (manager == NULL || device == NULL) {
                GtkWidget *d;

                d = get_error_dialog (_("Could not access any fingerprint readers"),
                                      _("Please contact your system administrator for help."),
                                      parent);
                gtk_dialog_run (GTK_DIALOG (d));
                gtk_widget_destroy (d);
                return;
        }

        data = g_new0 (EnrollData, 1);
        data->device = device;
        data->label1 = label1;
        data->label2 = label2;

        /* Get some details about the device */
        result = g_dbus_connection_call_sync (connection,
                                              "net.reactivated.Fprint",
                                              g_dbus_proxy_get_object_path (data->device),
                                              "org.freedesktop.DBus.Properties",
                                              "GetAll",
                                              g_variant_new ("(s)", "net.reactivated.Fprint.Device"),
                                              G_VARIANT_TYPE ("(a{sv})"),
                                              G_DBUS_CALL_FLAGS_NONE,
                                              -1,
                                              NULL,
                                              NULL);
        if (result) {
                GVariant *props;
                gchar *scan_type;

                g_variant_get (result, "(@a{sv})", &props);
                g_variant_lookup (props, "name", "s", &data->name);
                g_variant_lookup (props, "scan-type", "s", &scan_type);
                if (g_strcmp0 (scan_type, "swipe") == 0)
                        data->is_swipe = TRUE;
                g_free (scan_type);
                g_variant_unref (props);
                g_variant_unref (result);
        }

        dialog = gtk_builder_new ();
        filename = UIDIR "/account-fingerprint.ui";
        if (!g_file_test (filename, G_FILE_TEST_EXISTS))
                filename = "data/account-fingerprint.ui";
        if (!gtk_builder_add_from_file (dialog, filename, &error)) {
                g_error ("%s", error->message);
                g_error_free (error);
                return;
        }
        data->dialog = dialog;

        ass = WID ("assistant");
        gtk_window_set_title (GTK_WINDOW (ass), _("Enable Fingerprint Login"));
        gtk_window_set_transient_for (GTK_WINDOW (ass), parent);
        gtk_window_set_modal (GTK_WINDOW (ass), TRUE);
        gtk_window_set_resizable (GTK_WINDOW (ass), FALSE);
        gtk_window_set_type_hint (GTK_WINDOW (ass), GDK_WINDOW_TYPE_HINT_DIALOG);

        g_signal_connect (G_OBJECT (ass), "cancel",
                          G_CALLBACK (assistant_cancelled), data);
        g_signal_connect (G_OBJECT (ass), "close",
                          G_CALLBACK (assistant_cancelled), data);
        g_signal_connect (G_OBJECT (ass), "prepare",
                          G_CALLBACK (assistant_prepare), data);

        /* Page 1 */
        gtk_combo_box_set_active (GTK_COMBO_BOX (WID ("finger_combobox")), 0);

        g_signal_connect (G_OBJECT (WID ("radiobutton1")), "toggled",
                          G_CALLBACK (finger_radio_button_toggled), data);
        g_signal_connect (G_OBJECT (WID ("radiobutton2")), "toggled",
                          G_CALLBACK (finger_radio_button_toggled), data);
        g_signal_connect (G_OBJECT (WID ("radiobutton3")), "toggled",
                          G_CALLBACK (finger_radio_button_toggled), data);
        g_signal_connect (G_OBJECT (WID ("finger_combobox")), "changed",
                          G_CALLBACK (finger_combobox_changed), data);

        data->finger = selected_finger (dialog);

        g_object_set_data (G_OBJECT (WID("page1")), "name", "intro");

        /* translators:
         * The variable is the name of the device, for example:
         * "To enable fingerprint login, you need to save one of your fingerprints, using the
         * 'Digital Persona U.are.U 4000/4000B' device."
         */
        msg = g_strdup_printf (_("To enable fingerprint login, you need to save one of your fingerprints, using the '%s' device."),
                               data->name);
        gtk_label_set_text (GTK_LABEL (WID("intro-label")), msg);
        g_free (msg);

        gtk_assistant_set_page_complete (GTK_ASSISTANT (ass), WID("page1"), TRUE);

        gtk_assistant_set_page_title (GTK_ASSISTANT (ass), WID("page1"), _("Selecting finger"));
        gtk_assistant_set_page_title (GTK_ASSISTANT (ass), WID("page2"), _("Enrolling fingerprints"));
        gtk_assistant_set_page_title (GTK_ASSISTANT (ass), WID("page3"), _("Summary"));

        /* Page 2 */
        g_object_set_data (G_OBJECT (WID("page2")), "name", "enroll");

        msg = g_strdup_printf (TR(finger_str_to_msg (data->finger, data->is_swipe)), data->name);
        gtk_label_set_text (GTK_LABEL (WID("enroll-label")), msg);
        g_free (msg);

        /* Page 3 */
        g_object_set_data (G_OBJECT (WID("page3")), "name", "summary");

        data->ass = ass;
        gtk_widget_show_all (ass);
}
Exemple #15
0
static void
pkg_channel_page_init (PkgChannelPage *page)
{
	PkgChannelPagePrivate *priv;
	gchar *path;
	GtkTreeViewColumn *column;
	GtkCellRenderer *cell;

	ENTRY;
	page->priv = G_TYPE_INSTANCE_GET_PRIVATE(page,
	                                         PKG_TYPE_CHANNEL_PAGE,
	                                         PkgChannelPagePrivate);
	priv = page->priv;

	#define EXTRACT_WIDGET(_n, _w)                                          \
	    G_STMT_START {                                                      \
	        priv->_w = (gpointer)gtk_builder_get_object(priv->builder, _n); \
	    } G_STMT_END

	path = pkg_path_for_data("ui", "pkg-channel-page.ui", NULL);
	priv->builder = gtk_builder_new();
	gtk_builder_add_from_file(priv->builder, path, NULL);
	g_free(path);

	EXTRACT_WIDGET("page-label", page_label);
	EXTRACT_WIDGET("channel-page", container);
	EXTRACT_WIDGET("target", target);
	EXTRACT_WIDGET("args", args);
	EXTRACT_WIDGET("working-dir", working_dir);
	EXTRACT_WIDGET("env", env);
	EXTRACT_WIDGET("pid", pid);
	EXTRACT_WIDGET("kill-pid", kill_pid);
	EXTRACT_WIDGET("exit-status", exit_status);
	EXTRACT_WIDGET("muted", muted);
	EXTRACT_WIDGET("sources", sources);

	gtk_widget_unparent(priv->container);
	gtk_container_add(GTK_CONTAINER(page), priv->container);

	column = gtk_tree_view_column_new();
	gtk_tree_view_column_set_title(column, _("ID"));
	gtk_tree_view_append_column(GTK_TREE_VIEW(priv->sources), column);
	cell = gtk_cell_renderer_text_new();
	gtk_tree_view_column_pack_start(column, cell, TRUE);
	gtk_tree_view_column_add_attribute(column, cell, "text", COLUMN_IDSTR);

	column = gtk_tree_view_column_new();
	gtk_tree_view_column_set_title(column, _("Plugin"));
	gtk_tree_view_append_column(GTK_TREE_VIEW(priv->sources), column);
	cell = gtk_cell_renderer_text_new();
	gtk_tree_view_column_pack_start(column, cell, TRUE);
	gtk_tree_view_column_add_attribute(column, cell, "text", COLUMN_PLUGIN);

	priv->model = gtk_list_store_new(3,
	                                 G_TYPE_INT,
	                                 G_TYPE_STRING,
	                                 G_TYPE_STRING);
	gtk_tree_view_set_model(GTK_TREE_VIEW(priv->sources),
	                        GTK_TREE_MODEL(priv->model));

	EXIT;
}
GtkDialog*
repair_dialog_new(GSList* files)
{
    GObject* object;
    GtkDialog* dialog;
    GtkComboBox* combobox;
    GtkTreeView* treeview;
    GtkTreeModel* model;
    GtkTreeViewColumn* column;
    GtkCellRenderer* renderer;
    GtkBuilder* builder;
    gboolean include_subdir = FALSE;
    
    builder = gtk_builder_new();
    gtk_builder_set_translation_domain(builder, GETTEXT_PACKAGE);
    gtk_builder_add_from_file(builder, REPAIR_DIALOG_UI, NULL);

    object = gtk_builder_get_object(builder, "repair_dialog");
    if (object == NULL)
	return NULL;

    dialog = GTK_DIALOG(object);
    files = g_slist_copy(files);
    g_slist_foreach(files, (GFunc)g_object_ref, NULL);
    repair_dialog_set_file_list(dialog, files);
    g_signal_connect(G_OBJECT(dialog), "destroy",
		     G_CALLBACK(on_dialog_destroy), NULL);

    object = gtk_builder_get_object(builder, "apply_button");
    if (object != NULL) {
	g_object_set_data(G_OBJECT(dialog), "apply_button", object);
    }

    object = gtk_builder_get_object(builder, "encoding_combo");
    if (object == NULL)
	return NULL;

    model = (GtkTreeModel*)encoding_list_model_new();
    combobox = GTK_COMBO_BOX(object);
    gtk_combo_box_set_model(combobox, model);
    gtk_combo_box_set_row_separator_func(combobox, is_separator, NULL, NULL);
    g_object_unref(G_OBJECT(model));
    select_default_encoding(combobox, model);
    repair_dialog_set_encoding_combo_box(dialog, combobox);
    g_signal_connect(G_OBJECT(combobox), "changed",
		     G_CALLBACK(on_encoding_changed), dialog);

    renderer = gtk_cell_renderer_text_new();
    gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combobox), renderer, TRUE);
    gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combobox), renderer,
	    "text", ENCODING_COLUMN_LABEL, NULL);

    object = gtk_builder_get_object(builder, "subdir_check_button");
    if (object != NULL) {
	include_subdir = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(object));
	g_object_set_data(G_OBJECT(dialog), "subdir_check_button", object);
	g_signal_connect(G_OBJECT(object), "toggled",
			 G_CALLBACK(on_subdir_check_toggled), dialog);
    }

    object = gtk_builder_get_object(builder, "file_list_view");
    if (object == NULL)
	return NULL;

    treeview = GTK_TREE_VIEW(object);
    repair_dialog_set_file_list_view(dialog, treeview);

    model = (GtkTreeModel*)file_list_model_new(files, include_subdir);
    repair_dialog_set_file_list_model(dialog, model);
    repair_dialog_update_file_list_model(dialog, TRUE);
    gtk_tree_view_set_model(treeview, model);
    g_object_unref(G_OBJECT(model));

    renderer = gtk_cell_renderer_text_new();
    column = gtk_tree_view_column_new_with_attributes(_("As is"),
	    renderer, "text", FILE_COLUMN_DISPLAY_NAME, NULL);
    gtk_tree_view_column_set_sort_column_id(column, FILE_COLUMN_NAME);
    gtk_tree_view_column_set_resizable(column, TRUE);
    gtk_tree_view_append_column(treeview, column);

    renderer = gtk_cell_renderer_text_new();
    column = gtk_tree_view_column_new_with_attributes(_("To be"),
	    renderer, "text", FILE_COLUMN_NEW_NAME, NULL);
    gtk_tree_view_column_set_sort_column_id(column, FILE_COLUMN_NEW_NAME);
    gtk_tree_view_column_set_resizable(column, TRUE);
    gtk_tree_view_append_column(treeview, column);

    g_object_unref(builder);

    return dialog;
}
Exemple #17
0
Fichier : main.c Projet : wellth/V5
static GtkWidget*
create_window1 (void)
{
	GtkWidget *window, *button1; 
	GtkImage *imageClient, *imageWellth, *imageBG;	
	GError** error = NULL;
	GTimeVal  time;
	GDate    *date_heap;
	
	GDate     date_stack;
	gchar     tmp_buffer[256];

	g_get_current_time( &time );
	date_heap = g_date_new();

	GDate* mod_date = g_date_new ();
	
	g_date_set_time_val( date_heap, &time );
	g_date_strftime( tmp_buffer, 256, "%x", date_heap );
	g_print( "Current date (heap):  %s\n", tmp_buffer );

	//g_date_set_year (mod_date, atoi (parts[2]));
	
	g_date_free( date_heap );
	
	/* Load UI from file */
	MainBuilder = gtk_builder_new ();
	if (!gtk_builder_add_from_file (MainBuilder, UI_FILE, error))
	{
		g_critical ("Couldn't load builder file: %s", (*error)->message);
		g_error_free (*error);
	}

	/* Auto-connect signal handlers */
	gtk_builder_connect_signals (MainBuilder, NULL);

	/* Get the window object from the ui file */
	window = GTK_WIDGET (gtk_builder_get_object (MainBuilder, TOP_WINDOW));
        if (!window)
        {
                g_critical ("Widget \"%s\" is missing in file %s.",
				TOP_WINDOW,
				UI_FILE);
        }

	//GdkPixbufAnimation * pixbufclntanm = gdk_pixbuf_animation_new_from_file(CLIENT_LOGO, error);
	GdkPixbufAnimation * pixbufwlthanm = gdk_pixbuf_animation_new_from_file(WELLTH_LOGO, error);
	//imageClient = (GtkImage *) GTK_WIDGET (gtk_builder_get_object (MainBuilder, "clnt_logo"));
	imageWellth = (GtkImage *) GTK_WIDGET (gtk_builder_get_object (MainBuilder, "wellth_logo"));
	//gtk_image_set_from_animation(GTK_IMAGE(imageClient), pixbufclntanm);
	gtk_image_set_from_animation (GTK_IMAGE(imageWellth), pixbufwlthanm);

	//GdkPixbufAnimation * pixbufBGanm = gdk_pixbuf_animation_new_from_file(BG1, error);
	imageBG = (GtkImage *) GTK_WIDGET (gtk_builder_get_object (MainBuilder, "image1"));
	gtk_image_set_from_animation(GTK_IMAGE(imageBG), pixbufBGanm);
#ifdef DISPLAY_ADD
	GdkPixbufAnimation * pixbufaddanm = gdk_pixbuf_animation_new_from_file(ADDS2, error);
	GtkImage *add = (GtkImage *) GTK_WIDGET (gtk_builder_get_object (MainBuilder, "adds"));
	gtk_image_set_from_animation(GTK_IMAGE(add), pixbufaddanm);
#endif
	button1 = GTK_WIDGET (gtk_builder_get_object (MainBuilder, "main_start_btn"));
 	 g_signal_connect (G_OBJECT (button1), "clicked", G_CALLBACK (start_button_clicked), NULL);

		
	
	priv = g_malloc (sizeof (struct _Private));
	/* ANJUTA: Widgets initialization for WindowMain.ui - DO NOT REMOVE */

	//g_object_unref (MainBuilder);
	
	return window;
}
Exemple #18
0
static GtkWidget *_create_popup_menu(XiphosHtml *html, const gchar *mod_name,
				     DIALOG_DATA *d)
{
	gchar *glade_file;
#ifdef USE_GTKBUILDER
	GtkBuilder *gxml;
#else
	GladeXML *gxml;
#endif
	const gchar *mname = (is_dialog ? d->mod_name : mod_name);
	XI_message(("_create_popup_menu mod_name:%s", mod_name));
	if (!mname || !*mname)
		return NULL;

#ifdef USE_GTKBUILDER
#ifdef HAVE_GTK_314
	glade_file =
	    gui_general_user_file("xi-menus-popup.gtkbuilder", FALSE);
#else
	glade_file =
	    gui_general_user_file("xi-menus-popup_old.gtkbuilder", FALSE);
#endif
#else
	glade_file = gui_general_user_file("xi-menus.glade", FALSE);
#endif
	g_return_val_if_fail((glade_file != NULL), NULL);

#ifdef USE_GTKBUILDER
	gxml = gtk_builder_new();
	gtk_builder_add_from_file(gxml, glade_file, NULL);
#else
	gxml = glade_xml_new(glade_file, "menu_popup", NULL);
#endif
	g_free(glade_file);
	g_return_val_if_fail((gxml != NULL), NULL);

	GtkWidget *menu = UI_GET_ITEM(gxml, "menu_popup");
	GtkWidget *bookmark = UI_GET_ITEM(gxml, "bookmark");
	GtkWidget *open = UI_GET_ITEM(gxml, "open_module2");
	GtkWidget *export_ = UI_GET_ITEM(gxml, "export_passage");
	GtkWidget *close = UI_GET_ITEM(gxml, "close");
	GtkWidget *note = UI_GET_ITEM(gxml, "note");
	GtkWidget *mark_verse = UI_GET_ITEM(gxml, "mark_verse");
	GtkWidget *open_edit = UI_GET_ITEM(gxml, "open_in_editor");
	GtkWidget *mod_opt_sub = UI_GET_ITEM(gxml, "module_options1_menu");
	GtkWidget *lookup = UI_GET_ITEM(gxml, "lookup_selection1");
	GtkWidget *lookup_sub =
	    UI_GET_ITEM(gxml, "lookup_selection1_menu");
	GtkWidget *unlock = UI_GET_ITEM(gxml, "unlock_this_module");
	GtkWidget *book_heading =
	    UI_GET_ITEM(gxml, "display_book_heading");
	GtkWidget *chapter_heading =
	    UI_GET_ITEM(gxml, "display_chapter_heading");
	GtkWidget *rename_percomm = UI_GET_ITEM(gxml, "rename_perscomm");
	GtkWidget *dump_percomm = UI_GET_ITEM(gxml, "dump_perscomm");

	GtkWidget *open_sub = gtk_menu_new();
	GtkWidget *note_sub = gtk_menu_new();

	gtk_widget_hide(unlock);
	gtk_widget_hide(book_heading);
	gtk_widget_hide(export_);
	gtk_widget_hide(chapter_heading);
	gtk_widget_hide(rename_percomm);
	gtk_widget_hide(dump_percomm);
	gtk_widget_hide(note);
	gtk_widget_hide(open_edit);
	gtk_widget_hide(mark_verse);
	gtk_widget_hide(close); /* FIXME: hide until connected to dialog close */

	if (is_dialog) {
		gtk_widget_hide(open);
		gtk_widget_hide(bookmark);
		gtk_widget_hide(export_);
	} else {
		gtk_widget_hide(close);
		gtk_menu_item_set_submenu(GTK_MENU_ITEM(open), open_sub);
		gui_add_mods_2_gtk_menu(_get_type_mod_list(), open_sub,
					(GCallback)on_view_mod_activate);

		/* unlock from main window only */
		if (main_has_cipher_tag((gchar *)mod_name))
			gtk_widget_show(unlock);
	}

	switch (main_get_mod_type((gchar *)mname)) {
	case TEXT_TYPE:
		gtk_widget_show(export_);
		if (is_dialog)
			break;
		gtk_widget_show(note);
		gtk_widget_show(mark_verse);
		gtk_menu_item_set_submenu(GTK_MENU_ITEM(note), note_sub);
		gui_add_mods_2_gtk_menu(PERCOMM_LIST, note_sub, (GCallback)
					on_edit_percomm_activate);
		break;

	case COMMENTARY_TYPE:
		gtk_widget_show(export_);
		gtk_widget_show(book_heading);
		gtk_widget_show(chapter_heading);
		break;

	case PERCOM_TYPE:
		gtk_widget_show(export_);
		gtk_widget_show(open_edit);
		g_signal_connect(G_OBJECT(open_edit),
				 "activate",
				 G_CALLBACK(on_edit_percomm_activate),
				 (gchar *)(is_dialog ? d->mod_name : mod_name));

		gtk_widget_show(rename_percomm);
		gtk_widget_show(dump_percomm);
		break;

	case DICTIONARY_TYPE:
		break;

	case BOOK_TYPE:
		break;

	case PRAYERLIST_TYPE:
		gtk_widget_show(open_edit);
		g_signal_connect(G_OBJECT(open_edit),
				 "activate",
				 G_CALLBACK(on_edit_prayerlist_activate),
				 (gchar *)(is_dialog ? d->mod_name : mod_name));
		break;
	}

	gtk_menu_item_set_submenu(GTK_MENU_ITEM(lookup), lookup_sub);

	gui_add_mods_2_gtk_menu(DICT_DESC_LIST, lookup_sub,
				(GCallback)_lookup_selection);

	/* = glade_xml_get_widget (gxml, ""); */
	_add_and_check_global_opts(gxml,
				   (char *)(is_dialog ? d->mod_name : mod_name), mod_opt_sub, d);
/* connect signals and data */
#ifdef USE_GTKBUILDER
	gtk_builder_connect_signals(gxml, html);
/*gtk_builder_connect_signals_full
	   (gxml, (GtkBuilderConnectFunc)gui_glade_signal_connect_func, html); */
#else
	glade_xml_signal_autoconnect_full(gxml, (GladeXMLConnectFunc)gui_glade_signal_connect_func,
					  html);
#endif

	return menu;
}
void
plot_add_function_show (OreganoEngine *engine, SimulationData *current)
{
	GtkBuilder *gui;
	GError *perror = NULL;
	GtkDialog *dialog;
	GtkComboBoxText *op1, *op2, *functiontype;
	int i;
	gint result = 0;
	GtkWidget *warning;
	GtkWidget *container_temp;
	
	SimulationFunction *func = g_new0 (SimulationFunction, 1);

	if ((gui = gtk_builder_new ()) == NULL) {
		oregano_error (_("Could not create plot window."));
		return;
	} 
	gtk_builder_set_translation_domain (gui, NULL);

	if (gtk_builder_add_from_file (gui, OREGANO_UIDIR "/plot-add-function.ui", &perror) <= 0) {
		oregano_error_with_title (_("Could not create plot window."), perror->message);
		g_error_free (perror);
		return;
	}

	dialog = GTK_DIALOG (gtk_builder_get_object (gui, "toplevel"));
	container_temp = GTK_WIDGET (gtk_builder_get_object (gui, "op1_alignment"));
	op1 = GTK_COMBO_BOX_TEXT (gtk_combo_box_text_new ());
	gtk_container_add (GTK_CONTAINER (container_temp), GTK_WIDGET (op1));
	gtk_widget_show (GTK_WIDGET (op1));
	
	container_temp = GTK_WIDGET (gtk_builder_get_object (gui, "op2_alignment"));
	op2 = GTK_COMBO_BOX_TEXT (gtk_combo_box_text_new ());
	gtk_container_add (GTK_CONTAINER (container_temp), GTK_WIDGET (op2));
	gtk_widget_show (GTK_WIDGET (op2));

	container_temp = GTK_WIDGET (gtk_builder_get_object (gui, "function_alignment"));
	functiontype = GTK_COMBO_BOX_TEXT (gtk_combo_box_text_new ());
	gtk_container_add (GTK_CONTAINER (container_temp), GTK_WIDGET (functiontype));
	gtk_widget_show (GTK_WIDGET (functiontype));

	gtk_combo_box_text_append_text (functiontype, _("Substraction"));
	gtk_combo_box_text_append_text (functiontype, _("Division"));

	for (i = 1; i < current->n_variables; i++) {
		if (current->type != DC_TRANSFER) {
			if (strchr (current->var_names[i], '#') == NULL) {
				gtk_combo_box_text_append_text (op1, current->var_names[i]);
				gtk_combo_box_text_append_text (op2, current->var_names[i]);
			}
		} 
		else {
			gtk_combo_box_text_append_text (op1, current->var_names[i]);
			gtk_combo_box_text_append_text (op2, current->var_names[i]);
		}
	}
	gtk_combo_box_set_active (GTK_COMBO_BOX (op1),0);
	gtk_combo_box_set_active (GTK_COMBO_BOX (op2),1);
	gtk_combo_box_set_active (GTK_COMBO_BOX (functiontype),0);

	result = gtk_dialog_run (GTK_DIALOG (dialog));
	
	if ((result == GTK_RESPONSE_OK) &&
	    ((gtk_combo_box_get_active (GTK_COMBO_BOX (op1)) == -1) ||
		 (gtk_combo_box_get_active (GTK_COMBO_BOX (op2)) == -1) ||
		 (gtk_combo_box_get_active (GTK_COMBO_BOX (functiontype)) == -1))) 
	{	
		warning = gtk_message_dialog_new_with_markup (
					NULL,
					GTK_DIALOG_MODAL,
					GTK_MESSAGE_WARNING,
					GTK_BUTTONS_OK, 
					_("<span weight=\"bold\" size=\"large\">Neither function, nor operators have been chosen</span>\n\n"
					"Please, take care to choose a function and their associated operators")); 

		if (gtk_dialog_run (GTK_DIALOG (warning)) == GTK_RESPONSE_OK)  {
			gtk_widget_destroy (GTK_WIDGET (warning));
			plot_add_function_show (engine, current);
			gtk_widget_destroy (GTK_WIDGET (dialog));
			return;
		}
	}

	if  ((result == GTK_RESPONSE_OK) &&
	     ((gtk_combo_box_get_active (GTK_COMBO_BOX (op1)) != -1) &&
		  (gtk_combo_box_get_active (GTK_COMBO_BOX (op2)) != -1) &&
		  (gtk_combo_box_get_active (GTK_COMBO_BOX (functiontype)) != -1))) {
	
		for (i = 1; i < current->n_variables; i++) {
			if (g_strcmp0 (current->var_names[i], gtk_combo_box_text_get_active_text (op1)) == 0)
				func->first = i;
			if (g_strcmp0 (current->var_names[i], gtk_combo_box_text_get_active_text (op2)) == 0)
				func->second = i;
			}
		current->functions = g_list_append (current->functions, func);
	}

	gtk_widget_destroy (GTK_WIDGET (dialog));
}
/**
 * @brief GUI thread load UI File and create the GUI
 */
static gpointer
guiThread(gpointer data)
{

	GtkBuilder 	*builder;
	GtkWidget 	*window;
	GError 		*error = NULL;

	/* create new GtkBuilder object */
	builder = gtk_builder_new ();

	/* load UI from file. If error occurs, report it and quit application. */
	if (!gtk_builder_add_from_file(builder, UI_FILE, &error)) {
		g_warning("error loading glade file: %s", error->message);
		g_free(error);
		return NULL;
	}

	/*Get objects from UI */

 	window = GTK_WIDGET (gtk_builder_get_object (builder, "window1"));
  	scale1 = GTK_WIDGET (gtk_builder_get_object (builder, "scale1"));
  	scale2 = GTK_WIDGET (gtk_builder_get_object (builder, "scale2"));
  	scale3 = GTK_WIDGET (gtk_builder_get_object (builder, "scale3"));
  	scale4 = GTK_WIDGET (gtk_builder_get_object (builder, "scale4"));
  	scale5 = GTK_WIDGET (gtk_builder_get_object (builder, "scale5"));
  	scale6 = GTK_WIDGET (gtk_builder_get_object (builder, "scale6"));

	adjustment1 = GTK_ADJUSTMENT (gtk_builder_get_object (builder,
															"adjustment1"));
	adjustment2 = GTK_ADJUSTMENT (gtk_builder_get_object (builder,
														  	"adjustment2"));
	adjustment3 = GTK_ADJUSTMENT (gtk_builder_get_object (builder,
														  	"adjustment3"));
	adjustment4 = GTK_ADJUSTMENT (gtk_builder_get_object (builder,
														  	"adjustment4"));
	adjustment5 = GTK_ADJUSTMENT (gtk_builder_get_object (builder,
														  	"adjustment5"));
	adjustment6 = GTK_ADJUSTMENT (gtk_builder_get_object (builder,
														  	"adjustment6"));

	dialog_port = GTK_DIALOG (gtk_builder_get_object (builder,
													  	"dialog1"));
	dialog_about = GTK_DIALOG (gtk_builder_get_object (builder,
													  	"aboutdialog1"));
	dialog_file = GTK_DIALOG (gtk_builder_get_object (builder,
													  	"filechooserdialog1"));
	dialog_error = GTK_DIALOG (gtk_builder_get_object (builder,
													  	"dialog_error"));
	dialog_error_port = GTK_DIALOG (gtk_builder_get_object (builder,
														"dialog_error_port"));
	dialog_list = GTK_DIALOG (gtk_builder_get_object (builder,
													  	"dialog_list"));
	dialog_name_exists = GTK_DIALOG (gtk_builder_get_object (builder,
													 	"dialog_name_exists"));

	combobox1 = GTK_WIDGET (gtk_builder_get_object (builder, "comboboxtext1"));
	combobox2 = GTK_WIDGET (gtk_builder_get_object (builder, "comboboxtext2"));
	combobox3 = GTK_WIDGET (gtk_builder_get_object (builder, "comboboxtext3"));
	combobox4 = GTK_WIDGET (gtk_builder_get_object (builder, "comboboxtext4"));
	combobox5 = GTK_WIDGET (gtk_builder_get_object (builder, "comboboxtext5"));

	bt_con_decon = GTK_WIDGET (gtk_builder_get_object (builder,
													   	"bt_con_decon"));
	button_save = GTK_WIDGET (gtk_builder_get_object (builder,
													  	"bt_save_position"));
	button_file = GTK_WIDGET (gtk_builder_get_object (builder,
													  	"bt_file"));
	bt_file_save = GTK_WIDGET (gtk_builder_get_object (builder,
													   	"bt_file_save"));
  	image_connect =  GTK_IMAGE (gtk_builder_get_object (builder,
													  	"image_connect"));
	entry_name_position = GTK_WIDGET (gtk_builder_get_object (builder,
														"entry_name_position"));
	bt_ok_error_port = GTK_WIDGET (gtk_builder_get_object (builder,
														"bt_ok_error_port"));
	switch1 = GTK_WIDGET (gtk_builder_get_object (builder,
												  		"switch1"));
	bt_edit = GTK_WIDGET (gtk_builder_get_object (builder,
												  		"bt_edit"));
	bt_open_file = GTK_WIDGET (gtk_builder_get_object (builder,
													   	"bt_open_file"));


	treeview = GTK_TREE_VIEW (gtk_builder_get_object (builder, "treeview"));
	model = GTK_LIST_STORE (gtk_builder_get_object (builder, "model"));

	/*************************************************/

	gtk_builder_connect_signals (builder, NULL);
  	g_object_unref (G_OBJECT (builder));

  	gtk_window_set_application (GTK_WINDOW (window), GTK_APPLICATION (app));
  	gtk_window_set_title (GTK_WINDOW (window), "Servo Calibration");
	gtk_window_set_default_size (GTK_WINDOW (window), 700,530);
  	gtk_window_set_default_icon_from_file("../glade/img8.png", NULL);
  	gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);

	gtk_window_set_transient_for (GTK_WINDOW (dialog_port),
								  	GTK_WINDOW (window));
	gtk_window_set_transient_for (GTK_WINDOW (dialog_about),
								  	GTK_WINDOW (window));
	gtk_window_set_transient_for (GTK_WINDOW (dialog_file),
								  	GTK_WINDOW (window));
	gtk_window_set_transient_for (GTK_WINDOW (dialog_error),
								  	GTK_WINDOW (window));
	gtk_window_set_transient_for (GTK_WINDOW (dialog_error_port),
								  	GTK_WINDOW (window));
	gtk_window_set_transient_for (GTK_WINDOW (dialog_list),
								  	GTK_WINDOW (window));
	gtk_window_set_transient_for (GTK_WINDOW (dialog_name_exists),
								 	GTK_WINDOW (window));

  	gtk_scale_add_mark (GTK_SCALE(scale1), 0, GTK_POS_LEFT ,"0°");
	gtk_scale_add_mark (GTK_SCALE(scale2), 0, GTK_POS_LEFT ,"0°");
	gtk_scale_add_mark (GTK_SCALE(scale3), 0, GTK_POS_LEFT ,"0°");
	gtk_scale_add_mark (GTK_SCALE(scale4), 0, GTK_POS_LEFT ,"0°");
	gtk_scale_add_mark (GTK_SCALE(scale5), 0, GTK_POS_LEFT ,"0°");
	gtk_scale_add_mark (GTK_SCALE(scale6), 0, GTK_POS_LEFT ,"0°");

	gtk_widget_set_sensitive (GTK_WIDGET(entry_name_position), FALSE);
	gtk_widget_set_sensitive (GTK_WIDGET(button_save), FALSE);
	gtk_widget_set_sensitive (GTK_WIDGET(switch1), FALSE);
	gtk_widget_set_sensitive (GTK_WIDGET(bt_edit), FALSE);


  	gtk_widget_show_all(GTK_WIDGET(window));
  	gtk_main();
  	return NULL;
}
Exemple #21
0
void
settings_show (GtkWidget *widget, SchematicView *sv)
{
	gint i;
	GtkWidget *engine_group = NULL;
	GtkWidget *w, *pbox, *toplevel;
	GtkBuilder *gui;
	GError *perror = NULL;
	gchar *msg;
	Settings *s;
	Schematic *sm;

	g_return_if_fail (sv != NULL);
	
	// If no engine available, stop oregano
	if ((g_find_program_in_path (engine[0]) == NULL) &&
	    (g_find_program_in_path (engine[1]) == NULL)) {
		gchar *msg;
		msg = g_strdup_printf (
		_("No engine allowing analysis is available.\n"
		  "You might install one, at least! \n"
		  "Either ngspice or gnucap."));
		oregano_error_with_title (_("Could not create settings dialog"), msg);
		g_free (msg);
		return;
	}
	
	g_return_if_fail (sv != NULL);

	if ((gui = gtk_builder_new ()) == NULL) {
		oregano_error (_("Could not create settings dialog"));
		return;
	} 
	gtk_builder_set_translation_domain (gui, NULL);

	sm = schematic_view_get_schematic (sv);
	s = schematic_get_settings (sm);

	// Only allow one instance of the property box per schematic.
	if (GTK_WIDGET (SETTINGS (s)->pbox)) {
		gdk_window_raise (gtk_widget_get_window (
		                   GTK_WIDGET (SETTINGS (s)->pbox)));
		return;
	}

	if (gtk_builder_add_from_file (gui, OREGANO_UIDIR "/settings.ui", &perror) <= 0) {
		msg = perror->message;
		oregano_error_with_title (_("Could not create settings dialog"), msg);
		g_error_free (perror);
		return;
	}

	w = toplevel = GTK_WIDGET (gtk_builder_get_object (gui, "toplevel"));
	if (!w) {
		oregano_error (_("Could not create settings dialog"));
		return;
	}
	g_signal_connect (G_OBJECT (w), "delete_event",
			  G_CALLBACK (delete_event_callback), s);

	pbox = toplevel;
	s->pbox = GTK_WIDGET (pbox);

	w = GTK_WIDGET (gtk_builder_get_object (gui, "close_bt"));
	g_signal_connect (G_OBJECT (w), "clicked",
		G_CALLBACK (apply_callback), s);

	w = GTK_WIDGET (gtk_builder_get_object (gui, "splash-enable"));
	s->w_show_splash = w;
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), oregano.show_splash);

	w = GTK_WIDGET (gtk_builder_get_object (gui, "compress-enable"));
	s->w_compress_files = w;
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w),
								  oregano.compress_files);
	w = GTK_WIDGET (gtk_builder_get_object (gui, "log-enable"));
	s->w_show_log = w;
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), oregano.show_log);

	w = GTK_WIDGET (gtk_builder_get_object (gui, "grid-size"));
	gtk_widget_set_sensitive (w, FALSE);
	w = GTK_WIDGET (gtk_builder_get_object (gui, "realtime-enable"));
	gtk_widget_set_sensitive (w, FALSE);

	w = GTK_WIDGET (gtk_builder_get_object (gui, "engine_table"));
	for (i = 0; i < OREGANO_ENGINE_COUNT; i++) {
		if (engine_group)
			button[i] = gtk_radio_button_new_with_label_from_widget (
			      GTK_RADIO_BUTTON (engine_group), engine[i]);
		else
			button[i] = engine_group = 
		          gtk_radio_button_new_with_label_from_widget (NULL, engine[i]);

		g_object_set_data (G_OBJECT (button[i]), "id", GUINT_TO_POINTER (i));

		gtk_grid_attach (GTK_GRID (w), button[i], 0, i, 1, 1);
		g_signal_connect (G_OBJECT (button[i]), "clicked", 
						  G_CALLBACK (set_engine_name), s);

	}
	
	// Is the engine available?
	// In that case the button is active
	if (g_find_program_in_path (engine[oregano.engine]) != NULL)
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button[oregano.engine]), 
		                              TRUE);
	// Otherwise the button is inactive
	else
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button[oregano.engine]), 
		                              FALSE);

	// If no engine available, stop oregano
	if ((g_find_program_in_path (engine[0]) == NULL) &&
	    (g_find_program_in_path (engine[1]) == NULL)) {
			gchar *msg;
			msg = g_strdup_printf (
			_("No engine allowing analysis is available.\n"
			  "You might install one, at least! \n"
			  "Either ngspice or gnucap."));
			oregano_error_with_title (_("Could not create settings dialog"), msg);
			g_free (msg);
	}

	gtk_widget_show_all (toplevel);
}
static void gmpc_tools_metadata_appearance_real_preferences_pane_construct (GmpcPluginPreferencesIface* base, GtkContainer* container) {
	GmpcToolsMetadataAppearance * self;
	GtkBuilder* _tmp0_ = NULL;
	GtkBuilder* builder;
	gchar* _tmp1_ = NULL;
	gchar* preferences_ui_file;
	GObject* _tmp2_ = NULL;
	GObject* _tmp3_;
	GtkWidget* _tmp4_;
	GtkWidget* builderWidget;
	GObject* _tmp5_ = NULL;
	GObject* _tmp6_;
	GtkWidget* _tmp7_;
	gint _tmp8_;
	GObject* _tmp9_ = NULL;
	GObject* _tmp10_;
	GtkWidget* _tmp11_;
	gint _tmp12_;
	GObject* _tmp13_ = NULL;
	GObject* _tmp14_;
	GtkWidget* _tmp15_;
	gint _tmp16_;
	GObject* _tmp17_ = NULL;
	GObject* _tmp18_;
	GtkWidget* _tmp19_;
	gint _tmp20_;
	GObject* _tmp21_ = NULL;
	GObject* _tmp22_;
	GtkWidget* _tmp23_;
	gint _tmp24_;
	GObject* _tmp25_ = NULL;
	GObject* _tmp26_;
	GtkWidget* _tmp27_;
	gint _tmp28_;
	GError * _inner_error_ = NULL;
	self = (GmpcToolsMetadataAppearance*) base;
	g_return_if_fail (container != NULL);
	_tmp0_ = gtk_builder_new ();
	builder = _tmp0_;
	_tmp1_ = gmpc_get_full_glade_path ("preferences-metadata-appearance.ui");
	preferences_ui_file = _tmp1_;
	gtk_builder_add_from_file (builder, preferences_ui_file, &_inner_error_);
	if (_inner_error_ != NULL) {
		_g_free0 (preferences_ui_file);
		_g_object_unref0 (builder);
		goto __catch15_g_error;
	}
	gtk_builder_connect_signals (builder, NULL);
	_tmp2_ = gtk_builder_get_object (builder, "frame_metadata_appearance_settings");
	_tmp3_ = _tmp2_;
	_tmp4_ = _g_object_ref0 ((GtkWidget*) (GTK_IS_FRAME (_tmp3_) ? ((GtkFrame*) _tmp3_) : NULL));
	builderWidget = _tmp4_;
	gtk_container_add (container, builderWidget);
	gtk_widget_show_all (builderWidget);
	_tmp5_ = gtk_builder_get_object (builder, "checkbutton_show_lyrics");
	_tmp6_ = _tmp5_;
	_tmp7_ = _g_object_ref0 ((GtkWidget*) (GTK_IS_CHECK_BUTTON (_tmp6_) ? ((GtkCheckButton*) _tmp6_) : NULL));
	_g_object_unref0 (builderWidget);
	builderWidget = _tmp7_;
	_tmp8_ = cfg_get_single_value_as_int_with_default (config, "MetaData", "show-lyrics", 1);
	gtk_toggle_button_set_active ((GtkToggleButton*) GTK_CHECK_BUTTON (builderWidget), (gboolean) _tmp8_);
	_tmp9_ = gtk_builder_get_object (builder, "checkbutton_show_artist_information");
	_tmp10_ = _tmp9_;
	_tmp11_ = _g_object_ref0 ((GtkWidget*) (GTK_IS_CHECK_BUTTON (_tmp10_) ? ((GtkCheckButton*) _tmp10_) : NULL));
	_g_object_unref0 (builderWidget);
	builderWidget = _tmp11_;
	_tmp12_ = cfg_get_single_value_as_int_with_default (config, "MetaData", "show-artist-information", 1);
	gtk_toggle_button_set_active ((GtkToggleButton*) GTK_CHECK_BUTTON (builderWidget), (gboolean) _tmp12_);
	_tmp13_ = gtk_builder_get_object (builder, "checkbutton_show_web_links");
	_tmp14_ = _tmp13_;
	_tmp15_ = _g_object_ref0 ((GtkWidget*) (GTK_IS_CHECK_BUTTON (_tmp14_) ? ((GtkCheckButton*) _tmp14_) : NULL));
	_g_object_unref0 (builderWidget);
	builderWidget = _tmp15_;
	_tmp16_ = cfg_get_single_value_as_int_with_default (config, "MetaData", "show-web-links", 1);
	gtk_toggle_button_set_active ((GtkToggleButton*) GTK_CHECK_BUTTON (builderWidget), (gboolean) _tmp16_);
	_tmp17_ = gtk_builder_get_object (builder, "checkbutton_show_similar_artists");
	_tmp18_ = _tmp17_;
	_tmp19_ = _g_object_ref0 ((GtkWidget*) (GTK_IS_CHECK_BUTTON (_tmp18_) ? ((GtkCheckButton*) _tmp18_) : NULL));
	_g_object_unref0 (builderWidget);
	builderWidget = _tmp19_;
	_tmp20_ = cfg_get_single_value_as_int_with_default (config, "MetaData", "show-similar-artist", 1);
	gtk_toggle_button_set_active ((GtkToggleButton*) GTK_CHECK_BUTTON (builderWidget), (gboolean) _tmp20_);
	_tmp21_ = gtk_builder_get_object (builder, "checkbutton_show_similar_songs");
	_tmp22_ = _tmp21_;
	_tmp23_ = _g_object_ref0 ((GtkWidget*) (GTK_IS_CHECK_BUTTON (_tmp22_) ? ((GtkCheckButton*) _tmp22_) : NULL));
	_g_object_unref0 (builderWidget);
	builderWidget = _tmp23_;
	_tmp24_ = cfg_get_single_value_as_int_with_default (config, "MetaData", "show-similar-songs", 1);
	gtk_toggle_button_set_active ((GtkToggleButton*) GTK_CHECK_BUTTON (builderWidget), (gboolean) _tmp24_);
	_tmp25_ = gtk_builder_get_object (builder, "checkbutton_show_guitar_tabs");
	_tmp26_ = _tmp25_;
	_tmp27_ = _g_object_ref0 ((GtkWidget*) (GTK_IS_CHECK_BUTTON (_tmp26_) ? ((GtkCheckButton*) _tmp26_) : NULL));
	_g_object_unref0 (builderWidget);
	builderWidget = _tmp27_;
	_tmp28_ = cfg_get_single_value_as_int_with_default (config, "MetaData", "show-guitar-tabs", 1);
	gtk_toggle_button_set_active ((GtkToggleButton*) GTK_CHECK_BUTTON (builderWidget), (gboolean) _tmp28_);
	_g_object_unref0 (builderWidget);
	_g_free0 (preferences_ui_file);
	_g_object_unref0 (builder);
	goto __finally15;
	__catch15_g_error:
	{
		GError * e;
		e = _inner_error_;
		_inner_error_ = NULL;
		fprintf (stderr, "Could not load UI: %s\n", e->message);
		_g_error_free0 (e);
	}
	__finally15:
	if (_inner_error_ != NULL) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
}
/* Initialize password dialog */
static void
passdlg_init (PasswordDialog *pdialog, GtkWindow *parent)
{
	GtkBuilder		*dialog;
	GtkWidget		*wpassdlg;
	GtkAccelGroup	*group;

	/* Initialize dialog */
	dialog = gtk_builder_new ();
    gtk_builder_add_from_file (dialog, MATECC_UI_DIR "/mate-about-me-password.ui", NULL);
	pdialog->ui = dialog;

	wpassdlg = WID ("change-password");
	capplet_set_icon (wpassdlg, "user-info");

	group = gtk_accel_group_new ();

	/*
	 * Initialize backend
	 */

	/* Initialize backend_pid. -1 means the backend is not running */
	pdialog->backend_pid = -1;

	/* Initialize IO Channels */
	pdialog->backend_stdin = NULL;
	pdialog->backend_stdout = NULL;

	/* Initialize write queue */
	pdialog->backend_stdin_queue = g_queue_new ();

	/* Initialize watchers */
	pdialog->backend_child_watch_id = 0;
	pdialog->backend_stdout_watch_id = 0;

	/* Initialize backend state */
	pdialog->backend_state = PASSWD_STATE_NONE;

	/*
	 * Initialize UI
	 */

	/* Initialize pdialog widgets */
	pdialog->current_password	= GTK_ENTRY (WID ("current-password"));
	pdialog->new_password		= GTK_ENTRY (WID ("new-password"));
	pdialog->retyped_password	= GTK_ENTRY (WID ("retyped-password"));
	pdialog->dialog_image		= GTK_IMAGE (WID ("dialog-image"));
	pdialog->status_label		= GTK_LABEL (WID ("status-label"));

	/* Initialize accelerators */
	gtk_widget_add_accelerator (GTK_WIDGET (pdialog->current_password),
								"activate", group,
								GDK_Return, 0,
								0);

	gtk_widget_add_accelerator (GTK_WIDGET (pdialog->new_password),
								"activate", group,
								GDK_Return, 0,
								0);

	/* Activate authenticate-button when enter is pressed in current-password */
	g_signal_connect (G_OBJECT (pdialog->current_password), "activate",
					  G_CALLBACK (passdlg_activate), WID ("authenticate-button"));

	/* Activate retyped-password when enter is pressed in new-password */
	g_signal_connect (G_OBJECT (pdialog->new_password), "activate",
					  G_CALLBACK (passdlg_activate), pdialog->retyped_password);

	/* Clear status message */
	passdlg_set_status (pdialog, "");

	/* Set non-authenticated state */
	passdlg_set_auth_state (pdialog, FALSE);

	/* Connect signal handlers */
	g_signal_connect (G_OBJECT (WID ("authenticate-button")), "clicked",
					  G_CALLBACK (passdlg_authenticate), pdialog);

	/* Verify new passwords on-the-fly */
	g_signal_connect (G_OBJECT (WID ("new-password")), "changed",
					  G_CALLBACK (passdlg_check_password), pdialog);
	g_signal_connect (G_OBJECT (WID ("retyped-password")), "changed",
					  G_CALLBACK (passdlg_check_password), pdialog);

	/* Set misc dialog properties */
	gtk_window_set_resizable (GTK_WINDOW (wpassdlg), FALSE);
	gtk_window_set_transient_for (GTK_WINDOW (wpassdlg), GTK_WINDOW (parent));
}
void interface_init (int argc, char *argv[])
{
	g_message ("Interface init");
	
	// GTK initialisieren
	g_message ("\tGTK init");
	gtk_init(&argc, &argv);
	
	ui = NULL;
	mainwindow = NULL;
	vbox_placeholder = NULL;
	keyboard = NULL;
	vbox_tractasono = NULL;
	actual_entry = NULL;
	
	module.music = NULL;
	module.radio = NULL;
	module.server = NULL;
	module.import = NULL;
	module.settings = NULL;
	module.fullscreen = NULL;
	module.disc = NULL;
	module.previous = NULL;
	
	// Das Interface laden
	GString* buildfile = g_string_new(g_get_current_dir());
	buildfile = g_string_append(buildfile, "/data/tractasono.ui");
	if (g_file_test(buildfile->str, G_FILE_TEST_EXISTS) == FALSE) {
		buildfile = g_string_assign(buildfile, INSTALLED_GLADE);
	}
	if (g_file_test(buildfile->str, G_FILE_TEST_EXISTS) == FALSE) {
		g_warning ("Die Glade Datei konnte nicht geladen werden!");
		exit (0);
	}
	
	GError* error = NULL;
	ui = gtk_builder_new();
	if (!gtk_builder_add_from_file (ui, buildfile->str, &error)) {
		g_error ("Couldn't load builder file: %s", error->message);
		g_error_free (error);
	}
	
	// Verbinde die Signale automatisch mit dem Interface
	gtk_builder_connect_signals (ui, NULL);
	
	// Hauptfenster holen
	mainwindow = interface_get_widget ("window_main");
	
	// Icon setzen
	const gchar* icon = INSTALLED_ICON;
	if (g_file_test(icon, G_FILE_TEST_EXISTS) == TRUE) {
		gtk_window_set_icon_from_file (GTK_WINDOW (mainwindow), icon, NULL);
	}

	// Placeholder holen
	vbox_placeholder = interface_get_widget ("vbox_placeholder");
	
	// Tractasono Root holen
	vbox_tractasono = interface_get_widget ("vbox_tractasono");

	// Die einzelnen Windows laden und referenzieren
	module.music = g_object_ref (interface_get_widget ("modul_music"));
	module.disc = g_object_ref (interface_get_widget ("vbox_disc"));
	module.server = g_object_ref (interface_get_widget ("servermodul"));
	module.settings = g_object_ref (interface_get_widget ("vbox_settings"));
	module.radio = g_object_ref (interface_get_widget ("radiomodul"));
	module.fullscreen = g_object_ref (interface_get_widget ("eventbox_fullscreen"));

	// Keyboard laden
	GtkWidget *vbox_placeholder_keyboard = NULL;
	vbox_placeholder_keyboard = interface_get_widget ("vbox_placeholder_keyboard");
	keyboard = interface_get_widget ("alignment_keyboard");
	gtk_widget_reparent(keyboard, vbox_placeholder_keyboard);
	gtk_widget_hide(keyboard);
	
	// Progressbar laden
	progress = GTK_PROGRESS_BAR( interface_get_widget ("range_song"));
	
	// LCD
	GtkWidget *lcdspace;
	lcdspace = interface_get_widget ("lcdbox");
	lcd = lcd_new ();
	gtk_container_add (GTK_CONTAINER (lcdspace), GTK_WIDGET (lcd));
	
	// LCD Text initial setzen
	gchar *title = db_settings_get_text ("LCD", "StartText");
	lcd_set_title (LCD (lcd), title);
	
	// Widget anzeigen
	gtk_widget_show (GTK_WIDGET (lcd));
	
	// Einzelne GUI Module initialisieren
	disc_init ();
	radio_init ();
	music_init ();
	//server_init ();
	settings_init ();
	fullscreen_init ();
	
	// Musik von Anfang an anzeigen
	interface_show_module(module.music);
}
Exemple #25
0
int main(int argc, char** argv)
{
    GtkBuilder* builder;
    char* str = NULL;

    GKeyFile* kf = g_key_file_new();
    const char* session_name = g_getenv("DESKTOP_SESSION");
    /* load settings from current session config files */
    if(!session_name)
        session_name = "LXDE";

    char* rel_path = g_strconcat("lxsession/", session_name, "/desktop.conf", NULL);
    char* user_config_file = g_build_filename(g_get_user_config_dir(), rel_path, NULL);

#ifdef ENABLE_NLS
    bindtextdomain ( GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR );
    bind_textdomain_codeset ( GETTEXT_PACKAGE, "UTF-8" );
    textdomain ( GETTEXT_PACKAGE );
#endif

    gtk_init(&argc, &argv);

    gtk_icon_theme_prepend_search_path(gtk_icon_theme_get_default(), PACKAGE_DATA_DIR);

    /* build the UI */
    builder = gtk_builder_new();

    gtk_builder_add_from_file( builder, PACKAGE_DATA_DIR "/lxinput.ui", NULL );
    dlg = (GtkWidget*)gtk_builder_get_object( builder, "dlg" );
    gtk_dialog_set_alternative_button_order( (GtkDialog*)dlg, GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1 );

    mouse_accel = (GtkRange*)gtk_builder_get_object(builder,"mouse_accel");
    mouse_threshold = (GtkRange*)gtk_builder_get_object(builder,"mouse_threshold");
    mouse_left_handed = (GtkToggleButton*)gtk_builder_get_object(builder,"left_handed");
    mouse_dclick = (GtkRange*)gtk_builder_get_object(builder, "mouse_dclick");

    kb_delay = (GtkRange*)gtk_builder_get_object(builder,"kb_delay");
    kb_interval = (GtkRange*)gtk_builder_get_object(builder,"kb_interval");
    kb_beep = (GtkToggleButton*)gtk_builder_get_object(builder,"beep");
    kb_layout = (GtkButton*)gtk_builder_get_object(builder,"keyboard_layout");

    const gchar *program = detect_keymap_program();
    if (program == NULL)
    {
        /* Hide the button if there is no program to set keymap */
        kb_layout_label = (GtkLabel*)gtk_builder_get_object(builder,"keyboard_layout_label");
        gtk_widget_set_visible(GTK_WIDGET(kb_layout_label), FALSE);
        gtk_widget_set_visible(GTK_WIDGET(kb_layout), FALSE);
    }
    else
    {
            gtk_button_set_label(kb_layout, _("Keyboard Layout..."));
    }

    g_object_unref( builder );


    /* read the config flie */
    load_settings();

    /* init the UI */
    gtk_range_set_value(mouse_accel, (gdouble)accel / 10.0);
    gtk_range_set_value(mouse_threshold, threshold);
    gtk_range_set_value(mouse_dclick, dclick);
    gtk_toggle_button_set_active(mouse_left_handed, left_handed);

    gtk_range_set_value(kb_delay, delay);
    gtk_range_set_value(kb_interval, interval);
    gtk_toggle_button_set_active(kb_beep, beep);

    set_range_stops(mouse_accel, 10);
    g_signal_connect(mouse_accel, "value-changed", G_CALLBACK(on_mouse_accel_changed), NULL);
    set_range_stops(mouse_threshold, 10);
    g_signal_connect(mouse_threshold, "value-changed", G_CALLBACK(on_mouse_threshold_changed), NULL);
    g_signal_connect(mouse_left_handed, "toggled", G_CALLBACK(on_left_handed_toggle), NULL);
    g_signal_connect(mouse_dclick, "value-changed", G_CALLBACK(on_mouse_dclick_changed), NULL);

    set_range_stops(kb_delay, 10);
    g_signal_connect(kb_delay, "value-changed", G_CALLBACK(on_kb_range_changed), &delay);
    set_range_stops(kb_interval, 10);
    g_signal_connect(kb_interval, "value-changed", G_CALLBACK(on_kb_range_changed), &interval);
    g_signal_connect(kb_beep, "toggled", G_CALLBACK(on_kb_beep_toggle), NULL);
    g_signal_connect(kb_layout, "clicked", G_CALLBACK(on_kb_layout_clicked), NULL);

    if( gtk_dialog_run( (GtkDialog*)dlg ) == GTK_RESPONSE_OK )
    {
        gsize len;

        if(!g_key_file_load_from_file(kf, user_config_file, G_KEY_FILE_KEEP_COMMENTS|G_KEY_FILE_KEEP_TRANSLATIONS, NULL))
        {
            /* the user config file doesn't exist, create its parent dir */
            len = strlen(user_config_file) - strlen("/desktop.conf");
            user_config_file[len] = '\0';
            g_debug("user_config_file = %s", user_config_file);
            g_mkdir_with_parents(user_config_file, 0700);
            user_config_file[len] = '/';

            g_key_file_load_from_dirs(kf, rel_path, (const char**)g_get_system_config_dirs(), NULL,
                                      G_KEY_FILE_KEEP_COMMENTS|G_KEY_FILE_KEEP_TRANSLATIONS, NULL);
        }

        g_free(rel_path);

        g_key_file_set_integer(kf, "Mouse", "AccFactor", accel);
        g_key_file_set_integer(kf, "Mouse", "AccThreshold", threshold);
        g_key_file_set_integer(kf, "Mouse", "LeftHanded", !!left_handed);

        g_key_file_set_integer(kf, "Keyboard", "Delay", delay);
        g_key_file_set_integer(kf, "Keyboard", "Interval", interval);
        g_key_file_set_integer(kf, "Keyboard", "Beep", !!beep);

        str = g_key_file_to_data(kf, &len, NULL);
        g_file_set_contents(user_config_file, str, len, NULL);
        g_free(str);

        /* ask the settigns daemon to reload */
        /* FIXME: is this needed? */
        /* g_spawn_command_line_sync("lxde-settings-daemon reload", NULL, NULL, NULL, NULL); */

        /* also save settings into autostart file for non-lxsession sessions */
        g_free(user_config_file);
        rel_path = g_build_filename(g_get_user_config_dir(), "autostart", NULL);
        user_config_file = g_build_filename(rel_path, "LXinput-setup.desktop", NULL);
        if (g_mkdir_with_parents(rel_path, 0755) == 0)
        {
            str = g_strdup_printf("[Desktop Entry]\n"
                                  "Type=Application\n"
                                  "Name=%s\n"
                                  "Comment=%s\n"
                                  "NoDisplay=true\n"
                                  "Exec=sh -c 'xset m %d/10 %d r rate %d %d b %s'\n"
                                  "NotShowIn=GNOME;KDE;XFCE;\n",
                                  _("LXInput autostart"),
                                  _("Setup keyboard and mouse using settings done in LXInput"),
                                  /* FIXME: how to setup left-handed mouse? */
                                  accel, threshold, delay, interval,
                                  beep ? "on" : "off");
            g_file_set_contents(user_config_file, str, -1, NULL);
            g_free(str);
        }
    }
    else
    {
        /* restore to original settings */

        /* keyboard */
        delay = old_delay;
        interval = old_interval;
        beep = old_beep;
        XkbSetAutoRepeatRate(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), XkbUseCoreKbd, delay, interval);
        /* FIXME: beep? */

        /* mouse */
        accel = old_accel;
        threshold = old_threshold;
        left_handed = old_left_handed;
        XChangePointerControl(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), True, True,
                                 accel, 10, threshold);
        set_left_handed_mouse();
        set_dclick_time (old_dclick);
    }

    gtk_widget_destroy( dlg );

	g_free( file );
    g_key_file_free( kf );
    g_free(user_config_file);

    return 0;
}
Exemple #26
0
int
main (int argc, char *argv[])
{
	gchar	*path;
	char	*tmp = NULL;
	int		opt;
	int		longopt_index;
	int		arg = 0;
	GError	*error = NULL;

	setlocale (LC_ALL, "");
	bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);

	/* parse command-line arguments */
	static struct option long_options[] = {
		{"help", 0, NULL, 'h'},
		{"version", 0, NULL, 'v'},
		{"add", 1, NULL, 'A'},
		{NULL, 0, NULL, 0}
	};
	
	while ((opt = getopt_long(argc, argv, "hvA:", long_options, &longopt_index)) > 0)
	{
		switch (opt)
		{
			case 'v':
				tmp = g_strdup_printf ("%s version %s (%s)\n",
							g_ascii_strdown(PACKAGE,strlen(PACKAGE)),
							VERSION,
							GFPM_RELEASE_NAME);
				fprintf (stdout, tmp);
				g_free (tmp);
				return 0;
			case 'A':
				if (optarg)
				{
					tmp = g_strdup (optarg);
					arg |= ARG_ADD;
				}
				break;
			case 'h':
			default:
				fprintf(stderr, "usage: %s [options]\n", basename(argv[0]));
				fprintf(stderr, "  -A, --add <file>		install a package from file\n");
				fprintf(stderr, "  -h, --help			display this help\n");
				fprintf(stderr, "  -v, --version			version information\n");
				return 1;
		}
	}
	
	/* invite trouble */
	g_thread_init (NULL);
	
	/* initialize internal gdk threads mutex */
	gdk_threads_init ();
	
	gtk_init (&argc, &argv);
	gdk_threads_enter ();
	path = g_strdup_printf ("%s%s", PREFIX, UI_FILE);

	gb = gtk_builder_new ();
	if (!gtk_builder_add_from_file(gb, path, &error))
	{
		gchar *msg = g_strdup_printf ("%s\n\n%s",
				_("Failed to initialize interface due to the following error(s) in gfpm.ui:"),
				error->message);
		gfpm_error (_("Interface initialization Failed"), msg);
		g_free (msg);
		return 1;
	}
	g_free (path);
	gtk_builder_connect_signals (gb, NULL);

	if (pacman_initialize ("/") == -1)
	{
		gfpm_error (_("Error initializing libpacman"), _("Failed to initialize libpacman"));
		return 1;
	}
	/* initialize configuration subsystem */
	gfpm_config_init ();
	/* initialize everything else */
	gfpm_interface_init (arg, (void*)tmp);
	
	/* the main loop */
	gtk_main ();
	
	/* phew */
	gdk_threads_leave ();

	gfpm_db_cleanup ();
	gfpm_config_free ();
	gfpm_prefs_cleanup ();
	pacman_release ();

	return 0;
}
/*!
* Set up the dialog.
*/
GtkWidget * 
AP_UnixDialog_Spell::_constructWindow (void)
{
	// get the path where our UI file is located
	std::string ui_path = static_cast<XAP_UnixApp*>(XAP_App::getApp())->getAbiSuiteAppUIDir() + "/ap_UnixDialog_Spell.xml";

	// load the dialog from the UI file
	GtkBuilder* builder = gtk_builder_new();
	gtk_builder_add_from_file(builder, ui_path.c_str(), NULL);

	m_wDialog = GTK_WIDGET(gtk_builder_get_object(builder, "ap_UnixDialog_Spell"));

	const XAP_StringSet * pSS = m_pApp->getStringSet();

	UT_UTF8String s;
	pSS->getValueUTF8(AP_STRING_ID_DLG_Spell_SpellTitle,s);
	gtk_window_set_title (GTK_WINDOW( m_wDialog), s.utf8_str());

	localizeLabelUnderline(GTK_WIDGET(gtk_builder_get_object(builder, "lbNotInDict")), pSS, AP_STRING_ID_DLG_Spell_UnknownWord);
	localizeLabelUnderline(GTK_WIDGET(gtk_builder_get_object(builder, "lbChangeTo")), pSS, AP_STRING_ID_DLG_Spell_ChangeTo);

	m_txWrong = GTK_WIDGET(gtk_builder_get_object(builder, "txWrong"));
	m_eChange = GTK_WIDGET(gtk_builder_get_object(builder, "eChange"));
	m_lvSuggestions = GTK_WIDGET(gtk_builder_get_object(builder, "tvSuggestions"));

	// localise
	localizeButtonUnderline (GTK_WIDGET(gtk_builder_get_object(builder, "btIgnore")), pSS, AP_STRING_ID_DLG_Spell_Ignore);
	localizeButtonUnderline (GTK_WIDGET(gtk_builder_get_object(builder, "btIgnoreAll")), pSS, AP_STRING_ID_DLG_Spell_IgnoreAll);
	localizeButtonUnderline (GTK_WIDGET(gtk_builder_get_object(builder, "btChange")), pSS, AP_STRING_ID_DLG_Spell_Change);
	localizeButtonUnderline (GTK_WIDGET(gtk_builder_get_object(builder, "btChangeAll")), pSS, AP_STRING_ID_DLG_Spell_ChangeAll);

	// attach signals
	g_signal_connect (GTK_WIDGET(gtk_builder_get_object(builder, "btAdd")), 
					  "clicked", 
					  G_CALLBACK (AP_UnixDialog_Spell__onAddClicked), 
					  (gpointer)this);
	g_signal_connect (GTK_WIDGET(gtk_builder_get_object(builder, "btIgnore")), 
					  "clicked", 
					  G_CALLBACK (AP_UnixDialog_Spell__onIgnoreClicked), 
					  (gpointer)this);
	g_signal_connect (GTK_WIDGET(gtk_builder_get_object(builder, "btIgnoreAll")), 
					  "clicked", 
					  G_CALLBACK (AP_UnixDialog_Spell__onIgnoreAllClicked), 
					  (gpointer)this);
	g_signal_connect (GTK_WIDGET(gtk_builder_get_object(builder, "btChange")), 
					  "clicked", 
					  G_CALLBACK (AP_UnixDialog_Spell__onChangeClicked), 
					  (gpointer)this);
	g_signal_connect (GTK_WIDGET(gtk_builder_get_object(builder, "btChangeAll")), 
					  "clicked", 
					  G_CALLBACK (AP_UnixDialog_Spell__onChangeAllClicked), 
					  (gpointer)this);
	g_signal_connect (GTK_TREE_VIEW (m_lvSuggestions), 
					  "row-activated", 
					  G_CALLBACK (AP_UnixDialog_Spell__onSuggestionDblClicked), 
					  (gpointer)this);
	m_replaceHandlerID = g_signal_connect (G_OBJECT(m_eChange), 
					   "changed",
					   G_CALLBACK (AP_UnixDialog_Spell__onSuggestionChanged),
					   (gpointer)this);


	// highlight our misspelled word in red
	GdkColormap * cm = gdk_colormap_get_system();
	m_highlight.red = 0xffff;
	m_highlight.green = 0x0000;
	m_highlight.blue = 0x0000;
	gdk_colormap_alloc_color(cm, &m_highlight, FALSE, TRUE);


	// Liststore and -view
	GtkListStore *store = gtk_list_store_new (NUM_COLUMNS, G_TYPE_STRING, G_TYPE_UINT);
	gtk_tree_view_set_model (GTK_TREE_VIEW (m_lvSuggestions), GTK_TREE_MODEL (store));
	g_object_unref (G_OBJECT (store));

	// Column Suggestion
	GtkCellRenderer *renderer = NULL;
	renderer = gtk_cell_renderer_text_new ();
	gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (m_lvSuggestions),
												-1, "Name", renderer,
												"text", COLUMN_SUGGESTION,
												NULL);
	GtkTreeViewColumn *column = gtk_tree_view_get_column (GTK_TREE_VIEW (m_lvSuggestions), 0);
	gtk_tree_view_column_set_sort_column_id (column, COLUMN_SUGGESTION);

	m_listHandlerID = g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (m_lvSuggestions)), 
				  "changed",
				  G_CALLBACK (AP_UnixDialog_Spell__onSuggestionSelected), 
				  (gpointer)this);

	gtk_widget_show_all (m_wDialog);

	g_object_unref(G_OBJECT(builder));

	return m_wDialog;
}
static GObject *
gdict_source_dialog_constructor (GType                  type,
				 guint                  n_construct_properties,
				 GObjectConstructParam *construct_params)
{
  GObject *object;
  GdictSourceDialog *dialog;
  GtkWidget *vbox;
  GError *error = NULL;

  object = G_OBJECT_CLASS (gdict_source_dialog_parent_class)->constructor (type,
									   n_construct_properties,
									   construct_params);
  dialog = GDICT_SOURCE_DIALOG (object);

  gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
  gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), 2);
  
  gtk_widget_push_composite_child ();

  /* get the UI from the GtkBuilder file */
  dialog->builder = gtk_builder_new ();
  gtk_builder_add_from_file (dialog->builder, GDICT_SOURCE_UI, &error);

  if (error) {
    g_critical ("Unable to load the user interface definition file: %s",
                error->message);
    g_error_free (error);
    g_assert_not_reached ();
  }
  
  /* the main widget */
  gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
                     GTK_WIDGET (gtk_builder_get_object (dialog->builder, "source_root")));

  /* the transport combo changes the UI by changing the visible widgets
   * bound to the transport's own options.
   */
  dialog->transport_combo = GTK_WIDGET (gtk_builder_get_object (dialog->builder, "transport_combo"));
  g_signal_connect (dialog->transport_combo, "changed",
  		    G_CALLBACK (transport_combo_changed_cb),
  		    dialog);

  /* the help button is always visible */
  dialog->help_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
  					       GTK_STOCK_HELP,
					       GTK_RESPONSE_HELP);
  
  vbox = GTK_WIDGET (gtk_builder_get_object (dialog->builder, "db-vbox"));
  dialog->db_chooser = gdict_database_chooser_new ();
  gtk_box_pack_start (GTK_BOX (vbox), dialog->db_chooser, TRUE, TRUE, 0);
  gtk_widget_show (dialog->db_chooser);

  vbox = GTK_WIDGET (gtk_builder_get_object (dialog->builder, "strat-vbox"));
  dialog->strat_chooser = gdict_strategy_chooser_new ();
  gtk_box_pack_start (GTK_BOX (vbox), dialog->strat_chooser, TRUE, TRUE, 0);
  gtk_widget_show (dialog->strat_chooser);

  /* the UI changes depending on the action that the source dialog
   * should perform
   */
  switch (dialog->action)
    {
    case GDICT_SOURCE_DIALOG_VIEW:
      /* disable every editable widget */
      gtk_editable_set_editable (GTK_EDITABLE (gtk_builder_get_object (dialog->builder, "name_entry")), FALSE);
      gtk_editable_set_editable (GTK_EDITABLE (gtk_builder_get_object (dialog->builder, "description_entry")), FALSE);
      gtk_editable_set_editable (GTK_EDITABLE (gtk_builder_get_object (dialog->builder, "hostname_entry")), FALSE);
      gtk_editable_set_editable (GTK_EDITABLE (gtk_builder_get_object (dialog->builder, "port_entry")), FALSE);
      
      gtk_widget_set_sensitive (dialog->transport_combo, FALSE);

      /* we just allow closing the dialog */
      dialog->close_button  = gtk_dialog_add_button (GTK_DIALOG (dialog),
      						     GTK_STOCK_CLOSE,
      						     GTK_RESPONSE_CLOSE);
      break;
    case GDICT_SOURCE_DIALOG_CREATE:
      dialog->cancel_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
      						     GTK_STOCK_CANCEL,
      						     GTK_RESPONSE_CANCEL);
      dialog->add_button    = gtk_dialog_add_button (GTK_DIALOG (dialog),
      						     GTK_STOCK_ADD,
      						     GTK_RESPONSE_ACCEPT);
      /* the "add" button sensitivity is controlled by the transport_combo
       * since it's the only setting that makes a source usable.
       */
      gtk_widget_set_sensitive (dialog->add_button, FALSE);
      break;
    case GDICT_SOURCE_DIALOG_EDIT:
      dialog->cancel_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
      						     GTK_STOCK_CANCEL,
      						     GTK_RESPONSE_CANCEL);
      dialog->close_button  = gtk_dialog_add_button (GTK_DIALOG (dialog),
		      	 			     GTK_STOCK_CLOSE,
						     GTK_RESPONSE_CLOSE);
      break;
    default:
      g_assert_not_reached ();
      break;
    }
  
  /* this will take care of updating the contents of the dialog
   * based on the action
   */
  update_dialog_ui (dialog);
  
  gtk_widget_pop_composite_child ();
  
  return object;
}
Exemple #29
0
static gboolean
create_window(void)
{
	GError *error = NULL;

   	builder = gtk_builder_new();
	if( !gtk_builder_add_from_file(builder, PACKAGE_DATA_DIR "/chimara.ui", &error) ) {
#ifdef DEBUG
		g_error_free(error);
		error = NULL;
		if( !gtk_builder_add_from_file(builder, PACKAGE_SRC_DIR "/chimara.ui", &error) ) {
#endif /* DEBUG */
			return FALSE;
#ifdef DEBUG
		}
#endif /* DEBUG */
	}

	window = GTK_WIDGET(load_object("chimara"));
	aboutwindow = GTK_WIDGET(load_object("aboutwindow"));
	prefswindow = GTK_WIDGET(load_object("prefswindow"));
	GtkActionGroup *actiongroup = GTK_ACTION_GROUP(load_object("actiongroup"));

	/* Set the default value of the "View/Toolbar" menu item upon creation of a
	 new window to the "show-toolbar-default" setting, but bind the setting
	 one-way only - we don't want toolbars to disappear suddenly */
	GtkToggleAction *toolbar_action = GTK_TOGGLE_ACTION(load_object("toolbar"));
	gtk_toggle_action_set_active(toolbar_action, g_settings_get_boolean(state_settings, "show-toolbar-default"));
	g_settings_bind(state_settings, "show-toolbar-default", toolbar_action, "active", G_SETTINGS_BIND_SET);

	const gchar **ptr;
	GtkRecentFilter *filter = gtk_recent_filter_new();
	/* TODO: Use mimetypes and construct the filter dynamically depending on 
	what plugins are installed */
	const gchar *patterns[] = {
		"*.z[1-8]", "*.[zg]lb", "*.[zg]blorb", "*.ulx", "*.blb", "*.blorb", NULL
	};

	for(ptr = patterns; *ptr; ptr++)
		gtk_recent_filter_add_pattern(filter, *ptr);
	GtkRecentChooser *recent = GTK_RECENT_CHOOSER(load_object("recent"));
	gtk_recent_chooser_add_filter(recent, filter);

	uimanager = gtk_ui_manager_new();
	if( !gtk_ui_manager_add_ui_from_file(uimanager, PACKAGE_DATA_DIR "/chimara.menus", &error) ) {
#ifdef DEBUG
		g_error_free(error);
		error = NULL;
		if( !gtk_ui_manager_add_ui_from_file(uimanager, PACKAGE_SRC_DIR "/chimara.menus", &error) )
#endif /* DEBUG */
			return FALSE;
	}

	glk = chimara_if_new();
	g_object_set(glk,
	    "ignore-errors", TRUE,
	    /*"interpreter-number", CHIMARA_IF_ZMACHINE_TANDY_COLOR,*/
	    NULL);
	if( !chimara_glk_set_css_from_file(CHIMARA_GLK(glk), PACKAGE_DATA_DIR "/style.css", &error) ) {
#ifdef DEBUG
		g_error_free(error);
		error = NULL;
		if( !chimara_glk_set_css_from_file(CHIMARA_GLK(glk), PACKAGE_SRC_DIR "/style.css", &error) )
#endif /* DEBUG */
			return FALSE;
	}
	
	/* DON'T UNCOMMENT THIS your eyes will burn
	 but it is a good test of programmatically altering just one style
	chimara_glk_set_css_from_string(CHIMARA_GLK(glk),
	    "buffer { font-family: 'Comic Sans MS'; }");*/
	
	GtkBox *vbox = GTK_BOX( gtk_builder_get_object(builder, "vbox") );			
	if(vbox == NULL)
		return FALSE;

	gtk_ui_manager_insert_action_group(uimanager, actiongroup, 0);
	GtkWidget *menubar = gtk_ui_manager_get_widget(uimanager, "/menubar");
	toolbar = gtk_ui_manager_get_widget(uimanager, "/toolbar");
	gtk_widget_set_no_show_all(toolbar, TRUE);
	if(gtk_toggle_action_get_active(toolbar_action))
		gtk_widget_show(toolbar);
	else
		gtk_widget_hide(toolbar);

	/* Connect the accelerators */
	GtkAccelGroup *accels = gtk_ui_manager_get_accel_group(uimanager);
	gtk_window_add_accel_group(GTK_WINDOW(window), accels);

	gtk_box_pack_end(vbox, glk, TRUE, TRUE, 0);
	gtk_box_pack_start(vbox, menubar, FALSE, FALSE, 0);
	gtk_box_pack_start(vbox, toolbar, FALSE, FALSE, 0);
	
	gtk_builder_connect_signals(builder, glk);
	g_signal_connect(glk, "notify::program-name", G_CALLBACK(change_window_title), window);
	g_signal_connect(glk, "notify::story-name", G_CALLBACK(change_window_title), window);
	
	/* Create preferences window */
	preferences_create(CHIMARA_GLK(glk));

	return TRUE;
}
Exemple #30
0
void ConfigurePlugins() {
	if (!UseGui) {
		/* How do we get here if we're not running the GUI? */
		/* Ryan: we're going to imagine that someday, there will be a way
		 * to configure plugins from the commandline */
		printf("ERROR: Plugins cannot be configured without the GUI.");
		return;
	}

	GtkWidget *widget;

	gchar *path;

	UpdatePluginsBIOS();

	builder = gtk_builder_new();
	if (!gtk_builder_add_from_file(builder, PACKAGE_DATA_DIR "pcsxr.ui", NULL)) {
		g_warning("Error: interface could not be loaded!");
		return;
	}

	UpdatePluginsBIOS_UpdateGUI(builder);

	ConfDlg = gtk_builder_get_object(builder, "ConfDlg");
	
	gtk_window_set_title(GTK_WINDOW(ConfDlg), _("Configure PCSXR"));
	gtk_widget_show (ConfDlg);

	/* Set the paths in the file choosers to be based on the saved configurations */
	widget = gtk_builder_get_object(builder, "GtkFileChooser_Bios");
	gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (widget), Config.BiosDir);

	widget = gtk_builder_get_object(builder, "GtkFileChooser_Plugin");
	gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (widget), Config.PluginsDir);

	if (strlen(Config.PluginsDir) == 0) {
		if((path = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (widget))) != NULL) {
			strcpy(Config.PluginsDir, path);
			g_free(path);
		}
	}

	widget = gtk_builder_get_object(builder, "btn_ConfGpu");
	g_signal_connect_data(G_OBJECT(widget), "clicked",
			G_CALLBACK(on_configure_plugin), (gpointer) PSE_LT_GPU, NULL, G_CONNECT_AFTER);

	widget = gtk_builder_get_object(builder, "btn_ConfSpu");
	g_signal_connect_data(G_OBJECT(widget), "clicked",
			G_CALLBACK(on_configure_plugin), (gpointer) PSE_LT_SPU, NULL, G_CONNECT_AFTER);

	/* ADB TODO Does pad 1 and 2 need to be different? */
	widget = gtk_builder_get_object(builder, "btn_ConfPad1");
	g_signal_connect_data(G_OBJECT(widget), "clicked",
						  G_CALLBACK(OnConfConf_Pad1Conf), builder, NULL, G_CONNECT_AFTER);

	widget = gtk_builder_get_object(builder, "btn_ConfPad2");
	g_signal_connect_data(G_OBJECT(widget), "clicked",
			G_CALLBACK(OnConfConf_Pad2Conf), builder, NULL, G_CONNECT_AFTER);

	widget = gtk_builder_get_object(builder, "btn_ConfCdr");
	g_signal_connect_data(G_OBJECT(widget), "clicked",
			G_CALLBACK(on_configure_plugin), (gpointer) PSE_LT_CDR, NULL, G_CONNECT_AFTER);

	widget = gtk_builder_get_object(builder, "btn_AboutGpu");
	g_signal_connect_data(G_OBJECT(widget), "clicked",
			G_CALLBACK(on_about_plugin), (gpointer) PSE_LT_GPU, NULL, G_CONNECT_AFTER);

	widget = gtk_builder_get_object(builder, "btn_AboutSpu");
	g_signal_connect_data(G_OBJECT(widget), "clicked",
			G_CALLBACK(on_about_plugin), (gpointer) PSE_LT_SPU, NULL, G_CONNECT_AFTER);

	widget = gtk_builder_get_object(builder, "btn_AboutPad1");
	g_signal_connect_data(G_OBJECT(widget), "clicked",
			G_CALLBACK(OnConfConf_Pad1About), builder, NULL, G_CONNECT_AFTER);

	widget = gtk_builder_get_object(builder, "btn_AboutPad2");
	g_signal_connect_data(G_OBJECT(widget), "clicked",
			G_CALLBACK(OnConfConf_Pad2About), builder, NULL, G_CONNECT_AFTER);

	widget = gtk_builder_get_object(builder, "btn_AboutCdr");
	g_signal_connect_data(G_OBJECT(widget), "clicked",
			G_CALLBACK(on_about_plugin), (gpointer) PSE_LT_CDR, NULL, G_CONNECT_AFTER);

	widget = gtk_builder_get_object(builder, "GtkFileChooser_Bios");
	g_signal_connect_data(G_OBJECT(widget), "current_folder_changed",
			G_CALLBACK(OnBiosPath_Changed), builder, NULL, G_CONNECT_AFTER);

	widget = gtk_builder_get_object(builder, "GtkFileChooser_Plugin");
	g_signal_connect_data(G_OBJECT(widget), "current_folder_changed",
			G_CALLBACK(OnPluginPath_Changed), builder, NULL, G_CONNECT_AFTER);

	g_signal_connect_data(G_OBJECT(ConfDlg), "response",
			G_CALLBACK(OnConf_Clicked), builder, (GClosureNotify)g_object_unref, G_CONNECT_AFTER);
}