Beispiel #1
0
/* This is an internally used function to create pixmaps. */
GdkPixbuf*
create_pixbuf                          (const gchar     *filename)
{
  gchar *pathname = NULL;
  GdkPixbuf *pixbuf;
  GError *error = NULL;

  if (!filename || !filename[0])
      return NULL;

  pathname = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_APP_PIXMAP,
                                        filename, TRUE, NULL);

  if (!pathname)
    {
      g_warning (_("Couldn't find pixmap file: %s"), filename);
      return NULL;
    }

  pixbuf = gdk_pixbuf_new_from_file (pathname, &error);
  if (!pixbuf)
    {
      fprintf (stderr, "Failed to load pixbuf file: %s: %s\n",
               pathname, error->message);
      g_error_free (error);
    }
  g_free (pathname);
  return pixbuf;
}
Beispiel #2
0
char *
gnc_gnome_locate_file (GnomeFileDomain domain, const char *name)
{
    char *fullname;

    g_return_val_if_fail(name, NULL);
    fullname = gnome_program_locate_file(gnucash_program,
                                         domain, name, TRUE, NULL);
    if (!fullname)
        PERR ("Could not locate file %s", name);
    return fullname;
}
static void
wireless_applet_about_cb (BonoboUIComponent *uic, WirelessApplet *applet)
{
	GdkPixbuf *pixbuf;
	char *file;

	const gchar *authors[] = {
		"Eskil Heyn Olsen <*****@*****.**>",
		"Bastien Nocera <*****@*****.**> (Gnome2 port)",
		NULL
	};

	const gchar *documenters[] = { 
                 "Sun GNOME Documentation Team <*****@*****.**>",
 	        NULL 
         };	

	const gchar *translator_credits = _("translator_credits");

	if (applet->about_dialog != NULL) {
		gtk_window_set_screen (GTK_WINDOW (applet->about_dialog),
				       gtk_widget_get_screen (GTK_WIDGET (&applet->base)));
		
		gtk_window_present (GTK_WINDOW (applet->about_dialog));
		return;
	}

	file = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_PIXMAP,
			"wireless-applet/wireless-applet.png", FALSE, NULL);
	pixbuf = gdk_pixbuf_new_from_file (file, NULL);
	g_free (file);

	applet->about_dialog = gnome_about_new (
			_("Wireless Link Monitor"),
			VERSION,
			_("(C) 2001, 2002 Free Software Foundation "),
			_("This utility shows the status of a wireless link."),
			authors,
			documenters,
			strcmp (translator_credits, "translator_credits") != 0 ? translator_credits : NULL,
			pixbuf);

	g_object_unref (pixbuf);

	g_signal_connect (applet->about_dialog, "destroy",
			  G_CALLBACK (gtk_widget_destroyed),
			  &applet->about_dialog);
 
	gtk_widget_show (applet->about_dialog);

	return;
}
static gboolean
wireless_applet_fill (WirelessApplet *applet)
{
	gnome_window_icon_set_default_from_file
		(ICONDIR"/wireless-applet/wireless-applet.png");

	glade_gnome_init ();
	glade_file = gnome_program_locate_file
		(NULL, GNOME_FILE_DOMAIN_DATADIR,
		 "wireless-applet/wireless-applet.glade", FALSE, NULL);

	wireless_applet_new (applet);
	gtk_widget_show (GTK_WIDGET (applet));

	return TRUE;
}
Beispiel #5
0
char *
gnc_gnome_locate_pixmap (const char *name)
{
    char *fullname;

    g_return_val_if_fail (name != NULL, NULL);

    fullname = gnome_program_locate_file (gnucash_program,
                                          GNOME_FILE_DOMAIN_APP_PIXMAP,
                                          name, TRUE, NULL);
    if (fullname == NULL)
    {
        PERR ("Could not locate pixmap/pixbuf file %s", name);
        return NULL;
    }

    return fullname;
}
static void
wireless_applet_load_theme (WirelessApplet *applet) {
	char *pixmapdir;
	char *pixmapname;
	int i;

	pixmapdir = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_PIXMAP,
			"wireless-applet/", FALSE, NULL);


	for (i = 0; i < PIX_NUMBER; i++)
	{
		pixmapname = g_build_filename (G_DIR_SEPARATOR_S,
				pixmapdir, pixmap_names[i], NULL);
		applet->pixmaps[i] = gdk_pixbuf_new_from_file (pixmapname, NULL);
		g_free (pixmapname);
	}

	g_free (pixmapdir);
}
Beispiel #7
0
/* This is an internally used function to create pixmaps. */
GtkWidget*
create_pixmap                          (GtkWidget       *widget,
                                        const gchar     *filename)
{
  GtkWidget *pixmap;
  gchar *pathname;

  if (!filename || !filename[0])
      return gtk_image_new ();

  pathname = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_APP_PIXMAP,
                                        filename, TRUE, NULL);
  if (!pathname)
    {
      g_warning (_("Couldn't find pixmap file: %s"), filename);
      return gtk_image_new ();
    }

  pixmap = gtk_image_new_from_file (pathname);
  g_free (pathname);
  return pixmap;
}
Beispiel #8
0
char *
ve_find_file (const char *filename, const GList *directories)
{
	char *s, *ss;
	const char *path;
	char **pathv;
	int i;

	s = ve_find_file_simple (filename, directories);
	if (s != NULL)
		return s;
	/* if the filename was NULL or absolute
	 * no further checks are made */
	if (filename == NULL ||
	    g_path_is_absolute (filename))
		return NULL;

	s = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_APP_DATADIR,
				       filename, TRUE, NULL);
	if (s != NULL)
		return s;

	ss = g_build_filename (g_get_prgname (), filename, NULL);
	s = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_APP_DATADIR,
				       ss, TRUE, NULL);
	g_free (ss);
	if (s != NULL)
		return s;

	s = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_DATADIR,
				       filename, TRUE, NULL);
	if (s != NULL)
		return s;

	ss = g_build_filename (g_get_prgname (), filename, NULL);
	s = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_DATADIR,
				       ss, TRUE, NULL);
	g_free (ss);
	if (s != NULL)
		return s;

	path = g_getenv ("GNOME_PATH");
	if (path != NULL) {
		pathv = g_strsplit (path, ":", 0);
		for (i = 0; pathv[i] != NULL; i++) {
			s = g_build_filename (pathv[i], "share", filename, NULL);
			if (g_access (s, F_OK) == 0) {
				g_strfreev (pathv);
				return s;
			}
			g_free (s);
			s = g_build_filename (pathv[i], "share",
					      g_get_prgname (),
					      filename, NULL);
			if (g_access (s, F_OK) == 0) {
				g_strfreev (pathv);
				return s;
			}
			g_free (s);
		}
		g_strfreev (pathv);
	}

	return NULL;
}
Beispiel #9
0
int
main(int argc, char *argv[]) {
    cam cam_object, *cam;
    Display *display;
    Screen *screen_num;
    gchar *poopoo = NULL;
    gchar *pixfilename = "camorama/camorama.png";
    gchar *filename;            //= "/usr/opt/garnome/share/camorama/camorama.glade";
    int x = -1, y = -1;
    gboolean buggery = FALSE;
    GtkWidget *button;
    GConfClient *gc;

    const struct poptOption popt_options[] = {
        {"version", 'V', POPT_ARG_NONE, &ver, 0,
         N_("show version and exit"), NULL},
        {"device", 'd', POPT_ARG_STRING, &poopoo, 0,
         N_("v4l device to use"), NULL},
        {"debug", 'D', POPT_ARG_NONE, &buggery, 0,
         N_("enable debugging code"), NULL},
        {"width", 'x', POPT_ARG_INT, &x, 0, N_("capture width"),
         NULL},
        {"height", 'y', POPT_ARG_INT, &y, 0, N_("capture height"),
         NULL},
        {"max", 'M', POPT_ARG_NONE, &max, 0,
         N_("maximum capture size"), NULL},
        {"min", 'm', POPT_ARG_NONE, &min, 0,
         N_("minimum capture size"), NULL},
        {"half", 'H', POPT_ARG_NONE, &half, 0,
         N_("middle capture size"), NULL},
        {"read", 'R', POPT_ARG_NONE, &use_read, 0,
         N_("use read() rather than mmap()"), NULL},
        POPT_TABLEEND
    };

    cam = &cam_object;
    /* set some default values */
    cam->frame_number = 0;
    cam->pic = NULL;
    cam->pixmap = NULL;
    cam->size = PICHALF;
    cam->video_dev = NULL;
    cam->read = FALSE;

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

    /* gnome_program_init  - initialize everything (gconf, threads, etc) */
    gnome_program_init (PACKAGE_NAME, PACKAGE_VERSION, LIBGNOMEUI_MODULE, argc, argv,
                        GNOME_PARAM_APP_DATADIR, PACKAGE_DATA_DIR,
                        GNOME_PARAM_POPT_TABLE, popt_options,
                        GNOME_PARAM_HUMAN_READABLE_NAME, _("camorama"), NULL);

    /* gtk is initialized now */
    camorama_stock_init();
    camorama_filters_init();

    cam->debug = buggery;

	cam->x = x;
	cam->y = y;
	glade_gnome_init ();
	glade_set_custom_handler (camorama_glade_handler,
				  cam);


    if (ver) {
        fprintf (stderr, _("\n\nCamorama version %s\n\n"), VERSION);
        exit (0);
    }
    if (max) {
        cam->size = PICMAX;
    }
    if (min) {
        cam->size = PICMIN;
    }
    if (half) {
        cam->size = PICHALF;
    }
    if (use_read) {
        printf ("gah!\n");
        cam->read = TRUE;
    }
    gc = gconf_client_get_default ();
    cam->gc = gc;

    gconf_client_add_dir (cam->gc, PATH, GCONF_CLIENT_PRELOAD_NONE, NULL);
    gconf_client_notify_add (cam->gc, KEY1, (void *) gconf_notify_func,
                             cam->pixdir, NULL, NULL);
    gconf_client_notify_add (cam->gc, KEY5, (void *) gconf_notify_func,
                             cam->rhost, NULL, NULL);
    gconf_client_notify_add (cam->gc, KEY2, (void *) gconf_notify_func,
                             cam->capturefile, NULL, NULL);
    gconf_client_notify_add (cam->gc, KEY3,
                             (void *) gconf_notify_func_int,
                             GINT_TO_POINTER (cam->savetype), NULL, NULL);
    gconf_client_notify_add (cam->gc, KEY4,
                             (void *) gconf_notify_func_bool,
                             &cam->timestamp, NULL, NULL);

    if (!poopoo) {
	gchar const* gconf_device = gconf_client_get_string(cam->gc, KEY_DEVICE, NULL);
	if(gconf_device) {
		cam->video_dev = g_strdup(gconf_device);
	} else {
		cam->video_dev = g_strdup ("/dev/video0");
	}
    } else {
        cam->video_dev = g_strdup (poopoo);
    }

    cam->pixdir = g_strdup (gconf_client_get_string (cam->gc, KEY1, NULL));
    cam->capturefile =
        g_strdup (gconf_client_get_string (cam->gc, KEY2, NULL));
    cam->rhost = g_strdup (gconf_client_get_string (cam->gc, KEY5, NULL));
    cam->rlogin = g_strdup (gconf_client_get_string (cam->gc, KEY6, NULL));
    cam->rpw = g_strdup (gconf_client_get_string (cam->gc, KEY7, NULL));
    cam->rpixdir = g_strdup (gconf_client_get_string (cam->gc, KEY8, NULL));
    cam->rcapturefile =
        g_strdup (gconf_client_get_string (cam->gc, KEY9, NULL));
    cam->savetype = gconf_client_get_int (cam->gc, KEY3, NULL);
    cam->rsavetype = gconf_client_get_int (cam->gc, KEY10, NULL);
    cam->ts_string =
        g_strdup (gconf_client_get_string (cam->gc, KEY16, NULL));
    cam->date_format = "%Y-%m-%d %H:%M:%S";
    cam->timestamp = gconf_client_get_bool (cam->gc, KEY4, NULL);
    cam->rtimestamp = gconf_client_get_bool (cam->gc, KEY11, NULL);

    cam->cap = gconf_client_get_bool (cam->gc, KEY12, NULL);
    cam->rcap = gconf_client_get_bool (cam->gc, KEY13, NULL);
    cam->timefn = gconf_client_get_bool (cam->gc, KEY14, NULL);
    cam->rtimefn = gconf_client_get_bool (cam->gc, KEY15, NULL);
    cam->usestring = gconf_client_get_bool (cam->gc, KEY18, NULL);
    cam->usedate = gconf_client_get_bool (cam->gc, KEY19, NULL);
    cam->acap = gconf_client_get_bool (cam->gc, KEY20, NULL);
    cam->timeout_interval = gconf_client_get_int (cam->gc, KEY21, NULL);
    cam->show_adjustments = gconf_client_get_bool (cam->gc, KEY22, NULL);
	 cam->show_effects = gconf_client_get_bool (cam->gc, KEY23, NULL);


    /* get desktop depth */
    display = (Display *) gdk_x11_get_default_xdisplay ();
    screen_num = xlib_rgb_get_screen ();
    gdk_pixbuf_xlib_init (display, 0);
    cam->desk_depth = xlib_rgb_get_depth ();

    cam->dev = open (cam->video_dev, O_RDWR);

    camera_cap (cam);
    get_win_info (cam);

    /* query/set window attributes */
    cam->vid_win.x = 0;
    cam->vid_win.y = 0;
    cam->vid_win.width = cam->x;
    cam->vid_win.height = cam->y;
    cam->vid_win.chromakey = 0;
    cam->vid_win.flags = 0;

    set_win_info (cam);
    get_win_info (cam);

    /* get picture attributes */
    get_pic_info (cam);
//	set_pic_info(cam);
    /* set_pic_info(cam); */
    cam->contrast = cam->vid_pic.contrast;
    cam->brightness = cam->vid_pic.brightness;
    cam->colour = cam->vid_pic.colour;
    cam->hue = cam->vid_pic.hue;
    cam->wb = cam->vid_pic.whiteness;
    cam->depth = cam->vid_pic.depth / 8;
    cam->pic_buf = malloc (cam->x * cam->y * cam->depth);
    cam->tmp =
        malloc (cam->vid_cap.maxwidth * cam->vid_cap.maxheight * cam->depth);
    //cam->tmp = NULL;
    /* set the buffer size */
    if (cam->read == FALSE) {
        set_buffer (cam);
    }
    //cam->read = FALSE;
    /* initialize cam and create the window */

    if (cam->read == FALSE) {
        pt2Function = timeout_func;
        init_cam (NULL, cam);
    } else {
        printf ("using read()\n");
        cam->pic =
            realloc (cam->pic,
                     (cam->vid_cap.maxwidth * cam->vid_cap.maxheight * 3));
        pt2Function = read_timeout_func;
    }
    cam->pixmap = gdk_pixmap_new (NULL, cam->x, cam->y, cam->desk_depth);

    filename =
        gnome_program_locate_file (NULL,
                                   GNOME_FILE_DOMAIN_APP_DATADIR,
                                   "camorama/camorama.glade", TRUE, NULL);
    if (filename == NULL) {
        error_dialog (_
                      ("Couldn't find the main interface file (camorama.glade)."));
        exit (1);
    }

    //pixfilename = gnome_program_locate_file(NULL, GNOME_FILE_DOMAIN_APP_DATADIR, "pixmaps/camorama.png", TRUE, NULL);
    //printf("pixfile = %s\n",pixfilename);
    //pixfilename);
    //printf("pixfile = %s\n",pixfilename);
    cam->xml = glade_xml_new (filename, NULL, NULL);
    /*eggtray */

    /*tray_icon = egg_tray_icon_new ("Our other cool tray icon");
     * button = gtk_button_new_with_label ("This is a another\ncool tray icon");
     * g_signal_connect (button, "clicked",
     * G_CALLBACK (second_button_pressed), tray_icon);
     * 
     * gtk_container_add (GTK_CONTAINER (tray_icon), button);
     * gtk_widget_show_all (GTK_WIDGET (tray_icon)); */
    load_interface (cam);

    cam->idle_id = gtk_idle_add ((GSourceFunc) pt2Function, (gpointer) cam);

    gtk_timeout_add (2000, (GSourceFunc) fps, cam->status);
    gtk_main ();
    return 0;
}