Beispiel #1
0
static int ui_main()
{
#ifndef _WIN32
	GList *icons = NULL;
	GdkPixbuf *icon = NULL;
	char *icon_path;
#endif
	if (current_smiley_theme == NULL) {
		smiley_theme_probe();
		if (smiley_themes) {
			struct smiley_theme *smile = smiley_themes->data;
			load_smiley_theme(smile->path, TRUE);
		}
	}

	gaim_gtk_blist_setup_sort_methods();

#ifndef _WIN32
	/* use the nice PNG icon for all the windows */
	icon_path = g_build_filename(DATADIR, "pixmaps", "gaim", "icons", "online.png", NULL);
	icon = gdk_pixbuf_new_from_file(icon_path, NULL);
	g_free(icon_path);
	if (icon) {
		icons = g_list_append(icons,icon);
		gtk_window_set_default_icon_list(icons);
		g_object_unref(G_OBJECT(icon));
		g_list_free(icons);
	} else {
		gaim_debug(GAIM_DEBUG_ERROR, "ui_main",
				   "Failed to load the default window icon!\n");
	}
#endif

	return 0;
}
Beispiel #2
0
static void
set_icons ()
{
	static gchar const *icon_infos[] = {
		"gitg16x16.png",
		"gitg22x22.png",
		"gitg24x24.png",
		"gitg32x32.png",
		"gitg48x48.png",
		"gitg64x64.png",
		"gitg128x128.png",
		NULL
	};

	int i;
	GList *icons = NULL;

	for (i = 0; icon_infos[i]; ++i)
	{
		gchar *filename = gitg_dirs_get_data_filename ("icons", icon_infos[i], NULL);
		GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
		g_free (filename);

		if (pixbuf)
		{
			icons = g_list_prepend (icons, pixbuf);
		}
	}

	gtk_window_set_default_icon_list (icons);

	g_list_foreach (icons, (GFunc)g_object_unref, NULL);
	g_list_free (icons);
}
Beispiel #3
0
static void
logo_setup ()
{
  GdkPixbuf *pixbuf = NULL;
  GError *error = NULL;
  GList *list = NULL;
  gchar *path = NULL;

  path = g_build_filename (DATAROOTDIR, "icons", "hicolor", "48x48", "apps", "utt-wubi.png", NULL);
  pixbuf = gdk_pixbuf_new_from_file (path, &error);
  if (!g_file_test (path, G_FILE_TEST_EXISTS)) {
    g_error (G_STRLOC ": %s doesn't exists.", path);
  }
  if (error) {
    g_error_free (error);
  }
  g_free (path);
  if (error) {
    g_error_free (error);
    return;
  }
  if (pixbuf) {
    list = g_list_append (list, pixbuf);
    /* LAZY: not beautifual code, learn scim_setup_ui.cpp:create_main_ui() please */
    gtk_window_set_default_icon_list (list);
    g_list_free (list);
    g_object_unref (pixbuf);
  }
}
Beispiel #4
0
int
main (int argc, char **argv)
{
  GList *list;
  GdkPixbuf *pixbuf;
  GError *err;

  gtk_init (&argc, &argv);

  err = NULL;
  pixbuf = gdk_pixbuf_new_from_file (METACITY_ICON_DIR"/metacity-window-demo.png",
                                     &err);
  if (pixbuf)
    {
      list = g_list_prepend (NULL, pixbuf);

      gtk_window_set_default_icon_list (list);
      g_list_free (list);
      g_object_unref (G_OBJECT (pixbuf));
    }
  else
    {
      g_printerr ("Could not load icon: %s\n", err->message);
      g_error_free (err);
    }

  do_appwindow (NULL, NULL, NULL);

  gtk_main ();

  return 0;
}
/**
 * gnome_window_icon_set_default_from_file_list:
 * @filenames: NULL terminated string array
 * 
 * Description: Wrapper around gtk_window_set_default_icon_list(),
 * which loads the icons in @filenames.
 **/
void
gnome_window_icon_set_default_from_file_list (const char **filenames)
{
	GList *list;

	g_return_if_fail (filenames != NULL);

	list = list_from_char_array (filenames);
	gtk_window_set_default_icon_list (list);
	free_list (list);
}
Beispiel #6
0
static void
setup_default_icon (void)
{
    GdkPixbuf *pixbuf;
    char *filename;
    GError *err;

    err = NULL;

    pixbuf = NULL;
    filename = demo_find_file ("gtk-logo-rgb.gif", &err);
    if (filename)
    {
        pixbuf = gdk_pixbuf_new_from_file (filename, &err);
        g_free (filename);
    }

    /* Ignoring this error (passing NULL instead of &err above)
     * would probably be reasonable for most apps.  We're just
     * showing off.
     */
    if (err)
    {
        GtkWidget *dialog;

        dialog = gtk_message_dialog_new (NULL, 0,
                                         GTK_MESSAGE_ERROR,
                                         GTK_BUTTONS_CLOSE,
                                         "Failed to read icon file: %s",
                                         err->message);
        g_error_free (err);

        g_signal_connect (dialog, "response",
                          G_CALLBACK (gtk_widget_destroy), NULL);
    }

    if (pixbuf)
    {
        GList *list;
        GdkPixbuf *transparent;

        /* The gtk-logo-rgb icon has a white background, make it transparent */
        transparent = gdk_pixbuf_add_alpha (pixbuf, TRUE, 0xff, 0xff, 0xff);

        list = NULL;
        list = g_list_append (list, transparent);
        gtk_window_set_default_icon_list (list);
        g_list_free (list);
        g_object_unref (pixbuf);
        g_object_unref (transparent);
    }
}
Beispiel #7
0
static int
ui_main(void)
{
#ifndef _WIN32
	GList *icons = NULL;
	GdkPixbuf *icon = NULL;
	char *icon_path;
	int i;
	struct {
		const char *dir;
		const char *filename;
	} icon_sizes[] = {
		{"16x16", "pidgin.png"},
		{"24x24", "pidgin.png"},
		{"32x32", "pidgin.png"},
		{"48x48", "pidgin.png"},
		{"scalable", "pidgin.svg"}
	};

#endif

	pidgin_themes_init();

	pidgin_blist_setup_sort_methods();

#ifndef _WIN32
	/* use the nice PNG icon for all the windows */
	for(i=0; i<G_N_ELEMENTS(icon_sizes); i++) {
		icon_path = g_build_filename(DATADIR, "icons", "hicolor", icon_sizes[i].dir, "apps", icon_sizes[i].filename, NULL);
		icon = pidgin_pixbuf_new_from_file(icon_path);
		g_free(icon_path);
		if (icon) {
			icons = g_list_append(icons,icon);
		} else {
			purple_debug_error("ui_main",
					"Failed to load the default window icon (%spx version)!\n", icon_sizes[i].dir);
		}
	}
	if(NULL == icons) {
		purple_debug_error("ui_main", "Unable to load any size of default window icon!\n");
	} else {
		gtk_window_set_default_icon_list(icons);

		g_list_foreach(icons, (GFunc)g_object_unref, NULL);
		g_list_free(icons);
	}
#endif

	return 0;
}
Beispiel #8
0
static void
setup_default_icon()
{
  GdkPixbuf *pixbuf;

  pixbuf = gdk_pixbuf_new_from_file(UIM_PIXMAPSDIR "/uim-dict.png", NULL);
  if (pixbuf) {
    GList *list;

    list = NULL;
    list = g_list_append(list, pixbuf);
    gtk_window_set_default_icon_list(list);
    g_list_free(list);
    g_object_unref(pixbuf);
  }
}
Beispiel #9
0
/* Set the application icons. */
void set_icons(void) {
#include "app_icons.h"

	GList* icons = NULL;

	/* Setup the application icons. */
	icons = g_list_append(icons,
			gdk_pixbuf_new_from_inline(-1, icon_16x16_inline, FALSE, NULL));
	icons = g_list_append(icons,
			gdk_pixbuf_new_from_inline(-1, icon_24x24_inline, FALSE, NULL));
	icons = g_list_append(icons,
			gdk_pixbuf_new_from_inline(-1, icon_32x32_inline, FALSE, NULL));
	icons = g_list_append(icons,
			gdk_pixbuf_new_from_inline(-1, icon_36x36_inline, FALSE, NULL));
	gtk_window_set_default_icon_list(icons);
}
Beispiel #10
0
 static void load_icon(void)
 {
	GdkPixbuf 	*pix = NULL;
 	gchar		*filename;

	if(program_logo && !g_strcasecmp(program_logo,"none"))
		return;

	if(program_logo)
		filename = g_strdup(program_logo);
	else
		filename = g_build_filename(program_data,PROGRAM_LOGO,NULL);

	if(!g_file_test(filename,G_FILE_TEST_IS_REGULAR))
	{
		g_free(filename);
		return;
	}

	pix = gdk_pixbuf_new_from_file(filename, NULL);
	 
	if(pix)
	{
		static const	size[] = { 16, 32, 48, 64, 128, 256 };
		GList 			*icon = NULL;
		int				 f;

		gtk_window_set_default_icon(pix);
		g_object_set_data_full(G_OBJECT(topwindow),"logo",pix,g_object_unref);

#if defined( HAVE_IGEMAC )
		gtk_osxapplication_set_dock_icon_pixbuf(osxapp,pix);
#endif

		for(f=0;f<G_N_ELEMENTS(size);f++)
		{
			pix = gdk_pixbuf_new_from_file_at_size(filename,size[f],size[f],NULL);
			if(pix)
				icon = g_list_append(icon, pix);
		}

		gtk_window_set_default_icon_list(icon);

	}

 	g_free(filename);
 }
Beispiel #11
0
static void icons_setup(AWeatherGui *self)
{
	gchar *icons[] = {
		ICONDIR "/hicolor/16x16/apps/aweather.png",
		ICONDIR "/hicolor/22x22/apps/aweather.png",
		ICONDIR "/hicolor/24x24/apps/aweather.png",
		ICONDIR "/hicolor/32x32/apps/aweather.png",
		ICONDIR "/hicolor/48x48/apps/aweather.png",
		ICONDIR "/hicolor/scalable/apps/aweather.svg",
	};
	GList *list = NULL;
	for (int i = 0; i < G_N_ELEMENTS(icons); i++) {
		GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(icons[i], NULL);
		if (!pixbuf)
			g_warning("AWeatherGui: icons_setup - %s failed", icons[i]);
		list = g_list_prepend(list, pixbuf);
	}
	gtk_window_set_default_icon_list(list);
	g_list_free(list);
}
Beispiel #12
0
/**
 * Initialize the application icons for the program.  These icons are
 * the ones shown by the window manager within title bars and pagers.
 * The last icon listed in the array will be displayed in the About
 * dialog.
 *
 * @param top Toplevel whose icon to set.  All child windows will
 * inherit these icons.
 */
static void init_icons(toplevel_t * top)
{
	static const char *icon_names[] = { "sediffx-small.png", "sediffx.png" };
	GdkPixbuf *icon;
	char *path;
	GList *icon_list = NULL;
	size_t i;
	for (i = 0; i < sizeof(icon_names) / sizeof(icon_names[0]); i++) {
		if ((path = apol_file_find_path(icon_names[i])) == NULL) {
			continue;
		}
		icon = gdk_pixbuf_new_from_file(path, NULL);
		free(path);
		if (icon == NULL) {
			continue;
		}
		icon_list = g_list_append(icon_list, icon);
	}
	gtk_window_set_default_icon_list(icon_list);
	gtk_window_set_icon_list(top->w, icon_list);
}
Beispiel #13
0
void ctk_main(ParsedAttribute *p,
              ConfigProperties *conf,
              CtrlHandles *h,
              const char *page)
{
    int i, has_nv_control = FALSE;
    GList *list = NULL;
    GtkWidget *window;

    list = g_list_append (list, gdk_pixbuf_from_pixdata(&nvidia_icon_pixdata, TRUE, NULL));
    gtk_window_set_default_icon_list(list);
    window = ctk_window_new(p, conf, h);

    for (i = 0; i < h->targets[X_SCREEN_TARGET].n; i++) {
        if (h->targets[X_SCREEN_TARGET].t[i].h) {
            has_nv_control = TRUE;
            break;
        }
    }
    
    if (!has_nv_control) {
        GtkWidget *dlg;
        dlg = gtk_message_dialog_new (NULL,
                                      GTK_DIALOG_MODAL,
                                      GTK_MESSAGE_WARNING,
                                      GTK_BUTTONS_OK,
                                      "You do not appear to be using the NVIDIA "
                                      "X driver.  Please edit your X configuration "
                                      "file (just run `nvidia-xconfig` "
                                      "as root), and restart the X server.");
        gtk_dialog_run(GTK_DIALOG(dlg));
        gtk_widget_destroy (dlg);
    }

    ctk_window_set_active_page(CTK_WINDOW(window), page);

    gtk_main();
}
Beispiel #14
0
void
icons_initialize(void) {
	GtkIconFactory *factory;
	GdkPixbuf *goat;
	GList *l;

	factory = gtk_icon_factory_new();
	goat = add(factory, logjam_goat, "logjam-goat");
	add(factory, logjam_pencil, "logjam-server");
	add(factory, logjam_ljuser, "logjam-ljuser");
	add(factory, logjam_ljcomm, "logjam-ljcomm");
	add(factory, logjam_twuser, "logjam-twuser");
	add(factory, logjam_protected, "logjam-protected");
	add(factory, logjam_private, "logjam-private");
	add(factory, logjam_blogger, "logjam-blogger");
	gtk_icon_factory_add_default(factory);

	l = g_list_append(NULL, goat);
	gtk_window_set_default_icon_list(l);
	g_list_free(l);

	gtk_stock_add_static(logjam_stock_items, G_N_ELEMENTS(logjam_stock_items));
}
Beispiel #15
0
int CUIHandler::CreateMainWnd()
{
    GtkWidget* menubar;
    GtkWidget* filemenu, *helpmenu;
    GtkWidget* file, *quit;
    GtkWidget* help, *about;
    GtkWidget* vbox, *hbox;
    GtkWidget* align;
    GtkToolItem* toolitem;
    GtkWidget* frame;
    GtkWidget* status_menu;
    GtkWidget* status_menu_item;
    GtkWidget *hseparator;

    GtkWidget *statusbarHBox;
    GtkWidget *statusbarFrameConnection;
    GtkWidget *statusbarAlignmentConnection;
    GtkWidget *statusbarHBoxConnection;
    GtkWidget *statusbarFrameFps;
    GtkWidget *statusbarAlignmentFps;
    GtkWidget *statusbarFrameResolution;
    GtkWidget *statusbarAlignmentResolution;

    // set up tray icon
    trayIcon = gtk_status_icon_new_from_pixbuf(disconnectedTrayIcon);
    gtk_status_icon_set_tooltip(trayIcon, TRAY_TOOLTIP_DISCONNECTED);
    gtk_status_icon_set_visible(trayIcon, TRUE);
    g_signal_connect(G_OBJECT(trayIcon), "popup-menu", G_CALLBACK(status_popup), NULL);
    g_signal_connect(G_OBJECT(trayIcon), "activate", G_CALLBACK(status_activate), NULL);

    // set up main mainWindow
    mainWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    g_signal_connect(G_OBJECT(mainWindow), "delete_event", G_CALLBACK(delete_event), NULL);
    g_signal_connect(G_OBJECT(mainWindow), "destroy", G_CALLBACK(destroy), NULL);
    g_signal_connect(G_OBJECT(mainWindow), "window_state_event", G_CALLBACK(track_minimize), NULL);

    gtk_window_set_title(GTK_WINDOW(mainWindow), SMARTCAM_WND_TITLE);
    gtk_container_set_border_width(GTK_CONTAINER(mainWindow), 1);
    gtk_window_set_resizable(GTK_WINDOW(mainWindow), FALSE);
    gtk_widget_set_size_request(mainWindow, MAIN_WND_WIDTH, MAIN_WND_HEIGHT);
    gtk_window_set_position(GTK_WINDOW(mainWindow), GTK_WIN_POS_NONE);
    gtk_window_set_gravity(GTK_WINDOW (mainWindow), GDK_GRAVITY_CENTER);

    gtk_window_set_default_icon(connectedTrayIcon);

    GdkPixbuf* icon;
    GList* icon_list = NULL;
    icon = gdk_pixbuf_new_from_file(DATADIR "/icons/hicolor/16x16/apps/smartcam.png", NULL);
    icon_list = g_list_append(icon_list, icon);
    icon = gdk_pixbuf_new_from_file(DATADIR "/icons/hicolor/22x22/apps/smartcam.png", NULL);
    icon_list = g_list_append(icon_list, icon);
    icon = gdk_pixbuf_new_from_file(DATADIR "/icons/hicolor/24x24/apps/smartcam.png", NULL);
    icon_list = g_list_append(icon_list, icon);
    icon = gdk_pixbuf_new_from_file(DATADIR "/icons/hicolor/32x32/apps/smartcam.png", NULL);
    icon_list = g_list_append(icon_list, icon);
    icon = gdk_pixbuf_new_from_file(DATADIR "/icons/hicolor/48x48/apps/smartcam.png", NULL);
    icon_list = g_list_append(icon_list, icon);

    gtk_window_set_default_icon_list(icon_list);

    g_list_foreach(icon_list, (GFunc)g_object_unref, NULL );
    g_list_free(icon_list);

    // create menubar
    menubar = gtk_menu_bar_new();

    filemenu = gtk_menu_new();
    file = gtk_menu_item_new_with_mnemonic("_File");
    miSettings = gtk_image_menu_item_new_with_label("Settings");
    gtk_image_menu_item_set_image(
        GTK_IMAGE_MENU_ITEM(miSettings),
        gtk_image_new_from_stock(GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_MENU));
    g_signal_connect(G_OBJECT(miSettings), "activate", G_CALLBACK(OnSettingsClicked), (gpointer) NULL);
    quit = gtk_image_menu_item_new_from_stock(GTK_STOCK_QUIT, NULL);
    g_signal_connect(G_OBJECT(quit), "activate", G_CALLBACK(destroy), NULL);

    gtk_menu_shell_append(GTK_MENU_SHELL(menubar), file);
    gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), filemenu);
    gtk_menu_shell_append(GTK_MENU_SHELL(filemenu), miSettings);
    gtk_menu_shell_append(GTK_MENU_SHELL(filemenu), quit);

    helpmenu = gtk_menu_new();
    help = gtk_menu_item_new_with_mnemonic("_Help");
    about = gtk_image_menu_item_new_from_stock(GTK_STOCK_ABOUT, NULL);
    g_signal_connect(about, "activate", G_CALLBACK(show_about_dialog), NULL);

    gtk_menu_shell_append(GTK_MENU_SHELL(menubar), help);
    gtk_menu_item_set_submenu(GTK_MENU_ITEM(help), helpmenu);
    gtk_menu_shell_append(GTK_MENU_SHELL(helpmenu), about);

    // create toolbar
    toolbar = gtk_toolbar_new();
    gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS);
    gtk_toolbar_set_icon_size(GTK_TOOLBAR(toolbar), GTK_ICON_SIZE_MENU);
    g_object_set(G_OBJECT(toolbar), "can-focus", FALSE, NULL);

    tbSettings = gtk_tool_button_new_from_stock(GTK_STOCK_PREFERENCES);
    g_signal_connect(G_OBJECT(tbSettings), "clicked", G_CALLBACK(OnSettingsClicked), NULL);
    g_object_set(G_OBJECT(tbSettings), "tooltip-text", "Settings", NULL);
    g_object_set(G_OBJECT(tbSettings), "can-focus", FALSE, NULL);
    gtk_toolbar_insert(GTK_TOOLBAR(toolbar), tbSettings, 0);

    tbDisconnect = gtk_tool_button_new_from_stock(GTK_STOCK_DISCONNECT);
    g_signal_connect(G_OBJECT(tbDisconnect), "clicked", G_CALLBACK(OnDisconnectClicked), NULL);
    g_object_set(G_OBJECT(tbDisconnect), "tooltip-text", "Disconnect", NULL);
    g_object_set(G_OBJECT(tbDisconnect), "can-focus", FALSE, NULL);
    g_object_set(G_OBJECT(tbDisconnect), "sensitive", FALSE, NULL); // disable disconnect
    gtk_toolbar_insert(GTK_TOOLBAR(toolbar), tbDisconnect, 1);

    // create preview frame
    vbox = gtk_vbox_new(FALSE, 1);
    gtk_container_set_border_width(GTK_CONTAINER(vbox), 1);
    gtk_container_add(GTK_CONTAINER(mainWindow), vbox);

    align = gtk_alignment_new(0.5, 0.5, 0, 0);

    frame = gtk_frame_new(NULL);
    gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_OUT);

    image = gtk_image_new_from_pixbuf(logoIcon);

    gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, FALSE, 0);
    gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0);
    gtk_box_pack_start(GTK_BOX(vbox), align, TRUE, TRUE, 0);

    gtk_container_add(GTK_CONTAINER(align), frame);
    gtk_container_add(GTK_CONTAINER(frame), image);

    // set up status bar
    hseparator = gtk_hseparator_new ();
    gtk_box_pack_start (GTK_BOX (vbox), hseparator, FALSE, FALSE, 0);

    statusbarHBox = gtk_hbox_new (FALSE, 0);
    gtk_box_pack_start (GTK_BOX (vbox), statusbarHBox, FALSE, FALSE, 0);

    statusbarFrameConnection = gtk_frame_new (NULL);
    gtk_box_pack_start (GTK_BOX (statusbarHBox), statusbarFrameConnection, TRUE, TRUE, 0);
    gtk_widget_set_size_request (statusbarFrameConnection, 55, 25);
    gtk_frame_set_label_align (GTK_FRAME (statusbarFrameConnection), 0, 0);
    gtk_frame_set_shadow_type (GTK_FRAME (statusbarFrameConnection), GTK_SHADOW_IN);

    statusbarAlignmentConnection = gtk_alignment_new (0, 0.5, 1, 1);
    gtk_container_add (GTK_CONTAINER (statusbarFrameConnection), statusbarAlignmentConnection);
    gtk_alignment_set_padding (GTK_ALIGNMENT (statusbarAlignmentConnection), 0, 0, 3, 0);

    statusbarHBoxConnection = gtk_hbox_new (FALSE, 0);
    gtk_container_add (GTK_CONTAINER (statusbarAlignmentConnection), statusbarHBoxConnection);

    if(pSmartEngine->GetSettings().connectionType == CONN_BLUETOOTH)
    {
        statusbarImageConnection = gtk_image_new_from_pixbuf(btStatusIcon);
    }
    else
    {
        statusbarImageConnection = gtk_image_new_from_pixbuf(inetStatusIcon);
    }
    gtk_box_pack_start (GTK_BOX (statusbarHBoxConnection), statusbarImageConnection, FALSE, FALSE, 0);
    gtk_misc_set_alignment (GTK_MISC (statusbarImageConnection), 0, 0.5);

    statusbarLabelConnection = gtk_label_new ("Disconnected");
    gtk_box_pack_start (GTK_BOX (statusbarHBoxConnection), statusbarLabelConnection, TRUE, TRUE, 0);
    gtk_misc_set_alignment (GTK_MISC (statusbarLabelConnection), 0, 0.5);

    statusbarFrameFps = gtk_frame_new (NULL);
    gtk_box_pack_start (GTK_BOX (statusbarHBox), statusbarFrameFps, TRUE, TRUE, 0);
    gtk_widget_set_size_request (statusbarFrameFps, 17, 25);
    gtk_frame_set_shadow_type (GTK_FRAME (statusbarFrameFps), GTK_SHADOW_IN);

    statusbarAlignmentFps = gtk_alignment_new (0, 0.5, 1, 1);
    gtk_container_add (GTK_CONTAINER (statusbarFrameFps), statusbarAlignmentFps);
    gtk_alignment_set_padding (GTK_ALIGNMENT (statusbarAlignmentFps), 0, 0, 3, 0);

    statusbarLabelFps = gtk_label_new (CUIHandler::STATUS_LABEL_FPS);
    gtk_container_add (GTK_CONTAINER (statusbarAlignmentFps), statusbarLabelFps);
    gtk_misc_set_alignment (GTK_MISC (statusbarLabelFps), 0, 0.5);

    statusbarFrameResolution = gtk_frame_new (NULL);
    gtk_box_pack_start (GTK_BOX (statusbarHBox), statusbarFrameResolution, TRUE, TRUE, 0);
    gtk_widget_set_size_request (statusbarFrameResolution, 92, 25);
    gtk_frame_set_shadow_type (GTK_FRAME (statusbarFrameResolution), GTK_SHADOW_IN);

    statusbarAlignmentResolution = gtk_alignment_new (0, 0.5, 1, 1);
    gtk_container_add (GTK_CONTAINER (statusbarFrameResolution), statusbarAlignmentResolution);
    gtk_alignment_set_padding (GTK_ALIGNMENT (statusbarAlignmentResolution), 0, 0, 3, 0);

    statusbarLabelResolution = gtk_label_new (CUIHandler::STATUS_LABEL_RESOLUTION);
    gtk_container_add (GTK_CONTAINER (statusbarAlignmentResolution), statusbarLabelResolution);
    gtk_misc_set_alignment (GTK_MISC (statusbarLabelResolution), 0, 0.5);

    gtk_widget_show_all(mainWindow);

    return 0;
}
Beispiel #16
0
/**
 * gens_window_create(): Create the Gens window.
 */
void gens_window_create(void)
{
	// Create the icon for the Gens window, and set it as default for all windows.
	// TODO: Move this to a common C file.
	
	// TODO: Use the standard icon directory layout.
	GList *gens_icon_list = NULL;
	static const char* const gens_icon_filename[3] =
	{
		GENS_DATADIR "/gensgs_48x48.png",
		GENS_DATADIR "/gensgs_32x32.png",
		GENS_DATADIR "/gensgs_16x16.png"
	};
	
	// Add the icons.
	for (int i = 0; i < 3; i++)
	{
		if (!g_file_test(gens_icon_filename[i], G_FILE_TEST_EXISTS))
		{
			// File not found.
			LOG_MSG(gens, LOG_MSG_LEVEL_WARNING,
				"Image file not found: %s",
				gens_icon_filename[i]);
			continue;
		}
		
		// Load the icon.
		GError *error = NULL;
		GdkPixbuf *gens_icon = gdk_pixbuf_new_from_file(gens_icon_filename[i], &error);
		if (!gens_icon)
		{
			LOG_MSG(gens, LOG_MSG_LEVEL_WARNING,
				"Error loading image file %s: %s",
				gens_icon_filename[i], error->message);
			g_error_free(error);
			continue;
		}
		
		// Add the icon to the icon list.
		gens_icon_list = g_list_append(gens_icon_list, gens_icon);
	}
	
	// Set the icon list as the default icon list.
	gtk_window_set_default_icon_list(gens_icon_list);
	
	// Free the icon list.
	g_list_free(gens_icon_list);
	
	// Create the Gens window.
	gens_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_resizable(GTK_WINDOW(gens_window), FALSE);
	gtk_container_set_border_width(GTK_CONTAINER(gens_window), 0);
	gtk_window_set_position(GTK_WINDOW(gens_window), GTK_WIN_POS_CENTER);
	gtk_window_set_title(GTK_WINDOW(gens_window), "Gens");
	
	// Create the main VBox.
	gens_vbox_main = gtk_vbox_new(FALSE, 0);
	gtk_widget_show(gens_vbox_main);
	gtk_container_add(GTK_CONTAINER(gens_window), gens_vbox_main);
	
	// Create the HBox for the SDL "socket".
	GtkWidget *hboxSocket = gtk_hbox_new(FALSE, 0);
	gtk_widget_show(hboxSocket);
	gtk_box_pack_end(GTK_BOX(gens_vbox_main), hboxSocket, TRUE, TRUE, 0);
	
	// Create the SDL "socket".
	gens_window_sdlsock = gtk_event_box_new();
	gtk_box_pack_start(GTK_BOX(hboxSocket), gens_window_sdlsock, TRUE, FALSE, 0);
	
	// Set the background color of the SDL "socket" to black.
	GdkColor bg = {0, 0, 0, 0};
	gtk_widget_modify_bg(gens_window_sdlsock, GTK_STATE_NORMAL, &bg);
	
	// Callbacks for if the window is closed.
	g_signal_connect((gpointer)gens_window, "delete-event",
			 G_CALLBACK(on_gens_window_close), NULL);
	g_signal_connect((gpointer)gens_window, "destroy-event",
			 G_CALLBACK(on_gens_window_close), NULL);
	
	// Callbacks for Auto Pause.
	g_signal_connect((gpointer)gens_window, "focus-in-event",
			 G_CALLBACK(gens_window_focus_in), NULL);
	g_signal_connect((gpointer)gens_window, "focus-out-event",
			 G_CALLBACK(gens_window_focus_out), NULL);
	
	// Enable drag & drop for ROM loading.
	static const GtkTargetEntry target_list[] =
	{
		{"text/plain", 0, 0},
		{"text/uri-list", 0, 1},
	};
	
	gtk_drag_dest_set
	(
		gens_window_sdlsock,
		(GtkDestDefaults)(GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT),
		target_list,
		G_N_ELEMENTS(target_list),
		(GdkDragAction)(GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_PRIVATE | GDK_ACTION_ASK)
	);
	
	// Set drag & drop callbacks.
	g_signal_connect(gens_window_sdlsock, "drag-data-received",
			 G_CALLBACK(gens_window_drag_data_received), NULL);
	g_signal_connect(gens_window_sdlsock, "drag-drop",
			 G_CALLBACK(gens_window_drag_drop), NULL);
	
	// Expose event.
	g_signal_connect(gens_window_sdlsock, "expose-event",
			 G_CALLBACK(gens_window_sdlsock_expose), NULL);
	
	// Button Press event.
	g_signal_connect(gens_window_sdlsock, "button-press-event",
			 G_CALLBACK(gens_window_sdlsock_button_press), NULL);
	
	// Window State event.
	g_signal_connect(gens_window, "window-state-event",
			 G_CALLBACK(gens_window_window_state_event), NULL);
	
	// Window is active.
	Settings.Active = 1;
}
Beispiel #17
0
void
gnc_gnome_init (int argc, char **argv, const char * version)
{
    GError *error = NULL;
    gchar *prefix = gnc_path_get_prefix ();
    gchar *pkgsysconfdir = gnc_path_get_pkgsysconfdir ();
    gchar *pkgdatadir = gnc_path_get_pkgdatadir ();
    gchar *pkglibdir = gnc_path_get_pkglibdir ();
    gboolean installation_ok = TRUE;

    /* Verify all the various directory before proceeding */
    if (!g_file_test(pkgdatadir, G_FILE_TEST_IS_DIR))
    {
        g_critical("The installation data directory \"%s\" was not found. Your installation is incomplete and cannot be run.", pkgdatadir);
        installation_ok = FALSE;
    }
    if (!g_file_test(pkglibdir, G_FILE_TEST_IS_DIR))
    {
        g_critical("The installation lib directory \"%s\" was not found. Your installation is incomplete and cannot be run.", pkglibdir);
        installation_ok = FALSE;
    }

    if (!g_file_test(pkgsysconfdir, G_FILE_TEST_IS_DIR))
    {
        g_critical("The installation sysconf directory \"%s\" was not found. Your installation is incomplete and cannot be run.", pkgsysconfdir);
        installation_ok = FALSE;
    }

    gnc_gtk_add_rc_file();
    gnucash_program = gnome_program_init(
                          "gnucash", version, LIBGNOMEUI_MODULE,
                          argc, argv,
                          GNOME_PARAM_APP_PREFIX, prefix,
                          GNOME_PARAM_APP_SYSCONFDIR, pkgsysconfdir,
                          GNOME_PARAM_APP_DATADIR, pkgdatadir,
                          GNOME_PARAM_APP_LIBDIR, pkglibdir,
                          GNOME_PARAM_NONE);
    if (!installation_ok)
    {
        /* The following string does not need translation because if
         * it shows up, the program is unusable anyway. */
        gnc_error_dialog(NULL, "The installation directories were not found.\n\ndatadir=%s\nlibdir=%s\nsysconfdir=%s\n\nYour installation is incomplete and cannot be run.",
                         pkgdatadir, pkglibdir, pkgsysconfdir);
        /* gnc_error_dialog must not be called before gnome_program_init. */
    }

    g_free (prefix);
    g_free (pkgsysconfdir);
    g_free (pkgdatadir);
    g_free (pkglibdir);

    /* Did the installation directory check fail? Terminate
     * immediately because it will inevitably fail in the glade file
     * lookup. */
    if (!installation_ok)
    {
        /* No correct installation? Shut down immediately. */
        exit(-1);
    }

#ifdef G_OS_WIN32
    /* workaround for bug #421792 */
    xmlCleanupInputCallbacks();
#endif

    /* initialization required for gtkhtml (is it also needed for webkit?) */
    gtk_widget_set_default_colormap (gdk_rgb_get_colormap ());

    /* use custom icon */
    {
        int idx;
        char *icon_filenames[] = {"gnucash-icon-16x16.png",
                                  "gnucash-icon-32x32.png",
                                  "gnucash-icon-48x48.png",
                                  NULL
                                 };
        GList *icons = NULL;
        char *fullname, *name_iter;

        for (idx = 0; icon_filenames[idx] != NULL; idx++)
        {
            GdkPixbuf *buf = NULL;

            fullname = gnc_gnome_locate_pixmap(icon_filenames[idx]);
            if (fullname == NULL)
            {
                g_warning("couldn't find icon file [%s]", icon_filenames[idx]);
                continue;
            }

            buf = gnc_gnome_get_gdkpixbuf(fullname);
            if (buf == NULL)
            {
                g_warning("error loading image from [%s]", fullname);
                g_free(fullname);
                continue;
            }
            g_free(fullname);
            icons = g_list_append(icons, buf);
        }

        gtk_window_set_default_icon_list(icons);
        g_list_foreach(icons, (GFunc)g_object_unref, NULL);
        g_list_free(icons);
    }

    assistant_gconf_install_check_schemas();

    return;
}
Beispiel #18
0
Datei: gui.c Projekt: wareya/gzrt
/* GUI init */
void gzrt_gui_init ( int argc, char **argv )
{
    /* Set up icons */
    N64Rom *ctx = NULL;
    GList *list = NULL;
    char *icons[] =
    {
        GZRT_GUI_ICON_1, GZRT_GUI_ICON_2,
        GZRT_GUI_ICON_3, GZRT_GUI_ICON_4,
        NULL
    }, i;
    
    for( i = 0; icons[i]; i++ )
    {
        GdkPixbuf *g = gdk_pixbuf_new_from_file(icons[i], NULL);
        list = g_list_append( list, g );
    }
    
    /* Set default icon */
    gtk_window_set_default_icon_list( list );
    
    /* Show debug window */
    #ifdef GZRT_DEBUG
     gzrt_gui_debug_create();
    #endif
    
    /* Load configuration */
    gzrt_config_load();
    
    /* Load plugins */
    gzrt_load_plugins();
    
    /* Find a file to open */
    int opened = FALSE;
    
    /* Is the default file set? */
    if( GZRTConfig.default_rom )
    {
        /* Yep, try it */
        if( (ctx = n64rom_load(GZRTConfig.default_rom)) )
        {
            
            /* Goes */
            if( !gzrt_wmain_create_new( ctx ) )
                
                /* File selection */
                gzrt_wfilesel_show();
            
            else
                
                opened = TRUE;
        }
        else 
            gzrt_notice( "Notice!", "There was a default ROM specified, but it wasn't found.\nPlease fix this!" );
    }
    
    /* Try command line arguments also */
    if( argc > 1 )
        for( i = 1; i < argc; i++ )
        {
            if( !(ctx = n64rom_load( argv[i] )) )
            {
                char buffer[128];
                sprintf(buffer, "Failed to open \"%s\".", argv[i]);
                gzrt_notice( "Error", buffer );
            }
            else if( gzrt_wmain_create_new( ctx ) )
                    opened = TRUE;
        }
    
    /* Show splash? */
    if( !opened )
        gzrt_wsplash_init( gzrt_wfilesel_show );
}
Beispiel #19
0
int gnoclConfigureCmd (
	ClientData data,
	Tcl_Interp *interp,
	int objc,
	Tcl_Obj * const objv[] )
{
	GnoclOption options[] =
	{
		{ "-tooltip", GNOCL_BOOL, NULL },
		{ "-defaultIcon", GNOCL_OBJ, NULL },
		{ NULL }
	};
	const int tooltipIdx     = 0;
	const int defaultIconIdx = 1;

	int ret = TCL_ERROR;

	if ( gnoclParseOptions ( interp, objc, objv, options ) != TCL_OK )
		goto cleanExit;

	if ( options[defaultIconIdx].status == GNOCL_STATUS_CHANGED )
	{
		GnoclStringType type = gnoclGetStringType (
								   options[defaultIconIdx].val.obj );

		switch ( type )
		{
			case GNOCL_STR_EMPTY:
				gtk_window_set_default_icon_list ( NULL );
				break;
			case GNOCL_STR_FILE:
				{
					GdkPixbuf *pix = gnoclPixbufFromObj ( interp,
														  options + defaultIconIdx );
					GList *list = NULL;

					if ( pix == NULL )
						goto cleanExit;

					list = g_list_append ( list, pix );

					gtk_window_set_default_icon_list ( list );

					g_list_free ( list );
				}

				break;
			default:
				Tcl_AppendResult ( interp, "Unknown type for \"",
								   Tcl_GetString ( options[defaultIconIdx].val.obj ),
								   "\" must be of type FILE (%/) or empty", NULL );
				goto cleanExit;
		}
	}

	if ( options[tooltipIdx].status == GNOCL_STATUS_CHANGED )
	{
		if ( options[tooltipIdx].val.b )
			gtk_tooltips_enable ( gnoclGetTooltips() );
		else
			gtk_tooltips_disable ( gnoclGetTooltips() );
	}

	ret = TCL_OK;

cleanExit:
	gnoclClearOptions ( options );
	return ret;
}
Beispiel #20
0
void
gnc_gnome_init (int argc, char **argv, const char * version)
{
    GError *error = NULL;
    gchar *prefix = gnc_path_get_prefix ();
    gchar *pkgsysconfdir = gnc_path_get_pkgsysconfdir ();
    gchar *pkgdatadir = gnc_path_get_pkgdatadir ();
    gchar *pkglibdir = gnc_path_get_pkglibdir ();

    gnc_gtk_add_rc_file();
    gnucash_program = gnome_program_init(
                          "gnucash", version, LIBGNOMEUI_MODULE,
                          argc, argv,
                          GNOME_PARAM_APP_PREFIX, prefix,
                          GNOME_PARAM_APP_SYSCONFDIR, pkgsysconfdir,
                          GNOME_PARAM_APP_DATADIR, pkgdatadir,
                          GNOME_PARAM_APP_LIBDIR, pkglibdir,
                          GNOME_PARAM_NONE);
    g_free (prefix);
    g_free (pkgsysconfdir);
    g_free (pkgdatadir);
    g_free (pkglibdir);

#ifdef G_OS_WIN32
    /* workaround for bug #421792 */
    xmlCleanupInputCallbacks();
#endif

    /* initialization required for gtkhtml */
    gtk_widget_set_default_colormap (gdk_rgb_get_colormap ());

    /* use custom icon */
    {
        int idx;
        char *icon_filenames[] = {"gnucash-icon-16x16.png",
                                  "gnucash-icon-32x32.png",
                                  "gnucash-icon-48x48.png",
                                  NULL
                                 };
        GList *icons = NULL;
        char *fullname, *name_iter;

        for (idx = 0; icon_filenames[idx] != NULL; idx++)
        {
            GdkPixbuf *buf = NULL;

            fullname = gnc_gnome_locate_pixmap(icon_filenames[idx]);
            if (fullname == NULL)
            {
                g_warning("couldn't find icon file [%s]", icon_filenames[idx]);
                continue;
            }

            buf = gnc_gnome_get_gdkpixbuf(fullname);
            if (buf == NULL)
            {
                g_warning("error loading image from [%s]", fullname);
                g_free(fullname);
                continue;
            }
            g_free(fullname);
            icons = g_list_append(icons, buf);
        }

        gtk_window_set_default_icon_list(icons);
        g_list_foreach(icons, (GFunc)g_object_unref, NULL);
        g_list_free(icons);
    }

    druid_gconf_install_check_schemas();

    return;
}
SludgeApplication::SludgeApplication(const char * gladeFileName, const char * iconName, const char * configFile)
{
	configfile = configFile;
	GError *err = NULL;

	initSuccess = TRUE;

	char buf[1000];
	GdkPixbuf *pixbuf16, *pixbuf32, *pixbuf128, *pixbuf256;
	GList *list = NULL;

	sprintf(buf, "%s%s_16x16x32.png", DATADIR, iconName);
	pixbuf16 = gdk_pixbuf_new_from_file (buf, &err);

	if (err == NULL) {
		sprintf(buf, "%s%s_32x32x32.png", DATADIR, iconName);
		pixbuf32 = gdk_pixbuf_new_from_file (buf, &err);
	}
	if (err == NULL) {
		sprintf(buf, "%s%s_128x128x32.png", DATADIR, iconName);
		pixbuf128 = gdk_pixbuf_new_from_file (buf, &err);
	}
	if (err == NULL) {
		sprintf(buf, "%s%s_256x256x32.png", DATADIR, iconName);
		pixbuf256 = gdk_pixbuf_new_from_file (buf, &err);
	}

	if (err != NULL)
	{
		fprintf (stderr, "Unable to open icon file: %s\n", err->message);
		g_error_free (err);
	} else {
		list = g_list_append (list, pixbuf16);
		list = g_list_append (list, pixbuf32);
		list = g_list_append (list, pixbuf128);
		list = g_list_append (list, pixbuf256);
		gtk_window_set_default_icon_list(list);
	}

	/*
	 * Load the GTK interface.
	 */
	theXml = gtk_builder_new ();

	if (!gtk_builder_add_from_file (theXml, gladeFileName, NULL))
	{
		g_critical ("Failed to load the GTK file.\n");
		errorBox("Error!", joinTwoStrings("Failed to load resource file:\n", gladeFileName));
		initSuccess = FALSE;
		return;
	}

	/*
	 * Get the top-level window reference from loaded Glade file.
	 */
	theWindow = GTK_WIDGET (gtk_builder_get_object (theXml, "window1"));

	if (theWindow == NULL)
	{
		g_critical ("Failed to get the window from the builder.\n");
		initSuccess = FALSE;
		return;
	}

	// Set unassigned widgets to get handled automatically by the window manager.
	gtk_container_set_reallocate_redraws (GTK_CONTAINER (theWindow), TRUE);

	char folderFile[300];
	sprintf(folderFile, "%s/sludge-devkit/%s", g_get_user_config_dir(), configfile);
	FILE * fp = fopen (folderFile, "r");
	if (fp) {
		char readChar = ' ';
		for (int i = 0; i < 300; i++) {
			readChar = fgetc(fp);
			if (readChar != '\n') {
				currentFolder[i] = readChar;
			} else {
				currentFolder[i] = 0;
				break;
			}
		}
		fclose (fp);
	} else {
		sprintf (currentFolder, "%s", g_get_home_dir());
	}
	fileChanged = FALSE;

	currentFilename[0] = 0;
	currentShortname[0] = 0;
}
Beispiel #22
0
/* Gobj */
static void 
bjb_window_base_init (BjbWindowBase *self) 
{
  BjbWindowBasePriv *priv;
  const gchar *icons_path;
  gchar *full_path;
  GList *icons = NULL;
  GdkPixbuf *bjb ;
  GError *error = NULL ;
  GtkClutterEmbed *embed;

  self->priv = G_TYPE_INSTANCE_GET_PRIVATE(self,
                                           BJB_TYPE_WINDOW_BASE,
                                           BjbWindowBasePriv);
  priv = self->priv;
    
  gtk_window_set_default_size (GTK_WINDOW (self), BJB_WIDTH, BJB_HEIGHT);
  gtk_window_set_position (GTK_WINDOW (self),GTK_WIN_POS_CENTER);
  gtk_window_set_title (GTK_WINDOW (self), BIJIBEN_MAIN_WIN_TITLE);

  /* Icon for window. TODO - Should be BjbApp */
  icons_path = bijiben_get_bijiben_dir ();
  full_path = g_build_filename (icons_path,
                                "icons",
                                "hicolor",
                                "48x48",
                                "apps",
                                "bijiben.png",
                                NULL);

  bjb = gdk_pixbuf_new_from_file (full_path, &error);
  g_free (full_path);
    
  if ( error )
  {
    g_message("%s", error->message);
    g_error_free(error);
  }
    
  icons = g_list_prepend(icons,bjb);
  gtk_window_set_default_icon_list(icons);
  g_list_foreach (icons, (GFunc) g_object_unref, NULL);
  g_list_free (icons);

  /*  We probably want to offer a no entry window at first (startup) */
  priv->entry = NULL ;

  priv->tags = get_all_tracker_tags();
  priv->font = pango_font_description_from_string (BJB_DEFAULT_FONT);

  /* UI */
  embed = GTK_CLUTTER_EMBED (gtk_clutter_embed_new());
  gtk_clutter_embed_set_use_layout_size (embed, TRUE);
  
  gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (embed));
  priv->stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (embed));

  /* Signals */
  g_signal_connect(GTK_WIDGET(self),"destroy",
                   G_CALLBACK(bjb_window_base_destroy),self);
}