Commit 733c890a authored by Alexander Larsson's avatar Alexander Larsson

Move all ui files and icons into resources

parent d6291d9a
NULL=
icondir = $(datadir)/pixmaps/nautilus
icon_DATA =\
noinst_DATA =\
knob.png \
thumbnail_frame.png \
$(NULL)
EXTRA_DIST = $(icon_DATA)
EXTRA_DIST = $(noinst_DATA)
......@@ -726,41 +726,6 @@ nautilus_get_gmc_desktop_directory (void)
return g_build_filename (g_get_home_dir (), LEGACY_DESKTOP_DIRECTORY_NAME, NULL);
}
/**
* nautilus_get_pixmap_directory
*
* Get the path for the directory containing Nautilus pixmaps.
*
* Return value: the directory path.
**/
char *
nautilus_get_pixmap_directory (void)
{
return g_strdup (DATADIR "/pixmaps/nautilus");
}
/* FIXME bugzilla.gnome.org 42423:
* Callers just use this and dereference so we core dump if
* pixmaps are missing. That is lame.
*/
char *
nautilus_pixmap_file (const char *partial_path)
{
char *path;
path = g_build_filename (DATADIR "/pixmaps/nautilus", partial_path, NULL);
if (g_file_test (path, G_FILE_TEST_EXISTS)) {
return path;
} else {
char *tmp;
tmp = nautilus_get_pixmap_directory ();
g_debug ("Failed to locate \"%s\" in Nautilus pixmap path \"%s\". Incomplete installation?", partial_path, tmp);
g_free (tmp);
}
g_free (path);
return NULL;
}
char *
nautilus_get_data_file_path (const char *partial_path)
{
......
......@@ -49,7 +49,6 @@ gboolean nautilus_is_home_directory_file (GFile *dir,
const char *filename);
gboolean nautilus_is_in_system_dir (GFile *location);
char * nautilus_get_gmc_desktop_directory (void);
char * nautilus_get_pixmap_directory (void);
gboolean nautilus_should_use_templates_directory (void);
char * nautilus_get_templates_directory (void);
......@@ -64,16 +63,6 @@ char * nautilus_compute_title_for_location (GFile *file);
* is not NULL, but is not garaunteed to exist */
char * nautilus_get_desktop_directory_uri_no_create (void);
/* A version of gnome's gnome_pixmap_file that works for the nautilus prefix.
* Otherwise similar to gnome_pixmap_file in that it checks to see if the file
* exists and returns NULL if it doesn't.
*/
/* FIXME bugzilla.gnome.org 42425:
* We might not need this once we get on gnome-libs 2.0 which handles
* gnome_pixmap_file better, using GNOME_PATH.
*/
char * nautilus_pixmap_file (const char *partial_path);
/* Locate a file in either the uers directory or the datadir. */
char * nautilus_get_data_file_path (const char *partial_path);
......
......@@ -1233,15 +1233,16 @@ static GdkPixbuf *
get_knob_pixbuf (void)
{
GdkPixbuf *knob_pixbuf;
char *knob_filename;
knob_pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
"stock-nautilus-knob",
8, 0, NULL);
if (!knob_pixbuf) {
knob_filename = nautilus_pixmap_file ("knob.png");
knob_pixbuf = gdk_pixbuf_new_from_file (knob_filename, NULL);
g_free (knob_filename);
GInputStream *stream = g_resources_open_stream ("/org/gnome/nautilus/icons/knob.png", 0, NULL);
if (stream != NULL) {
knob_pixbuf = gdk_pixbuf_new_from_stream (stream, NULL, NULL);
g_object_unref (stream);
}
}
return knob_pixbuf;
......
......@@ -240,15 +240,14 @@ nautilus_remove_thumbnail_for_file (const char *file_uri)
static GdkPixbuf *
nautilus_get_thumbnail_frame (void)
{
char *image_path;
static GdkPixbuf *thumbnail_frame = NULL;
if (thumbnail_frame == NULL) {
image_path = nautilus_pixmap_file ("thumbnail_frame.png");
if (image_path != NULL) {
thumbnail_frame = gdk_pixbuf_new_from_file (image_path, NULL);
GInputStream *stream = g_resources_open_stream ("/org/gnome/nautilus/icons/thumbnail_frame.png", 0, NULL);
if (stream != NULL) {
thumbnail_frame = gdk_pixbuf_new_from_stream (stream, NULL, NULL);
g_object_unref (stream);
}
g_free (image_path);
}
return thumbnail_frame;
......
......@@ -60,53 +60,6 @@ nautilus_ui_prepare_merge_ui (GtkUIManager *ui_manager,
g_object_unref (*action_group); /* owned by ui manager */
}
char *
nautilus_get_ui_directory (void)
{
return g_strdup (DATADIR "/nautilus/ui");
}
char *
nautilus_ui_file (const char *partial_path)
{
char *path;
path = g_build_filename (DATADIR "/nautilus/ui", partial_path, NULL);
if (g_file_test (path, G_FILE_TEST_EXISTS)) {
return path;
}
g_free (path);
return NULL;
}
const char *
nautilus_ui_string_get (const char *filename)
{
static GHashTable *ui_cache = NULL;
char *ui;
char *path;
if (ui_cache == NULL) {
ui_cache = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
eel_debug_call_at_shutdown_with_data ((GFreeFunc)g_hash_table_destroy, ui_cache);
}
ui = g_hash_table_lookup (ui_cache, filename);
if (ui == NULL) {
path = nautilus_ui_file (filename);
if (path == NULL || !g_file_get_contents (path, &ui, NULL, NULL)) {
g_warning ("Unable to load ui file %s\n", filename);
}
g_free (path);
g_hash_table_insert (ui_cache,
g_strdup (filename),
ui);
}
return ui;
}
static void
extension_action_callback (GtkAction *action,
gpointer callback_data)
......
......@@ -27,8 +27,6 @@
#include <gtk/gtk.h>
#include <libnautilus-extension/nautilus-menu-item.h>
char * nautilus_get_ui_directory (void);
char * nautilus_ui_file (const char *partial_path);
void nautilus_ui_unmerge_ui (GtkUIManager *ui_manager,
guint *merge_id,
GtkActionGroup **action_group);
......@@ -37,7 +35,6 @@ void nautilus_ui_prepare_merge_ui (GtkUIManager *ui_manage
guint *merge_id,
GtkActionGroup **action_group);
GtkAction * nautilus_action_from_menu_item (NautilusMenuItem *item);
const char *nautilus_ui_string_get (const char *filename);
gboolean nautilus_event_should_open_in_new_tab (void);
......
......@@ -53,8 +53,28 @@ $(dbus_built_sources) : Makefile.am $(top_srcdir)/data/freedesktop-dbus-interfac
$(top_srcdir)/data/freedesktop-dbus-interfaces.xml \
$(NULL)
UI_FILES = \
nautilus-bookmarks-window.ui \
nautilus-file-management-properties.ui \
nautilus-icon-view-ui.xml \
nautilus-toolbar-ui.xml \
nautilus-directory-view-ui.xml \
nautilus-desktop-icon-view-ui.xml \
nautilus-list-view-ui.xml \
nautilus-shell-ui.xml \
$(NULL)
nautilus-resources.c: nautilus.gresource.xml $(UI_FILES)
glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-source --c-name nautilus $(srcdir)/nautilus.gresource.xml
nautilus-resources.h: nautilus.gresource.xml
glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-header --c-name nautilus $(srcdir)/nautilus.gresource.xml
BUILT_SOURCES = \
$(dbus_built_sources) \
nautilus-resources.c \
nautilus-resources.h \
$(NULL)
nautilus_SOURCES = \
......@@ -193,18 +213,6 @@ TESTS=check-nautilus
@INTLTOOL_SERVER_RULE@
uidir = $(datadir)/nautilus/ui
ui_DATA = \
nautilus-shell-ui.xml \
nautilus-file-management-properties.ui \
nautilus-bookmarks-window.ui \
nautilus-desktop-icon-view-ui.xml \
nautilus-directory-view-ui.xml \
nautilus-icon-view-ui.xml \
nautilus-list-view-ui.xml \
nautilus-toolbar-ui.xml \
$(NULL)
CLEANFILES = \
$(BUILT_SOURCES) \
$(server_DATA) \
......@@ -212,7 +220,7 @@ CLEANFILES = \
EXTRA_DIST = \
$(server_in_files) \
$(ui_DATA) \
$(UI_FILES) \
check-nautilus \
$(NULL)
......
......@@ -254,9 +254,9 @@ create_bookmarks_window (NautilusBookmarkList *list, GObject *undo_manager_sourc
bookmarks = list;
builder = gtk_builder_new ();
if (!gtk_builder_add_from_file (builder,
UIDIR "/nautilus-bookmarks-window.ui",
NULL)) {
if (!gtk_builder_add_from_resource (builder,
"/org/gnome/nautilus/nautilus-bookmarks-window.ui",
NULL)) {
return NULL;
}
......
......@@ -747,7 +747,6 @@ real_merge_menus (NautilusView *view)
NautilusDesktopIconView *desktop_view;
GtkUIManager *ui_manager;
GtkActionGroup *action_group;
const char *ui;
NAUTILUS_VIEW_CLASS (nautilus_desktop_icon_view_parent_class)->merge_menus (view);
......@@ -765,9 +764,8 @@ real_merge_menus (NautilusView *view)
gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
g_object_unref (action_group); /* owned by ui manager */
ui = nautilus_ui_string_get ("nautilus-desktop-icon-view-ui.xml");
desktop_view->details->desktop_merge_id =
gtk_ui_manager_add_ui_from_string (ui_manager, ui, -1, NULL);
gtk_ui_manager_add_ui_from_resource (ui_manager, "/org/gnome/nautilus/nautilus-desktop-icon-view-ui.xml", NULL);
}
static NautilusView *
......
......@@ -837,9 +837,9 @@ nautilus_file_management_properties_dialog_show (GtkWindow *window)
builder = gtk_builder_new ();
gtk_builder_add_from_file (builder,
UIDIR "/nautilus-file-management-properties.ui",
NULL);
gtk_builder_add_from_resource (builder,
"/org/gnome/nautilus/nautilus-file-management-properties.ui",
NULL);
nautilus_file_management_properties_dialog_setup (builder, window);
......
......@@ -1356,7 +1356,6 @@ nautilus_icon_view_merge_menus (NautilusView *view)
GtkUIManager *ui_manager;
GtkActionGroup *action_group;
GtkAction *action;
const char *ui;
g_assert (NAUTILUS_IS_ICON_VIEW (view));
......@@ -1385,9 +1384,8 @@ nautilus_icon_view_merge_menus (NautilusView *view)
gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
g_object_unref (action_group); /* owned by ui manager */
ui = nautilus_ui_string_get ("nautilus-icon-view-ui.xml");
icon_view->details->icon_merge_id =
gtk_ui_manager_add_ui_from_string (ui_manager, ui, -1, NULL);
gtk_ui_manager_add_ui_from_resource (ui_manager, "/org/gnome/nautilus/nautilus-icon-view-ui.xml", NULL);
/* Do one-time state-setting here; context-dependent state-setting
* is done in update_menus.
......
......@@ -2659,7 +2659,6 @@ nautilus_list_view_merge_menus (NautilusView *view)
NautilusListView *list_view;
GtkUIManager *ui_manager;
GtkActionGroup *action_group;
const char *ui;
list_view = NAUTILUS_LIST_VIEW (view);
......@@ -2677,8 +2676,8 @@ nautilus_list_view_merge_menus (NautilusView *view)
gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
g_object_unref (action_group); /* owned by ui manager */
ui = nautilus_ui_string_get ("nautilus-list-view-ui.xml");
list_view->details->list_merge_id = gtk_ui_manager_add_ui_from_string (ui_manager, ui, -1, NULL);
list_view->details->list_merge_id =
gtk_ui_manager_add_ui_from_resource (ui_manager, "/org/gnome/nautilus/nautilus-list-view-ui.xml", NULL);
list_view->details->menus_ready = TRUE;
}
......
......@@ -88,7 +88,6 @@ nautilus_toolbar_constructed (GObject *obj)
GtkToolItem *item;
GtkWidget *hbox, *toolbar, *search;
GtkStyleContext *context;
const gchar *ui;
G_OBJECT_CLASS (nautilus_toolbar_parent_class)->constructed (obj);
......@@ -96,9 +95,8 @@ nautilus_toolbar_constructed (GObject *obj)
GTK_JUNCTION_BOTTOM);
/* add the UI */
ui = nautilus_ui_string_get ("nautilus-toolbar-ui.xml");
self->priv->ui_manager = gtk_ui_manager_new ();
gtk_ui_manager_add_ui_from_string (self->priv->ui_manager, ui, -1, NULL);
gtk_ui_manager_add_ui_from_resource (self->priv->ui_manager, "/org/gnome/nautilus/nautilus-toolbar-ui.xml", NULL);
gtk_ui_manager_insert_action_group (self->priv->ui_manager, self->priv->action_group, 0);
toolbar = gtk_ui_manager_get_widget (self->priv->ui_manager, "/Toolbar");
......
......@@ -7162,7 +7162,6 @@ real_merge_menus (NautilusView *view)
GtkActionGroup *action_group;
GtkUIManager *ui_manager;
GtkAction *action;
const char *ui;
char *tooltip;
ui_manager = nautilus_window_get_ui_manager (view->details->window);
......@@ -7196,8 +7195,7 @@ real_merge_menus (NautilusView *view)
gtk_ui_manager_insert_action_group (ui_manager, action_group, -1);
g_object_unref (action_group); /* owned by ui manager */
ui = nautilus_ui_string_get ("nautilus-directory-view-ui.xml");
view->details->dir_merge_id = gtk_ui_manager_add_ui_from_string (ui_manager, ui, -1, NULL);
view->details->dir_merge_id = gtk_ui_manager_add_ui_from_resource (ui_manager, "/org/gnome/nautilus/nautilus-directory-view-ui.xml", NULL);
view->details->scripts_invalid = TRUE;
view->details->templates_invalid = TRUE;
......
......@@ -1223,7 +1223,6 @@ nautilus_window_initialize_menus (NautilusWindow *window)
GtkActionGroup *action_group;
GtkUIManager *ui_manager;
GtkAction *action;
const char *ui;
gint i;
window->details->ui_manager = gtk_ui_manager_new ();
......@@ -1296,8 +1295,7 @@ nautilus_window_initialize_menus (NautilusWindow *window)
G_CALLBACK (disconnect_proxy_cb), window);
/* add the UI */
ui = nautilus_ui_string_get ("nautilus-shell-ui.xml");
gtk_ui_manager_add_ui_from_string (ui_manager, ui, -1, NULL);
gtk_ui_manager_add_ui_from_resource (ui_manager, "/org/gnome/nautilus/nautilus-shell-ui.xml", NULL);
nautilus_window_initialize_trash_icon_monitor (window);
nautilus_window_initialize_go_menu (window);
......
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gnome/nautilus">
<file compressed="true">nautilus-bookmarks-window.ui</file>
<file compressed="true">nautilus-file-management-properties.ui</file>
<file>nautilus-icon-view-ui.xml</file>
<file>nautilus-toolbar-ui.xml</file>
<file>nautilus-directory-view-ui.xml</file>
<file>nautilus-desktop-icon-view-ui.xml</file>
<file>nautilus-list-view-ui.xml</file>
<file>nautilus-shell-ui.xml</file>
<file alias="icons/thumbnail_frame.png">../icons/thumbnail_frame.png</file>
<file alias="icons/knob.png">../icons/knob.png</file>
</gresource>
</gresources>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment