[planner: 27/32] Make use of gtk_builder_new_from_resource() from GTK 3.10
- From: Mart Raudsepp <mraudsepp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [planner: 27/32] Make use of gtk_builder_new_from_resource() from GTK 3.10
- Date: Sun, 20 Jun 2021 18:13:51 +0000 (UTC)
commit 4921044c4361d12c573b8e158d048770c5365cb4
Author: Mart Raudsepp <leio gentoo org>
Date: Mon Jun 14 00:02:12 2021 +0300
Make use of gtk_builder_new_from_resource() from GTK 3.10
The resource files are now included into planner executable, not the
inbetween static library, as otherwise they get optimized out as there's
no manual code referencing the resources anymore.
src/meson.build | 4 ++--
src/planner-calendar-dialog.c | 4 ++--
src/planner-calendar-selector.c | 2 +-
src/planner-column-dialog.c | 2 +-
src/planner-day-type-dialog.c | 4 ++--
src/planner-default-week-dialog.c | 2 +-
src/planner-eds-plugin.c | 11 +----------
src/planner-group-dialog.c | 2 +-
src/planner-phase-dialog.c | 4 ++--
src/planner-project-properties.c | 4 ++--
src/planner-property-dialog.c | 4 ++--
src/planner-resource-dialog.c | 2 +-
src/planner-resource-input-dialog.c | 2 +-
src/planner-sql-plugin.c | 22 ++--------------------
src/planner-task-date-widget.c | 2 +-
src/planner-task-dialog.c | 4 ++--
src/planner-task-input-dialog.c | 2 +-
src/planner-util.c | 19 -------------------
src/planner-util.h | 2 --
src/planner-working-time-dialog.c | 2 +-
20 files changed, 26 insertions(+), 74 deletions(-)
---
diff --git a/src/meson.build b/src/meson.build
index 6e0af959..95ac6c9e 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -78,7 +78,7 @@ planner_marshal_srcs = gnome.genmarshal('planner-marshal',
)
libplanner_app_library = static_library('libplannerapp',
- [libplanner_app_srcs, gantt_task_srcs, resource_srcs, usage_srcs, planner_marshal_srcs, resources],
+ [libplanner_app_srcs, gantt_task_srcs, resource_srcs, usage_srcs, planner_marshal_srcs],
dependencies: [planner_deps, m_dep],
include_directories: [toplevel_inc, src_inc],
link_with: gnomecanvas_lib,
@@ -90,7 +90,7 @@ libplanner_app_dep = declare_dependency(
dependencies: [planner_deps, libplanner_dep],
)
planner_app = executable('planner',
- ['planner-main.c'],
+ ['planner-main.c', resources],
dependencies: [libplanner_app_dep, planner_deps, libplanner_dep],
export_dynamic: true,
include_directories: [toplevel_inc],
diff --git a/src/planner-calendar-dialog.c b/src/planner-calendar-dialog.c
index d2f81d66..4203a20f 100644
--- a/src/planner-calendar-dialog.c
+++ b/src/planner-calendar-dialog.c
@@ -592,7 +592,7 @@ planner_calendar_dialog_new (PlannerWindow *window)
g_return_val_if_fail (PLANNER_IS_WINDOW (window), NULL);
- builder = planner_util_new_builder ("/org/gnome/Planner/ui/calendar-dialog.ui");
+ builder = gtk_builder_new_from_resource ("/org/gnome/Planner/ui/calendar-dialog.ui");
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "calendar_dialog"));
@@ -1252,7 +1252,7 @@ cal_dialog_new_dialog_run (DialogData *data)
const gchar *name;
GtkTreePath *path;
- builder = planner_util_new_builder ("/org/gnome/Planner/ui/new-calendar-dialog.ui");
+ builder = gtk_builder_new_from_resource ("/org/gnome/Planner/ui/new-calendar-dialog.ui");
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "new_calendar_dialog"));
diff --git a/src/planner-calendar-selector.c b/src/planner-calendar-selector.c
index 472c4f67..cb414403 100644
--- a/src/planner-calendar-selector.c
+++ b/src/planner-calendar-selector.c
@@ -78,7 +78,7 @@ planner_calendar_selector_new (PlannerWindow *window,
g_return_val_if_fail (PLANNER_IS_WINDOW (window), NULL);
- builder = planner_util_new_builder ("/org/gnome/Planner/ui/calendar-selector.ui");
+ builder = gtk_builder_new_from_resource ("/org/gnome/Planner/ui/calendar-selector.ui");
selector = GTK_WIDGET (gtk_builder_get_object (builder, "calendar_selector"));
diff --git a/src/planner-column-dialog.c b/src/planner-column-dialog.c
index 08bbcbbf..f713ffa8 100644
--- a/src/planner-column-dialog.c
+++ b/src/planner-column-dialog.c
@@ -478,7 +478,7 @@ planner_column_dialog_show (PlannerWindow *window,
GtkBuilder *builder;
GtkWidget *close_button;
- builder = planner_util_new_builder ("/org/gnome/Planner/ui/column-dialog.ui");
+ builder = gtk_builder_new_from_resource ("/org/gnome/Planner/ui/column-dialog.ui");
data = g_new0 (DialogData, 1);
diff --git a/src/planner-day-type-dialog.c b/src/planner-day-type-dialog.c
index d53bac03..50337616 100644
--- a/src/planner-day-type-dialog.c
+++ b/src/planner-day-type-dialog.c
@@ -152,7 +152,7 @@ planner_day_type_dialog_new (PlannerWindow *window)
g_return_val_if_fail (PLANNER_IS_WINDOW (window), NULL);
- builder = planner_util_new_builder ("/org/gnome/Planner/ui/day-type-dialog.ui");
+ builder = gtk_builder_new_from_resource ("/org/gnome/Planner/ui/day-type-dialog.ui");
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "day_type_dialog"));
@@ -417,7 +417,7 @@ day_type_dialog_new_dialog_run (DialogData *data)
GtkWidget *button;
const gchar *name;
- builder = planner_util_new_builder ("/org/gnome/Planner/ui/new-day-dialog.ui");
+ builder = gtk_builder_new_from_resource ("/org/gnome/Planner/ui/new-day-dialog.ui");
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "new_day_dialog"));
diff --git a/src/planner-default-week-dialog.c b/src/planner-default-week-dialog.c
index 07d62836..48cb4ccf 100644
--- a/src/planner-default-week-dialog.c
+++ b/src/planner-default-week-dialog.c
@@ -179,7 +179,7 @@ planner_default_week_dialog_new (PlannerWindow *window,
g_return_val_if_fail (PLANNER_IS_WINDOW (window), NULL);
- builder = planner_util_new_builder ("/org/gnome/Planner/ui/default-week-dialog.ui");
+ builder = gtk_builder_new_from_resource ("/org/gnome/Planner/ui/default-week-dialog.ui");
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "default_week_dialog"));
diff --git a/src/planner-eds-plugin.c b/src/planner-eds-plugin.c
index 23847341..b6db28b0 100644
--- a/src/planner-eds-plugin.c
+++ b/src/planner-eds-plugin.c
@@ -232,20 +232,11 @@ eds_plugin_import (GtkAction *action,
PlannerPluginPriv *priv;
GtkCellRenderer *renderer;
GList *groups;
- GBytes *res_bytes;
- gconstpointer res_data;
- gsize res_size;
- GError *error = NULL;
plugin = PLANNER_PLUGIN (user_data);
priv = plugin->priv;
- priv->builder = gtk_builder_new ();
- res_bytes = g_resource_lookup_data (eds_plugin_resources_get_resource (),
"/org/gnome/Planner/plugin/eds/ui/eds.ui", 0, NULL);
- res_data = g_bytes_get_data (res_bytes, &res_size);
- if (gtk_builder_add_from_string (priv->builder, res_data, res_size, &error) == 0)
- g_error ("Failed to load resources: %s", error->message);
- g_bytes_unref (res_bytes);
+ priv->builder = gtk_builder_new_from_resource ("/org/gnome/Planner/plugin/eds/ui/eds.ui");
priv->dialog_get_resources = GTK_WIDGET (gtk_builder_get_object (priv->builder, "resources_get"));
diff --git a/src/planner-group-dialog.c b/src/planner-group-dialog.c
index e803eb1b..44455e5f 100644
--- a/src/planner-group-dialog.c
+++ b/src/planner-group-dialog.c
@@ -191,7 +191,7 @@ group_dialog_create (PlannerView *view)
data->project = g_object_ref (project);
- builder = planner_util_new_builder ("/org/gnome/Planner/ui/group-dialog.ui");
+ builder = gtk_builder_new_from_resource ("/org/gnome/Planner/ui/group-dialog.ui");
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "dialog_group_editor"));
diff --git a/src/planner-phase-dialog.c b/src/planner-phase-dialog.c
index 78daf1d7..0d9e324c 100644
--- a/src/planner-phase-dialog.c
+++ b/src/planner-phase-dialog.c
@@ -180,7 +180,7 @@ planner_phase_dialog_new (PlannerWindow *window)
g_return_val_if_fail (PLANNER_IS_WINDOW (window), NULL);
- builder = planner_util_new_builder ("/org/gnome/Planner/ui/phase-dialog.ui");
+ builder = gtk_builder_new_from_resource ("/org/gnome/Planner/ui/phase-dialog.ui");
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "phase_dialog"));
@@ -420,7 +420,7 @@ phase_dialog_new_dialog_run (DialogData *data)
GtkWidget *entry;
const gchar *name;
- builder = planner_util_new_builder ("/org/gnome/Planner/ui/new-phase-dialog.ui");
+ builder = gtk_builder_new_from_resource ("/org/gnome/Planner/ui/new-phase-dialog.ui");
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "new_phase_dialog"));
diff --git a/src/planner-project-properties.c b/src/planner-project-properties.c
index d063bdc0..0385eafa 100644
--- a/src/planner-project-properties.c
+++ b/src/planner-project-properties.c
@@ -1288,7 +1288,7 @@ mpp_add_property_button_clicked_cb (GtkButton *button, GtkWidget *dialog)
gint response;
gboolean finished = FALSE;
- builder = planner_util_new_builder ("/org/gnome/Planner/ui/new-property.ui");
+ builder = gtk_builder_new_from_resource ("/org/gnome/Planner/ui/new-property.ui");
add_dialog = GTK_WIDGET (gtk_builder_get_object (builder, "add_dialog"));
@@ -1500,7 +1500,7 @@ planner_project_properties_new (PlannerWindow *window)
g_return_val_if_fail (PLANNER_IS_WINDOW (window), NULL);
- builder = planner_util_new_builder ("/org/gnome/Planner/ui/project-properties.ui");
+ builder = gtk_builder_new_from_resource ("/org/gnome/Planner/ui/project-properties.ui");
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "project_properties"));
diff --git a/src/planner-property-dialog.c b/src/planner-property-dialog.c
index e719a362..27dc4fff 100644
--- a/src/planner-property-dialog.c
+++ b/src/planner-property-dialog.c
@@ -249,7 +249,7 @@ property_dialog_add_cb (GtkWidget *button,
priv = GET_PRIV (dialog);
- builder = planner_util_new_builder ("/org/gnome/Planner/ui/new-property.ui");
+ builder = gtk_builder_new_from_resource ("/org/gnome/Planner/ui/new-property.ui");
add_dialog = GTK_WIDGET (gtk_builder_get_object (builder, "add_dialog"));
label_entry = GTK_WIDGET (gtk_builder_get_object (builder, "label_entry"));
@@ -548,7 +548,7 @@ planner_property_dialog_new (PlannerWindow *main_window,
priv = g_new0 (PlannerPropertyDialogPriv, 1);
- builder = planner_util_new_builder ("/org/gnome/Planner/ui/property-dialog.ui");
+ builder = gtk_builder_new_from_resource ("/org/gnome/Planner/ui/property-dialog.ui");
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "dialog"));
diff --git a/src/planner-resource-dialog.c b/src/planner-resource-dialog.c
index 817efd7b..db357a71 100644
--- a/src/planner-resource-dialog.c
+++ b/src/planner-resource-dialog.c
@@ -1669,7 +1669,7 @@ planner_resource_dialog_new (PlannerWindow *window,
g_object_get (resource, "project", &project, NULL);
- builder = planner_util_new_builder ("/org/gnome/Planner/ui/resource-dialog.ui");
+ builder = gtk_builder_new_from_resource ("/org/gnome/Planner/ui/resource-dialog.ui");
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "resource_dialog"));
diff --git a/src/planner-resource-input-dialog.c b/src/planner-resource-input-dialog.c
index 8c43b2c1..806ce7cf 100644
--- a/src/planner-resource-input-dialog.c
+++ b/src/planner-resource-input-dialog.c
@@ -235,7 +235,7 @@ planner_resource_input_dialog_new (PlannerWindow *main_window)
data->project = g_object_ref (project);
data->main_window = g_object_ref (main_window);
- builder = planner_util_new_builder ("/org/gnome/Planner/ui/resource-input-dialog.ui");
+ builder = gtk_builder_new_from_resource ("/org/gnome/Planner/ui/resource-input-dialog.ui");
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "resource_input_dialog"));
g_signal_connect (dialog,
diff --git a/src/planner-sql-plugin.c b/src/planner-sql-plugin.c
index 926f4ea7..9814c96a 100644
--- a/src/planner-sql-plugin.c
+++ b/src/planner-sql-plugin.c
@@ -774,24 +774,6 @@ out:
return NULL;
}
-GtkBuilder *
-sql_plugin_new_builder (const gchar *resource_path)
-{
- GtkBuilder *builder;
- GBytes *res_bytes;
- gconstpointer res_data;
- gsize res_size;
- GError *error = NULL;
-
- builder = gtk_builder_new ();
- res_bytes = g_resource_lookup_data (sql_plugin_resources_get_resource (), resource_path, 0, NULL);
- res_data = g_bytes_get_data (res_bytes, &res_size);
- if (gtk_builder_add_from_string (builder, res_data, res_size, &error) == 0)
- g_error ("Failed to load resources: %s", error->message);
- g_bytes_unref (res_bytes);
- return builder;
-}
-
/**
* Display a list with projects and let the user select one. Returns the project
* id of the selected one.
@@ -849,7 +831,7 @@ sql_plugin_retrieve_project_id (PlannerPlugin *plugin,
return -1;
}
- builder = sql_plugin_new_builder ("/org/gnome/Planner/plugin/sql/ui/sql-select-dialog.ui");
+ builder = gtk_builder_new_from_resource ("/org/gnome/Planner/plugin/sql/ui/sql-select-dialog.ui");
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "select_dialog"));
treeview = GTK_WIDGET (gtk_builder_get_object (builder, "project_treeview"));
@@ -995,7 +977,7 @@ sql_plugin_retrieve_db_values (PlannerPlugin *plugin,
planner_window_get_application (plugin->main_window);
- builder = sql_plugin_new_builder ("/org/gnome/Planner/plugin/sql/ui/sql-open-dialog.ui");
+ builder = gtk_builder_new_from_resource ("/org/gnome/Planner/plugin/sql/ui/sql-open-dialog.ui");
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "open_dialog"));
diff --git a/src/planner-task-date-widget.c b/src/planner-task-date-widget.c
index eb6f7469..c274db9e 100644
--- a/src/planner-task-date-widget.c
+++ b/src/planner-task-date-widget.c
@@ -147,7 +147,7 @@ task_date_widget_setup (PlannerTaskDateWidget *widget)
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (widget), vbox);
- builder = planner_util_new_builder ("/org/gnome/Planner/ui/task-date-widget.ui");
+ builder = gtk_builder_new_from_resource ("/org/gnome/Planner/ui/task-date-widget.ui");
root_vbox = GTK_WIDGET (gtk_builder_get_object (builder, "root_vbox"));
gtk_container_add (GTK_CONTAINER (vbox), root_vbox);
diff --git a/src/planner-task-dialog.c b/src/planner-task-dialog.c
index 55f67ce2..a379364d 100644
--- a/src/planner-task-dialog.c
+++ b/src/planner-task-dialog.c
@@ -1828,7 +1828,7 @@ task_dialog_predecessor_dialog_new (MrpTask *task,
mrp_object_get (task, "project", &project, NULL);
- builder = planner_util_new_builder ("/org/gnome/Planner/ui/add-predecessor.ui");
+ builder = gtk_builder_new_from_resource ("/org/gnome/Planner/ui/add-predecessor.ui");
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "add_predecessor_dialog"));
@@ -2888,7 +2888,7 @@ planner_task_dialog_new (PlannerWindow *window,
return dialog;
}
- builder = planner_util_new_builder ("/org/gnome/Planner/ui/task-dialog.ui");
+ builder = gtk_builder_new_from_resource ("/org/gnome/Planner/ui/task-dialog.ui");
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "task_dialog"));
diff --git a/src/planner-task-input-dialog.c b/src/planner-task-input-dialog.c
index 0541d4fd..b772e04d 100644
--- a/src/planner-task-input-dialog.c
+++ b/src/planner-task-input-dialog.c
@@ -115,7 +115,7 @@ planner_task_input_dialog_new (PlannerWindow *main_window)
data->project = g_object_ref (project);
data->main_window = g_object_ref (main_window);
- builder = planner_util_new_builder ("/org/gnome/Planner/ui/task-input-dialog.ui");
+ builder = gtk_builder_new_from_resource ("/org/gnome/Planner/ui/task-input-dialog.ui");
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "task_input_dialog"));
g_signal_connect (dialog,
diff --git a/src/planner-util.c b/src/planner-util.c
index e4652d2b..30ea4b2e 100644
--- a/src/planner-util.c
+++ b/src/planner-util.c
@@ -21,7 +21,6 @@
#include <config.h>
#include "planner-util.h"
-#include "org.gnome.Planner.h"
void
planner_util_show_help (GtkWindow *parent)
@@ -48,24 +47,6 @@ planner_util_show_url (GtkWindow *parent, const gchar *url)
}
}
-GtkBuilder *
-planner_util_new_builder (const gchar *resource_path)
-{
- GtkBuilder *builder;
- GBytes *res_bytes;
- gconstpointer res_data;
- gsize res_size;
- GError *error = NULL;
-
- builder = gtk_builder_new ();
- res_bytes = g_resource_lookup_data (resources_get_resource (), resource_path, 0, NULL);
- res_data = g_bytes_get_data (res_bytes, &res_size);
- if (gtk_builder_add_from_string (builder, res_data, res_size, &error) == 0)
- g_error ("Failed to load resources: %s", error->message);
- g_bytes_unref (res_bytes);
- return builder;
-}
-
void
planner_util_menu_position_on_current_cell (GtkMenu *menu,
gint *x,
diff --git a/src/planner-util.h b/src/planner-util.h
index 0c224420..895a2bb6 100644
--- a/src/planner-util.h
+++ b/src/planner-util.h
@@ -28,8 +28,6 @@ void planner_util_show_help (GtkWindow *parent);
void planner_util_show_url (GtkWindow *parent,
const gchar *url);
-GtkBuilder *planner_util_new_builder (const gchar *resource_path);
-
void planner_util_menu_position_on_current_cell (GtkMenu *menu,
gint *x,
gint *y,
diff --git a/src/planner-working-time-dialog.c b/src/planner-working-time-dialog.c
index 4fcdc56e..bfebc552 100644
--- a/src/planner-working-time-dialog.c
+++ b/src/planner-working-time-dialog.c
@@ -209,7 +209,7 @@ planner_working_time_dialog_new (PlannerWindow *window,
g_return_val_if_fail (PLANNER_IS_WINDOW (window), NULL);
- builder = planner_util_new_builder ("/org/gnome/Planner/ui/working-time-dialog.ui");
+ builder = gtk_builder_new_from_resource ("/org/gnome/Planner/ui/working-time-dialog.ui");
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "working_time_dialog"));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]