Exemple #1
0
static void explorer_init(Explorer *self) {

    if (g_file_test (FYRE_DATADIR "/explorer.glade", G_FILE_TEST_EXISTS))
        self->xml = glade_xml_new (FYRE_DATADIR "/explorer.glade", NULL, NULL);
    if (!self->xml)
	self->xml = glade_xml_new(BR_DATADIR("/fyre/explorer.glade"), NULL, NULL);
    if (!self->xml) {
	GtkWidget *dialog;
	dialog = gtk_message_dialog_new_with_markup(NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
						    "<b>Fyre can't find its data files.</b>\n\n"
						    "The main glade file could not be located.\n"
						    "We tried looking for it in the following places:\n"
						    "\n"
						    "    %s\n"
						    "    %s",
						    FYRE_DATADIR "/explorer.glade",
						    BR_DATADIR("/fyre/explorer.glade"));
	gtk_dialog_run(GTK_DIALOG(dialog));
	exit(0);
    }

    self->window = glade_xml_get_widget(self->xml, "explorer_window");
    fyre_set_icon_later(self->window);
    fyre_set_icon_later(glade_xml_get_widget(self->xml, "animation_window"));
    fyre_set_icon_later(glade_xml_get_widget(self->xml, "interactive_prefs"));
    fyre_set_icon_later(glade_xml_get_widget(self->xml, "cluster_window"));
    fyre_set_icon_later(glade_xml_get_widget(self->xml, "about_window"));
    fyre_set_icon_later(glade_xml_get_widget(self->xml, "error dialog"));

    /* Connect signal handlers */
    glade_xml_signal_connect_data(self->xml, "on_randomize",                    G_CALLBACK(on_randomize),                    self);
    glade_xml_signal_connect_data(self->xml, "on_load_defaults",                G_CALLBACK(on_load_defaults),                self);
    glade_xml_signal_connect_data(self->xml, "on_save",                         G_CALLBACK(on_save),                         self);
    glade_xml_signal_connect_data(self->xml, "on_save_exr",                     G_CALLBACK(on_save_exr),                     self);
    glade_xml_signal_connect_data(self->xml, "on_quit",                         G_CALLBACK(on_quit),                         self);
    glade_xml_signal_connect_data(self->xml, "on_pause_rendering_toggle",       G_CALLBACK(on_pause_rendering_toggle),       self);
    glade_xml_signal_connect_data(self->xml, "on_load_from_image",              G_CALLBACK(on_load_from_image),              self);
    glade_xml_signal_connect_data(self->xml, "on_widget_toggle",                G_CALLBACK(on_widget_toggle),                self);
    glade_xml_signal_connect_data(self->xml, "on_zoom_reset",                   G_CALLBACK(on_zoom_reset),                   self);
    glade_xml_signal_connect_data(self->xml, "on_zoom_in",                      G_CALLBACK(on_zoom_in),                      self);
    glade_xml_signal_connect_data(self->xml, "on_zoom_out",                     G_CALLBACK(on_zoom_out),                     self);
    glade_xml_signal_connect_data(self->xml, "on_render_time_changed",          G_CALLBACK(on_render_time_changed),          self);
    glade_xml_signal_connect_data(self->xml, "on_interactive_prefs_delete",     G_CALLBACK(on_interactive_prefs_delete),     self);

#ifndef HAVE_EXR
    /* If we don't have OpenEXR support, gray out the menu item
     * so it sits there taunting the user and not breaking HIG
     */
    gtk_widget_set_sensitive(glade_xml_get_widget(self->xml, "save_image_as_exr"), FALSE);
#endif

    /* Set up the statusbar */
    self->statusbar = GTK_STATUSBAR(glade_xml_get_widget(self->xml, "statusbar"));
    self->render_status_context = gtk_statusbar_get_context_id(self->statusbar, "Rendering status");
    self->speed_timer = g_timer_new();
    self->auto_update_rate_timer = g_timer_new();
    self->status_update_rate_timer = g_timer_new();
}
Exemple #2
0
static char * get_datadir(void)
{
#ifdef _WIN32
	HINSTANCE hInstance;
#endif
	char * data_dir = NULL;

	if (custom_data_dir != NULL) {
		data_dir = safe_strdup(custom_data_dir);
		return data_dir; 
	}
	
#ifdef ENABLE_BINRELOC
	data_dir = safe_strdup (BR_DATADIR("/link-grammar"));
#elif defined(_WIN32)
	/* Dynamically locate library and return containing directory */
	hInstance = GetModuleHandle(NULL);
	if(hInstance != NULL)
	{
		char dll_path[MAX_PATH];

		if(GetModuleFileName(hInstance,dll_path,MAX_PATH)) {
			data_dir = path_get_dirname(dll_path);
		}
	}
#endif

	return data_dir;
}
static void test ()
{
	printf ("Full path: %s\n", SELFPATH);
	printf ("PREFIX is: %s\n", PREFIX);
	printf ("DATADIR is: %s\n", DATADIR);
	printf ("Data file : %s\n", BR_DATADIR ("/test/logo.png"));
	printf ("Conf file : %s\n\n", BR_SYSCONFDIR ("/test/configuration.txt"));

	libtest_start ();
}
Exemple #4
0
static void
update_image_preview (GtkFileChooser *chooser, GtkImage *image) {
    GdkPixbuf *image_pixbuf, *temp;
    static GdkPixbuf *emblem_pixbuf = NULL;
    gchar *filename;
    GdkPixmap *pixmap;
    gint width, height;

    if (emblem_pixbuf == NULL) {
	emblem_pixbuf = gdk_pixbuf_new_from_file (FYRE_DATADIR "/metadata-emblem.png", NULL);
	if (!emblem_pixbuf)
	    emblem_pixbuf = gdk_pixbuf_new_from_file (BR_DATADIR ("/fyre/metadata-emblem.png"), NULL);
    }

    filename = gtk_file_chooser_get_filename (chooser);
    if (filename == NULL) {
	gtk_file_chooser_set_preview_widget_active (chooser, FALSE);
	return;
    }

    image_pixbuf = gdk_pixbuf_new_from_file_at_size (filename, 112, 112, NULL);
    if (image_pixbuf == NULL) {
	gtk_file_chooser_set_preview_widget_active (chooser, FALSE);
	return;
    }
    width = gdk_pixbuf_get_width (image_pixbuf);
    height = gdk_pixbuf_get_height (image_pixbuf);

    pixmap = gdk_pixmap_new (GTK_WIDGET (image)->window, width + 16, height + 16, -1);
    gdk_draw_rectangle (pixmap, GTK_WIDGET (image)->style->bg_gc[GTK_STATE_NORMAL], TRUE, 0, 0, width + 16, height + 16);
    gdk_draw_pixbuf (pixmap, NULL, image_pixbuf, 0, 0, 0, 0, width - 1, height - 1, GDK_RGB_DITHER_NONE, 0, 0);

    temp = gdk_pixbuf_new_from_file (filename, NULL);
    if (temp) {
        if (gdk_pixbuf_get_option (temp, "tEXt::fyre_params"))
            gdk_draw_pixbuf (pixmap, NULL, emblem_pixbuf, 0, 0, width - 16, height - 16, 31, 31, GDK_RGB_DITHER_NONE, 0, 0);
        else if (gdk_pixbuf_get_option (temp, "tEXt::de_jong_params"))
            gdk_draw_pixbuf (pixmap, NULL, emblem_pixbuf, 0, 0, width - 16, height - 16, 31, 31, GDK_RGB_DITHER_NONE, 0, 0);
        gdk_pixbuf_unref (temp);
    }

    if (image_pixbuf)
	gdk_pixbuf_unref (image_pixbuf);

    gtk_image_set_from_pixmap (GTK_IMAGE (image), pixmap, NULL);
    gdk_pixmap_unref (pixmap);
    gtk_file_chooser_set_preview_widget_active (chooser, TRUE);
}
Exemple #5
0
static void animation_render_ui_init(AnimationRenderUi *self) {
    if (g_file_test (FYRE_DATADIR "/animation-render.glade", G_FILE_TEST_EXISTS))
        self->xml = glade_xml_new(FYRE_DATADIR "/animation-render.glade", NULL, NULL);
    if (!self->xml)
	self->xml = glade_xml_new(BR_DATADIR("/fyre/animation-render.glade"), NULL, NULL);

    fyre_set_icon_later(glade_xml_get_widget(self->xml, "window"));

    glade_xml_signal_connect_data(self->xml, "on_ok_clicked",                 G_CALLBACK(on_ok_clicked),                 self);
    glade_xml_signal_connect_data(self->xml, "on_cancel_clicked",             G_CALLBACK(on_cancel_clicked),             self);
    glade_xml_signal_connect_data(self->xml, "on_select_output_file_clicked", G_CALLBACK(on_select_output_file_clicked), self);
    glade_xml_signal_connect_data(self->xml, "on_delete_event",               G_CALLBACK(on_delete_event),               self);

    self->map = ITERATIVE_MAP(de_jong_new());
    self->frame.a = PARAMETER_HOLDER(de_jong_new());
    self->frame.b = PARAMETER_HOLDER(de_jong_new());
}
int main(int argc, char *argv[])
{
    if (argc < 4) {
        g_critical(L_("Expecting 3 arguments."));
        return 1;
    } else {
        GtkLabel *lbl;
        GladeXML *glade_xml;
        GError *err = NULL;
        GConfClient *gconf;
        gboolean keep_password;
        gchar *password;
        const gchar *gconf_keep_password;
        const gchar *gconf_password;
        gtk_init(&argc, &argv);
        gconf_password = g_getenv("PPP_GCONF_PASSWORD");
        gconf_keep_password = g_getenv("PPP_GCONF_KEEP_PASSWORD");
        if (!gconf_password || !gconf_keep_password) {
            g_critical(L_("Environment variables not set."));
            exit(1);
        }
        if (argv[3] != NULL) {
            output_file_descriptor = atoi(argv[3]);
        }
        gconf = gconf_client_get_default();
        keep_password = gconf_client_get_bool(gconf, gconf_keep_password, &err);

        /* user has password in database, spit it out */
        if (!err && keep_password) {
            password = gconf_client_get_string(gconf, gconf_password, &err);
            if (!err && password) {
                int len = strlen(password);

                if (write(output_file_descriptor, password, len) != len) {
                    g_warning(L_("could not write to file descriptor\n"));
                }
                /* all went fine, say bye */
                return 0;
            }
        }

        glade_init();
        glade_xml =
            glade_xml_new(BR_DATADIR("/gnome-ppx/ppp_get_password.glade"), NULL,
                          NULL);
        glade_xml_signal_autoconnect(glade_xml);

        password_entry =
            GTK_ENTRY(glade_xml_get_widget
                      (glade_xml, "gtk_entry_password"));
        lbl =
            GTK_LABEL(glade_xml_get_widget
                      (glade_xml, "msg_label"));
        g_object_unref(glade_xml);

        username = argv[1];
        server = argv[2];

        change_gtk_label(lbl);
        gtk_main();
    }

    return ret;
}
char * dictionary_get_data_dir(void)
{
#ifdef _WIN32
	HINSTANCE hInstance;
#endif
	char * data_dir = NULL;

	if (custom_data_dir != NULL) {
		data_dir = safe_strdup(custom_data_dir);
		return data_dir;
	}
	
#ifdef ENABLE_BINRELOC
	data_dir = safe_strdup (BR_DATADIR("/link-grammar"));
#elif defined(_WIN32)
	/* Dynamically locate library and return containing directory */
	hInstance = GetModuleHandle("link-grammar.dll");
	if (hInstance != NULL)
	{
		char dll_path[MAX_PATH];

		if (GetModuleFileName(hInstance, dll_path, MAX_PATH))
		{
#ifdef _DEBUG
			prt_error("Info: GetModuleFileName=%s", (dll_path ? dll_path : "NULL"));
#endif
			data_dir = path_get_dirname(dll_path);
		}
	}
	else
	{
		/* BHayes added else block for when link-grammar.dll is not found 11apr11 */
		/* This requests module handle for the current program */
		hInstance = GetModuleHandle(NULL);
		if (hInstance != NULL)
		{
			char prog_path16[MAX_PATH];
			printf("  found ModuleHandle for current program so try to get Filename for current program \n");
			if (GetModuleFileName(hInstance, prog_path16, MAX_PATH))
			{
				char * data_dir16 = NULL;
				// convert 2-byte to 1-byte encoding of prog_path
				char prog_path[MAX_PATH/2];
				int i, k;
				for (i = 0; i < MAX_PATH/2 ; i++)
				{
					k = i + i;
					if (prog_path16[k] == 0 )
					{
						prog_path[i] = 0;
						break; // found the string ending null char
					}
					// XXX this cannot possibly be correct for UTF-16 filepaths!! ?? FIXME
					prog_path[i] = prog_path16[k];
				}
#ifdef _DEBUG
				prt_error("Info: GetModuleFileName=%s", (prog_path ? prog_path : "NULL"));
#endif
				if (sizeof(TCHAR) == 1)
				    data_dir16 = path_get_dirname(prog_path16);
				else
				    data_dir16 = path_get_dirname(prog_path);
				if (data_dir16 != NULL)
				{
					printf("   found dir for current prog %s\n", data_dir16);
				}
				return data_dir16;  // return path of data directory here instead of below
			} else {
				printf("   FAIL GetModuleFileName for current program \n");
			}
		}
   }
#endif


	return data_dir;
}