[gimp] Use the new GtkAction accessors instead of g_object_get()/set()
- From: Michael Natterer <mitch src gnome org>
- To: svn-commits-list gnome org
- Subject: [gimp] Use the new GtkAction accessors instead of g_object_get()/set()
- Date: Sun, 24 May 2009 16:30:07 -0400 (EDT)
commit c9674b4603d3fc21636a07eb1c3ce3ee5001742f
Author: Michael Natterer <mitch gimp org>
Date: Sun May 24 22:29:18 2009 +0200
Use the new GtkAction accessors instead of g_object_get()/set()
---
app/actions/debug-commands.c | 11 +++++------
app/widgets/gimpaction.c | 15 +++++----------
app/widgets/gimpactiongroup.c | 2 +-
app/widgets/gimpactionview.c | 21 ++++-----------------
app/widgets/gimpcontrollereditor.c | 7 ++-----
app/widgets/gimpdockable.c | 4 +---
app/widgets/gimpeditor.c | 16 ++++------------
app/widgets/gimpradioaction.c | 25 ++++++++++---------------
app/widgets/gimpstringaction.c | 2 +-
app/widgets/gimptoggleaction.c | 24 +++++++++---------------
app/widgets/gimpuimanager.c | 9 ++-------
app/widgets/gimpwidgets-utils.c | 14 +++++---------
12 files changed, 49 insertions(+), 101 deletions(-)
diff --git a/app/actions/debug-commands.c b/app/actions/debug-commands.c
index 1878204..5deb707 100644
--- a/app/actions/debug-commands.c
+++ b/app/actions/debug-commands.c
@@ -230,12 +230,12 @@ debug_dump_keyboard_shortcuts_cmd_callback (GtkAction *action,
key->accel_key &&
key->accel_flags & GTK_ACCEL_VISIBLE)
{
- gchar *label_tmp = NULL;
- gchar *label = NULL;
- gchar *key_string = NULL;
- gchar *formated_string = NULL;
+ const gchar *label_tmp;
+ gchar *label;
+ gchar *key_string;
+ gchar *formated_string;
- g_object_get (action, "label", &label_tmp, NULL);
+ label_tmp = gtk_action_get_label (action);
label = gimp_strip_uline (label_tmp);
key_string = gtk_accelerator_get_label (key->accel_key,
key->accel_mods);
@@ -247,7 +247,6 @@ debug_dump_keyboard_shortcuts_cmd_callback (GtkAction *action,
g_free (key_string);
g_free (label);
- g_free (label_tmp);
}
}
}
diff --git a/app/widgets/gimpaction.c b/app/widgets/gimpaction.c
index 9d5bb47..0d0faa7 100644
--- a/app/widgets/gimpaction.c
+++ b/app/widgets/gimpaction.c
@@ -289,7 +289,7 @@ gimp_action_new (const gchar *name,
if (stock_id)
{
if (gtk_icon_theme_has_icon (gtk_icon_theme_get_default (), stock_id))
- g_object_set (action, "icon-name", stock_id, NULL);
+ gtk_action_set_icon_name (GTK_ACTION (action), stock_id);
}
return action;
@@ -409,17 +409,12 @@ static void
gimp_action_set_proxy_tooltip (GimpAction *action,
GtkWidget *proxy)
{
- gchar *tooltip;
-
- g_object_get (action, "tooltip", &tooltip, NULL);
+ const gchar *tooltip = gtk_action_get_tooltip (GTK_ACTION (action));
if (tooltip)
- {
- gimp_help_set_help_data (proxy, tooltip,
- g_object_get_qdata (G_OBJECT (proxy),
- GIMP_HELP_ID));
- g_free (tooltip);
- }
+ gimp_help_set_help_data (proxy, tooltip,
+ g_object_get_qdata (G_OBJECT (proxy),
+ GIMP_HELP_ID));
}
static void
diff --git a/app/widgets/gimpactiongroup.c b/app/widgets/gimpactiongroup.c
index ed76456..7e6c70d 100644
--- a/app/widgets/gimpactiongroup.c
+++ b/app/widgets/gimpactiongroup.c
@@ -842,7 +842,7 @@ gimp_action_group_set_action_label (GimpActionGroup *group,
else
stripped = (gchar *) label;
- g_object_set (action, "label", stripped, NULL);
+ gtk_action_set_label (action, stripped);
if (! group->mnemonics)
g_free (stripped);
diff --git a/app/widgets/gimpactionview.c b/app/widgets/gimpactionview.c
index e51120f..72dcdef 100644
--- a/app/widgets/gimpactionview.c
+++ b/app/widgets/gimpactionview.c
@@ -241,10 +241,9 @@ gimp_action_view_new (GimpUIManager *manager,
{
GtkAction *action = list2->data;
const gchar *name = gtk_action_get_name (action);
- gchar *stock_id;
+ const gchar *stock_id = gtk_action_get_stock_id (action);
gchar *label;
gchar *label_casefold;
- gchar *tmp;
guint accel_key = 0;
GdkModifierType accel_mask = 0;
GClosure *accel_closure = NULL;
@@ -255,13 +254,7 @@ gimp_action_view_new (GimpUIManager *manager,
name[0] == '<')
continue;
- g_object_get (action,
- "stock-id", &stock_id,
- "label", &tmp,
- NULL);
-
- label = gimp_strip_uline (tmp);
- g_free (tmp);
+ label = gimp_strip_uline (gtk_action_get_label (action));
if (! (label && strlen (label)))
{
@@ -307,7 +300,6 @@ gimp_action_view_new (GimpUIManager *manager,
GIMP_ACTION_VIEW_COLUMN_ACCEL_CLOSURE, accel_closure,
-1);
- g_free (stock_id);
g_free (label);
g_free (label_casefold);
@@ -655,19 +647,14 @@ gimp_action_view_conflict_confirm (GimpActionView *view,
{
GimpActionGroup *group;
gchar *label;
- gchar *tmp;
gchar *accel_string;
ConfirmData *confirm_data;
GtkWidget *dialog;
GimpMessageBox *box;
- g_object_get (action,
- "action-group", &group,
- "label", &tmp,
- NULL);
+ g_object_get (action, "action-group", &group, NULL);
- label = gimp_strip_uline (tmp);
- g_free (tmp);
+ label = gimp_strip_uline (gtk_action_get_label (action));
accel_string = gtk_accelerator_get_label (accel_key, accel_mask);
diff --git a/app/widgets/gimpcontrollereditor.c b/app/widgets/gimpcontrollereditor.c
index 6eb8807..5604524 100644
--- a/app/widgets/gimpcontrollereditor.c
+++ b/app/widgets/gimpcontrollereditor.c
@@ -308,7 +308,7 @@ gimp_controller_editor_constructor (GType type,
const gchar *event_name;
const gchar *event_blurb;
const gchar *event_action;
- gchar *stock_id = NULL;
+ const gchar *stock_id = NULL;
event_name = gimp_controller_get_event_name (controller, i);
event_blurb = gimp_controller_get_event_blurb (controller, i);
@@ -322,7 +322,7 @@ gimp_controller_editor_constructor (GType type,
action = gimp_ui_manager_find_action (ui_manager, NULL, event_action);
if (action)
- g_object_get (action, "stock-id", &stock_id, NULL);
+ stock_id = gtk_action_get_stock_id (action);
}
gtk_list_store_append (store, &iter);
@@ -332,9 +332,6 @@ gimp_controller_editor_constructor (GType type,
COLUMN_STOCK_ID, stock_id,
COLUMN_ACTION, event_action,
-1);
-
- if (stock_id)
- g_free (stock_id);
}
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tv), 0,
diff --git a/app/widgets/gimpdockable.c b/app/widgets/gimpdockable.c
index 93cdf19..9f1ef4e 100644
--- a/app/widgets/gimpdockable.c
+++ b/app/widgets/gimpdockable.c
@@ -1232,9 +1232,7 @@ gimp_dockable_show_menu (GimpDockable *dockable)
if (gtk_icon_theme_has_icon (gtk_icon_theme_get_default (),
dockable->stock_id))
{
- g_object_set (parent_menu_action,
- "icon-name", dockable->stock_id,
- NULL);
+ gtk_action_set_icon_name (parent_menu_action, dockable->stock_id);
}
}
diff --git a/app/widgets/gimpeditor.c b/app/widgets/gimpeditor.c
index 2dc3bda..df84d4a 100644
--- a/app/widgets/gimpeditor.c
+++ b/app/widgets/gimpeditor.c
@@ -615,7 +615,7 @@ gimp_editor_add_action_button (GimpEditor *editor,
GtkWidget *image;
GtkIconSize button_icon_size;
GtkReliefStyle button_relief;
- gchar *stock_id;
+ const gchar *stock_id;
gchar *tooltip;
const gchar *help_id;
GList *extended = NULL;
@@ -648,10 +648,8 @@ gimp_editor_add_action_button (GimpEditor *editor,
gtk_button_set_relief (GTK_BUTTON (button), button_relief);
- g_object_get (action,
- "stock-id", &stock_id,
- "tooltip", &tooltip,
- NULL);
+ stock_id = gtk_action_get_stock_id (action);
+ tooltip = g_strdup (gtk_action_get_tooltip (action));
old_child = gtk_bin_get_child (GTK_BIN (button));
@@ -662,8 +660,6 @@ gimp_editor_add_action_button (GimpEditor *editor,
gtk_container_add (GTK_CONTAINER (button), image);
gtk_widget_show (image);
- g_free (stock_id);
-
gtk_activatable_set_related_action (GTK_ACTIVATABLE (button), action);
gtk_box_pack_start (GTK_BOX (editor->button_box), button, TRUE, TRUE, 0);
gtk_widget_show (button);
@@ -692,17 +688,13 @@ gimp_editor_add_action_button (GimpEditor *editor,
if (tooltip)
{
- gchar *ext_tooltip;
-
- g_object_get (action, "tooltip", &ext_tooltip, NULL);
+ const gchar *ext_tooltip = gtk_action_get_tooltip (action);
if (ext_tooltip)
{
gchar *tmp = g_strconcat (tooltip, "\n<b>",
gimp_get_mod_string (mod_mask),
"</b> ", ext_tooltip, NULL);
-
- g_free (ext_tooltip);
g_free (tooltip);
tooltip = tmp;
}
diff --git a/app/widgets/gimpradioaction.c b/app/widgets/gimpradioaction.c
index fd8808f..ca63334 100644
--- a/app/widgets/gimpradioaction.c
+++ b/app/widgets/gimpradioaction.c
@@ -82,18 +82,18 @@ gimp_radio_action_new (const gchar *name,
GtkRadioAction *action;
action = g_object_new (GIMP_TYPE_RADIO_ACTION,
- "name", name,
- "label", label,
- "tooltip", tooltip,
- "value", value,
+ "name", name,
+ "label", label,
+ "tooltip", tooltip,
+ "value", value,
NULL);
if (stock_id)
{
if (gtk_icon_factory_lookup_default (stock_id))
- g_object_set (action, "stock-id", stock_id, NULL);
+ gtk_action_set_stock_id (GTK_ACTION (action), stock_id);
else
- g_object_set (action, "icon-name", stock_id, NULL);
+ gtk_action_set_icon_name (GTK_ACTION (action), stock_id);
}
return action;
@@ -107,17 +107,12 @@ static void
gimp_radio_action_set_proxy_tooltip (GimpRadioAction *action,
GtkWidget *proxy)
{
- gchar *tooltip;
-
- g_object_get (action, "tooltip", &tooltip, NULL);
+ const gchar *tooltip = gtk_action_get_tooltip (GTK_ACTION (action));
if (tooltip)
- {
- gimp_help_set_help_data (proxy, tooltip,
- g_object_get_qdata (G_OBJECT (proxy),
- GIMP_HELP_ID));
- g_free (tooltip);
- }
+ gimp_help_set_help_data (proxy, tooltip,
+ g_object_get_qdata (G_OBJECT (proxy),
+ GIMP_HELP_ID));
}
static void
diff --git a/app/widgets/gimpstringaction.c b/app/widgets/gimpstringaction.c
index a6a632c..0d8c4fc 100644
--- a/app/widgets/gimpstringaction.c
+++ b/app/widgets/gimpstringaction.c
@@ -170,7 +170,7 @@ gimp_string_action_new (const gchar *name,
if (stock_id)
{
if (gtk_icon_theme_has_icon (gtk_icon_theme_get_default (), stock_id))
- g_object_set (action, "icon-name", stock_id, NULL);
+ gtk_action_set_icon_name (GTK_ACTION (action), stock_id);
}
return action;
diff --git a/app/widgets/gimptoggleaction.c b/app/widgets/gimptoggleaction.c
index 2678e97..335aeff 100644
--- a/app/widgets/gimptoggleaction.c
+++ b/app/widgets/gimptoggleaction.c
@@ -81,18 +81,17 @@ gimp_toggle_action_new (const gchar *name,
GtkToggleAction *action;
action = g_object_new (GIMP_TYPE_TOGGLE_ACTION,
- "name", name,
- "label", label,
- "tooltip", tooltip,
- "stock-id", stock_id,
+ "name", name,
+ "label", label,
+ "tooltip", tooltip,
NULL);
if (stock_id)
{
if (gtk_icon_factory_lookup_default (stock_id))
- g_object_set (action, "stock-id", stock_id, NULL);
+ gtk_action_set_stock_id (GTK_ACTION (action), stock_id);
else
- g_object_set (action, "icon-name", stock_id, NULL);
+ gtk_action_set_icon_name (GTK_ACTION (action), stock_id);
}
return action;
@@ -106,17 +105,12 @@ static void
gimp_toggle_action_set_proxy_tooltip (GimpToggleAction *action,
GtkWidget *proxy)
{
- gchar *tooltip;
-
- g_object_get (action, "tooltip", &tooltip, NULL);
+ const gchar *tooltip = gtk_action_get_tooltip (GTK_ACTION (action));
if (tooltip)
- {
- gimp_help_set_help_data (proxy, tooltip,
- g_object_get_qdata (G_OBJECT (proxy),
- GIMP_HELP_ID));
- g_free (tooltip);
- }
+ gimp_help_set_help_data (proxy, tooltip,
+ g_object_get_qdata (G_OBJECT (proxy),
+ GIMP_HELP_ID));
}
static void
diff --git a/app/widgets/gimpuimanager.c b/app/widgets/gimpuimanager.c
index 6a2661f..740b6f3 100644
--- a/app/widgets/gimpuimanager.c
+++ b/app/widgets/gimpuimanager.c
@@ -916,15 +916,10 @@ gimp_ui_manager_menu_item_select (GtkWidget *widget,
if (action)
{
- gchar *tooltip;
-
- g_object_get (action, "tooltip", &tooltip, NULL);
+ const gchar *tooltip = gtk_action_get_tooltip (action);
if (tooltip)
- {
- g_signal_emit (manager, manager_signals[SHOW_TOOLTIP], 0, tooltip);
- g_free (tooltip);
- }
+ g_signal_emit (manager, manager_signals[SHOW_TOOLTIP], 0, tooltip);
}
}
diff --git a/app/widgets/gimpwidgets-utils.c b/app/widgets/gimpwidgets-utils.c
index bbc31b1..d5491f1 100644
--- a/app/widgets/gimpwidgets-utils.c
+++ b/app/widgets/gimpwidgets-utils.c
@@ -1030,12 +1030,12 @@ gimp_widget_accel_changed (GtkAccelGroup *accel_group,
{
GtkAction *action;
GtkAccelKey *accel_key;
- gchar *tooltip;
+ const gchar *tooltip;
const gchar *help_id;
action = g_object_get_data (G_OBJECT (widget), "gimp-accel-action");
- g_object_get (action, "tooltip", &tooltip, NULL);
+ tooltip = gtk_action_get_tooltip (action);
help_id = g_object_get_qdata (G_OBJECT (action), GIMP_HELP_ID);
accel_key = gtk_accel_group_find (accel_group,
@@ -1061,8 +1061,6 @@ gimp_widget_accel_changed (GtkAccelGroup *accel_group,
{
gimp_help_set_help_data (widget, tooltip, help_id);
}
-
- g_free (tooltip);
}
}
@@ -1094,15 +1092,13 @@ gimp_widget_set_accel_help (GtkWidget *widget,
}
else
{
- gchar *tooltip;
- gchar *help_id;
+ const gchar *tooltip;
+ const gchar *help_id;
- g_object_get (action, "tooltip", &tooltip, NULL);
+ tooltip = gtk_action_get_tooltip (action);
help_id = g_object_get_qdata (G_OBJECT (action), GIMP_HELP_ID);
gimp_help_set_help_data (widget, tooltip, help_id);
-
- g_free (tooltip);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]