Commit 9f435d87 authored by Stefano Facchini's avatar Stefano Facchini Committed by Robert Roth

Switch to glib resource framework

https://bugzilla.gnome.org/show_bug.cgi?id=704378
parent 62b0abec
## Process this file with automake to produce Makefile.in
ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
SUBDIRS = pixmaps po scripts src help
SUBDIRS = po scripts src help
uidir = $(pkgdatadir)
ui_DATA = data/preferences.ui \
data/renice.ui \
data/lsof.ui \
data/openfiles.ui \
data/interface.ui \
data/menus.ui \
data/popups.ui
ui_files = \
data/preferences.ui \
data/renice.ui \
data/lsof.ui \
data/openfiles.ui \
data/interface.ui \
data/menus.ui \
data/popups.ui
pixmap_files = \
pixmaps/download.svg \
pixmaps/upload.svg
runnabledir = $(pkglibexecdir)
runnable_SCRIPTS = scripts/gsm-renice \
......@@ -21,7 +24,8 @@ org.gnome.gnome-system-monitor.policy.in: org.gnome.gnome-system-monitor.policy.
$(AM_V_GEN) sed -e "s|\@pkglibexecdir\@|$(pkglibexecdir)|" $< > $@
EXTRA_DIST = \
$(ui_DATA) \
$(ui_files) \
$(pixmap_files) \
$(runnable_SCRIPTS) \
org.gnome.gnome-system-monitor.policy.in.in \
gnome-system-monitor.desktop.in \
......
......@@ -124,7 +124,6 @@ AC_CONFIG_FILES([
Makefile
scripts/Makefile
src/Makefile
pixmaps/Makefile
po/Makefile.in
help/Makefile
gnome-system-monitor.desktop.in
......
imagesdir = $(datadir)/pixmaps/gnome-system-monitor
images_DATA = side.png download.svg upload.svg
EXTRA_DIST = $(images_DATA)
## Process this file with automake to produce Makefile.in
INCLUDES = \
-DPROCMAN_DATADIR=\""$(datadir)/procman/"\" \
AM_CPPFLAGS = \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-DDATADIR=\""$(datadir)"\" \
@PROCMAN_CFLAGS@ \
@SYSTEMD_CFLAGS@ \
@WNCK_CFLAGS@
-DGSM_LIBEXEC_DIR=\""$(pkglibexecdir)"\" \
$(PROCMAN_CFLAGS) \
$(SYSTEMD_CFLAGS) \
$(WNCK_CFLAGS)
bin_PROGRAMS = gnome-system-monitor
BUILT_SOURCES = gsm-resources.c
gnome_system_monitor_cpp_files = \
argv.cpp \
interface.cpp \
......@@ -45,17 +46,20 @@ gnome_system_monitor_h_files = \
defaulttable.h
gnome_system_monitor_SOURCES = \
$(gnome_system_monitor_h_files) \
$(gnome_system_monitor_cpp_files) \
$(gnome_system_monitor_c_files) \
procman.cpp
$(BUILT_SOURCES) \
$(gnome_system_monitor_h_files) \
$(gnome_system_monitor_cpp_files) \
$(gnome_system_monitor_c_files) \
procman.cpp
gnome_system_monitor_LDADD = @PROCMAN_LIBS@ @SYSTEMD_LIBS@ @WNCK_LIBS@
LDADD = \
$(PROCMAN_LIBS) \
$(SYSTEMD_LIBS) \
$(WNCK_LIBS)
gnome_system_monitor_CPPFLAGS = -DGSM_DATA_DIR=\""$(pkgdatadir)"\" \
-DGSM_LIBEXEC_DIR=\""$(pkglibexecdir)"\"
gsm-resources.c: gsm.gresource.xml $(shell glib-compile-resources --sourcedir=$(top_srcdir) --generate-dependencies gsm.gresource.xml)
$(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(top_srcdir) --generate-source gsm.gresource.xml
specdir = $(datadir)/procman
# GSettings schemas, enum files and conversion file
gsettings_ENUM_NAMESPACE = org.gnome.gnome-system-monitor
......@@ -68,7 +72,11 @@ gsettings_SCHEMAS = $(gsettings_in_file:.xml.in=.xml)
dist_noinst_DATA = \
$(gsettings_in_file)
EXTRA_DIST = \
gsm.gresource.xml
CLEANFILES = \
$(gsettings_SCHEMAS)
$(gsettings_SCHEMAS) \
$(BUILT_SOURCES)
MAINTAINERCLEANFILES = $(gsettings_SCHEMAS:.xml=.valid)
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gnome/gnome-system-monitor">
<file preprocess="xml-stripblanks">data/interface.ui</file>
<file preprocess="xml-stripblanks">data/lsof.ui</file>
<file preprocess="xml-stripblanks">data/openfiles.ui</file>
<file preprocess="xml-stripblanks">data/preferences.ui</file>
<file preprocess="xml-stripblanks">data/renice.ui</file>
<file preprocess="xml-stripblanks">data/menus.ui</file>
<file preprocess="xml-stripblanks">data/popups.ui</file>
<file preprocess="xml-stripblanks">pixmaps/download.svg</file>
<file preprocess="xml-stripblanks">pixmaps/upload.svg</file>
</gresource>
</gresources>
......@@ -240,18 +240,24 @@ gsm_color_button_class_init (GSMColorButtonClass * klass)
static cairo_surface_t *
fill_image_buffer_from_file (cairo_t *cr, const char *filePath)
fill_image_buffer_from_resource (cairo_t *cr, const char *path)
{
GBytes *bytes;
const guint8 *data;
gsize len;
GError *error = NULL;
RsvgHandle *handle;
cairo_surface_t *tmp_surface;
cairo_t *tmp_cr;
handle = rsvg_handle_new_from_file (filePath, &error);
bytes = g_resources_lookup_data (path, 0 , NULL);
data = g_bytes_get_data (bytes, &len);
handle = rsvg_handle_new_from_data (data, len, &error);
if (handle == NULL) {
g_warning("rsvg_handle_new_from_file(\"%s\") failed: %s",
filePath, (error ? error->message : "unknown error"));
g_warning("rsvg_handle_new_from_data(\"%s\") failed: %s",
path, (error ? error->message : "unknown error"));
if (error)
g_error_free(error);
return NULL;
......@@ -383,7 +389,7 @@ render (GtkWidget * widget)
case GSMCP_TYPE_NETWORK_IN:
if (color_button->priv->image_buffer == NULL)
color_button->priv->image_buffer =
fill_image_buffer_from_file (cr, DATADIR "/pixmaps/gnome-system-monitor/download.svg");
fill_image_buffer_from_resource (cr, "/org/gnome/gnome-system-monitor/pixmaps/download.svg");
gtk_widget_set_size_request (widget, 32, 32);
cairo_move_to (cr, 8.5, 1.5);
cairo_line_to (cr, 23.5, 1.5);
......@@ -414,7 +420,7 @@ render (GtkWidget * widget)
case GSMCP_TYPE_NETWORK_OUT:
if (color_button->priv->image_buffer == NULL)
color_button->priv->image_buffer =
fill_image_buffer_from_file (cr, DATADIR "/pixmaps/gnome-system-monitor/upload.svg");
fill_image_buffer_from_resource (cr, "/org/gnome/gnome-system-monitor/pixmaps/upload.svg");
gtk_widget_set_size_request (widget, 32, 32);
cairo_move_to (cr, 16.5, 1.5);
cairo_line_to (cr, 29.5, 17.5);
......
......@@ -317,11 +317,8 @@ create_main_window (ProcmanApp *app)
GtkAction *action;
GtkWidget *notebook;
gchar* filename = g_build_filename (GSM_DATA_DIR, "interface.ui", NULL);
GtkBuilder *builder = gtk_builder_new();
gtk_builder_add_from_file (builder, filename, NULL);
g_free (filename);
gtk_builder_add_from_resource (builder, "/org/gnome/gnome-system-monitor/data/interface.ui", NULL);
main_window = GTK_WIDGET (gtk_builder_get_object (builder, "main_window"));
gtk_window_set_application (GTK_WINDOW (main_window), app->gobj());
......@@ -358,14 +355,12 @@ create_main_window (ProcmanApp *app)
gtk_window_add_accel_group (GTK_WINDOW (main_window),
gtk_ui_manager_get_accel_group (app->uimanager));
filename = g_build_filename (GSM_DATA_DIR, "popups.ui", NULL);
if (!gtk_ui_manager_add_ui_from_file (app->uimanager,
filename,
NULL)) {
if (!gtk_ui_manager_add_ui_from_resource (app->uimanager,
"/org/gnome/gnome-system-monitor/data/popups.ui",
NULL)) {
g_error("building menus failed");
}
g_free (filename);
app->action_group = gtk_action_group_new ("ProcmanActions");
gtk_action_group_set_translation_domain (app->action_group, NULL);
gtk_action_group_add_actions (app->action_group,
......
......@@ -300,25 +300,15 @@ void procman_lsof(ProcmanApp *app)
gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
GtkWidget *dialog; /* = gtk_dialog_new_with_buttons(_("Search for Open Files"), NULL,
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
NULL); */
//dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gchar* filename = g_build_filename (GSM_DATA_DIR, "lsof.ui", NULL);
GtkWidget *dialog;
GtkBuilder *builder = gtk_builder_new();
gtk_builder_add_from_file (builder, filename, NULL);
gtk_builder_add_from_resource (builder, "/org/gnome/gnome-system-monitor/data/lsof.ui", NULL);
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "lsof_dialog"));
gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(app->main_window));
// entry = sexy_icon_entry_new();
// sexy_icon_entry_add_clear_button(SEXY_ICON_ENTRY(entry));
// GtkWidget *icon = gtk_image_new_from_stock(GTK_STOCK_FIND, GTK_ICON_SIZE_MENU);
// sexy_icon_entry_set_icon(SEXY_ICON_ENTRY(entry), SEXY_ICON_ENTRY_PRIMARY, GTK_IMAGE(icon));
GtkWidget *entry = GTK_WIDGET (gtk_builder_get_object (builder, "entry"));
GtkWidget *search_button = GTK_WIDGET (gtk_builder_get_object (builder, "search_button"));
GtkWidget *clear_button = GTK_WIDGET (gtk_builder_get_object (builder, "clear_button"));
......@@ -357,6 +347,5 @@ void procman_lsof(ProcmanApp *app)
gtk_widget_show_all(dialog);
g_object_unref (G_OBJECT (builder));
g_free (filename);
}
......@@ -333,10 +333,8 @@ create_single_openfiles_dialog (GtkTreeModel *model, GtkTreePath *path,
if (!info)
return;
gchar* filename = g_build_filename (GSM_DATA_DIR, "openfiles.ui", NULL);
GtkBuilder *builder = gtk_builder_new();
gtk_builder_add_from_file (builder, filename, NULL);
gtk_builder_add_from_resource (builder, "/org/gnome/gnome-system-monitor/data/openfiles.ui", NULL);
openfilesdialog = GTK_WIDGET (gtk_builder_get_object (builder, "openfiles_dialog"));
......@@ -370,7 +368,6 @@ create_single_openfiles_dialog (GtkTreeModel *model, GtkTreePath *path,
update_openfiles_dialog (tree);
g_object_unref (G_OBJECT (builder));
g_free (filename);
}
......
......@@ -161,10 +161,8 @@ procdialog_create_renice_dialog (ProcmanApp *app)
if (!info)
return;
gchar* filename = g_build_filename (GSM_DATA_DIR, "renice.ui", NULL);
builder = gtk_builder_new();
gtk_builder_add_from_file (builder, filename, NULL);
gtk_builder_add_from_resource (builder, "/org/gnome/gnome-system-monitor/data/renice.ui", NULL);
renice_dialog = GTK_WIDGET (gtk_builder_get_object (builder, "renice_dialog"));
......@@ -204,7 +202,6 @@ procdialog_create_renice_dialog (ProcmanApp *app)
gtk_builder_connect_signals (builder, NULL);
g_object_unref (G_OBJECT (builder));
g_free (filename);
}
static void
......@@ -405,10 +402,8 @@ procdialog_create_preferences_dialog (ProcmanApp *app)
if (prefs_dialog)
return;
gchar* filename = g_build_filename (GSM_DATA_DIR, "preferences.ui", NULL);
builder = gtk_builder_new();
gtk_builder_add_from_file (builder, filename, NULL);
gtk_builder_add_from_resource (builder, "/org/gnome/gnome-system-monitor/data/preferences.ui", NULL);
prefs_dialog = GTK_WIDGET (gtk_builder_get_object (builder, "preferences_dialog"));
......@@ -487,7 +482,6 @@ procdialog_create_preferences_dialog (ProcmanApp *app)
}
gtk_builder_connect_signals (builder, NULL);
g_object_unref (G_OBJECT (builder));
g_free (filename);
}
......
......@@ -670,9 +670,7 @@ void ProcmanApp::on_startup()
action->signal_activate().connect(sigc::mem_fun(*this, &ProcmanApp::on_preferences_activate));
add_action(action);
char* filename = g_build_filename (GSM_DATA_DIR, "menus.ui", NULL);
Glib::RefPtr<Gtk::Builder> builder = Gtk::Builder::create_from_file(filename);
g_free (filename);
Glib::RefPtr<Gtk::Builder> builder = Gtk::Builder::create_from_resource("/org/gnome/gnome-system-monitor/data/menus.ui");
Glib::RefPtr<Gio::Menu> menu = Glib::RefPtr<Gio::Menu>::cast_static(builder->get_object ("app-menu"));
set_app_menu (menu);
......
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