Exemplo n.º 1
0
// window resized signal handler
static gboolean
view_resized (GtkWindow *window, GdkEvent *event, gpointer data)
{
	int width, height;
	char *name = data;

	width = event->configure.width;
	height = event->configure.height;

	preferences_set_int (preferences_get_window_key (name, "width"), width);
	preferences_set_int (preferences_get_window_key (name, "height"),
			height);

	return FALSE;
}
Exemplo n.º 2
0
static void
on_spinbutton_value_changed (GtkSpinButton *spinbutton,
                             gpointer user_data)
{
    Preference pref;

    pref = GPOINTER_TO_INT (user_data);
    preferences_set_int (preferences_get_key (pref),
                         gtk_spin_button_get_value_as_int (spinbutton));
}
Exemplo n.º 3
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;
}