summaryrefslogtreecommitdiff
path: root/plugins/gtk+/glade-gtk-about-dialog.c
blob: 92d80574abeb0aca7d2708cf76717c42b0c7093f (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
 * glade-gtk-about-dialog.c - GladeWidgetAdaptor for GtkAboutDialog
 *
 * 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"

GObject *
glade_gtk_about_dialog_construct_object (GladeWidgetAdaptor *adaptor,
                                         guint               n_parameters,
                                         GParameter         *parameters)
{
  GParameter *new_params = g_new0 (GParameter, n_parameters + 1);
  gboolean use_header_bar_set = FALSE;
  GObject *retval;
  gint i;

  /* Here we need to force use-header-bar to FALSE in the runtime because
   * GtkAboutDialog set it to TRUE in its contructor which then triggers a
   * warning when glade tries to add placeholders in the action area
   */
  for (i = 0; i < n_parameters; i++)
    {
      new_params[i] = parameters[i];

      if (!g_strcmp0 (new_params[i].name, "use-header-bar"))
        {
          /* force the value to 0 */
          g_value_set_int (&new_params[i].value, 0);
          use_header_bar_set = TRUE;
        }
    }

  if (!use_header_bar_set)
    {
      GParameter *use_header = &new_params[n_parameters++];

      /* append value if it was not part of the parameters */
      use_header->name = "use-header-bar";
      g_value_init (&use_header->value, G_TYPE_INT);
      g_value_set_int (&use_header->value, 0);
    }

  retval = GWA_GET_CLASS (GTK_TYPE_DIALOG)->construct_object (adaptor, n_parameters, new_params);
  g_free (new_params);
  return retval;
}

void
glade_gtk_about_dialog_read_widget (GladeWidgetAdaptor *adaptor,
				    GladeWidget        *widget,
                                    GladeXmlNode       *node)
{
  if (!(glade_xml_node_verify_silent (node, GLADE_XML_TAG_WIDGET) ||
	glade_xml_node_verify_silent (node, GLADE_XML_TAG_TEMPLATE)))
    return;

  /* First chain up and read in all the normal properties.. */
  GWA_GET_CLASS (GTK_TYPE_WIDGET)->read_widget (adaptor, widget, node);

  /* Sync the logo icon mode */
  if (glade_widget_property_original_default (widget, "logo") == FALSE)
    glade_widget_property_set (widget, "glade-logo-as-file", TRUE);
  else
    glade_widget_property_set (widget, "glade-logo-as-file", FALSE);
}

void
glade_gtk_about_dialog_set_property (GladeWidgetAdaptor *adaptor,
				     GObject            *object,
				     const gchar        *id,
                                     const GValue       *value)
{
  if (!strcmp (id, "glade-logo-as-file"))
    {
      GladeWidget *gwidget = glade_widget_get_from_gobject (object);
      GladeProperty *logo = glade_widget_get_property (gwidget, "logo");
      GladeProperty *icon = glade_widget_get_property (gwidget, "logo-icon-name");
      gboolean as_file = g_value_get_boolean (value);

      glade_property_set_sensitive (icon, !as_file, as_file ? NOT_SELECTED_MSG : NULL);
      glade_property_set_enabled (icon, !as_file);

      glade_property_set_sensitive (logo, as_file, as_file ? NULL : NOT_SELECTED_MSG);
      glade_property_set_enabled (logo, as_file);
    }
  else
    GWA_GET_CLASS (GTK_TYPE_DIALOG)->set_property (adaptor, object, id, value);
}