Use the new GtkAction accessors instead of g_object_get()/set()

This commit is contained in:
Michael Natterer
2009-05-24 22:29:18 +02:00
parent be21d3a1e3
commit c9674b4603
12 changed files with 49 additions and 101 deletions

View File

@ -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);
}
}
}

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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,

View File

@ -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);
}
}

View File

@ -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;
}

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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);
}
}

View File

@ -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);
}
}