summaryrefslogtreecommitdiff
path: root/plugins/gtk+/glade-gtk-action.c
blob: 6623753f184d8c1da2c4a36eb4a05de683490d9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
 * glade-gtk-action.c - GladeWidgetAdaptor for GtkAction
 *
 * Copyright (C) 2013 Tristan Van Berkom
 *
 * Authors:
 *      Tristan Van Berkom <tristan.van.berkom@gmail.com>
 *
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public 
 * License along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

#include <config.h>
#include <glib/gi18n-lib.h>
#include <gladeui/glade.h>

#include "glade-gtk.h"
#include "glade-action-editor.h"
#include "glade-recent-action-editor.h"

void
glade_gtk_action_post_create (GladeWidgetAdaptor *adaptor,
                              GObject            *object,
                              GladeCreateReason   reason)
{
  GladeWidget *gwidget = glade_widget_get_from_gobject (object);

  if (reason == GLADE_CREATE_REBUILD)
    return;

G_GNUC_BEGIN_IGNORE_DEPRECATIONS
  if (!gtk_action_get_name (GTK_ACTION (object)))
G_GNUC_END_IGNORE_DEPRECATIONS
    {
      glade_widget_property_set (gwidget, "name", "untitled");
    }

  glade_widget_set_action_sensitive (gwidget, "launch_editor", FALSE);
  glade_widget_property_set_sensitive (gwidget, "accelerator", FALSE, 
                                       ACTION_ACCEL_INSENSITIVE_MSG);
}

GladeEditable *
glade_gtk_action_create_editable (GladeWidgetAdaptor *adaptor,
                                  GladeEditorPageType type)
{
  GladeEditable *editable;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
  GType type_recent_action = GTK_TYPE_RECENT_ACTION;
G_GNUC_END_IGNORE_DEPRECATIONS

  if (type == GLADE_PAGE_GENERAL)
    {
      GType action_type = glade_widget_adaptor_get_object_type (adaptor);

      if (g_type_is_a (action_type, type_recent_action))
        editable = (GladeEditable *) glade_recent_action_editor_new ();
      else
        editable = (GladeEditable *) glade_action_editor_new ();
    }
  else
    editable = GLADE_WIDGET_ADAPTOR_GET_ADAPTOR_CLASS (G_TYPE_OBJECT)->create_editable (adaptor, type);

  return editable;
}