Exemple #1
0
void
glade_gtk_box_remove_child (GladeWidgetAdaptor * adaptor,
                            GObject * object, GObject * child)
{
  GladeWidget *gbox;
  gint size;
  gchar *special_child_type;

  g_return_if_fail (GTK_IS_BOX (object));
  g_return_if_fail (GTK_IS_WIDGET (child));

  gbox = glade_widget_get_from_gobject (object);

  special_child_type = g_object_get_data (child, "special-child-type");
  if (special_child_type && !strcmp (special_child_type, "center"))
    {
      GtkWidget *w;

      w = glade_placeholder_new ();
      g_object_set_data (G_OBJECT (w), "special-child-type", "center");
      gtk_box_set_center_widget (GTK_BOX (object), w);
      return;
    }

  gtk_container_remove (GTK_CONTAINER (object), GTK_WIDGET (child));

  if (glade_widget_superuser () == FALSE)
    {
      glade_widget_property_get (gbox, "size", &size);
      glade_widget_property_set (gbox, "size", size);
    }

  fix_response_id_on_child (gbox, child, FALSE);
}
Exemple #2
0
void
glade_gtk_box_set_property (GladeWidgetAdaptor * adaptor,
                            GObject * object,
                            const gchar * id, const GValue * value)
{
  if (!strcmp (id, "use-center-child"))
    {
      GtkWidget *child;

      if (g_value_get_boolean (value))
        {
          child = gtk_box_get_center_widget (GTK_BOX (object));
          if (!child)
            child = glade_placeholder_new ();
          g_object_set_data (G_OBJECT (child), "special-child-type", "center");
        }
      else
        child = NULL;
      gtk_box_set_center_widget (GTK_BOX (object), child);
    }

  else if (!strcmp (id, "size"))
    glade_gtk_box_set_size (object, value);
  else
    GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor, object, id,
                                                      value);
}
Exemple #3
0
void
glade_gtk_box_replace_child (GladeWidgetAdaptor * adaptor,
                             GObject * container,
                             GObject * current, GObject * new_widget)
{
  GladeWidget *gchild;
  GladeWidget *gbox;

  gchar *special_child_type;

  special_child_type =
      g_object_get_data (G_OBJECT (current), "special-child-type");

  if (special_child_type && !strcmp (special_child_type, "center"))
    {
      g_object_set_data (G_OBJECT (new_widget), "special-child-type", "center");
      gtk_box_set_center_widget (GTK_BOX (container), GTK_WIDGET (new_widget));
      return;
    }

  g_object_ref (G_OBJECT (current));

  GWA_GET_CLASS (GTK_TYPE_CONTAINER)->replace_child (adaptor,
                                                     container,
                                                     current, new_widget);
  gbox = glade_widget_get_from_gobject (container);

  if ((gchild = glade_widget_get_from_gobject (new_widget)) != NULL)
    /* The "Remove Slot" operation only makes sence on placeholders,
     * otherwise its a "Delete" operation on the child widget.
     */
    glade_widget_set_pack_action_visible (gchild, "remove_slot", FALSE);

  fix_response_id_on_child (gbox, current, FALSE);
  fix_response_id_on_child (gbox, new_widget, TRUE);

  g_object_unref (G_OBJECT (current));
}
static void
egg_search_bar_init (EggSearchBar *self)
{
  EggSearchBarPrivate *priv = egg_search_bar_get_instance_private (self);
  GtkStyleContext *style_context;
  GtkBox *box;

  priv->window_signals = egg_signal_group_new (GTK_TYPE_WINDOW);
  egg_signal_group_connect_object (priv->window_signals,
                                   "key-press-event",
                                   G_CALLBACK (toplevel_key_press_event_before),
                                   self,
                                   G_CONNECT_SWAPPED);
  egg_signal_group_connect_object (priv->window_signals,
                                   "key-press-event",
                                   G_CALLBACK (toplevel_key_press_event_after),
                                   self,
                                   G_CONNECT_SWAPPED | G_CONNECT_AFTER);

  priv->revealer =
    g_object_new (GTK_TYPE_REVEALER,
                  "transition-type", GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN,
                  "visible", TRUE,
                  NULL);
  /* outer box used for styling */
  box =
    g_object_new (GTK_TYPE_BOX,
                  "orientation", GTK_ORIENTATION_HORIZONTAL,
                  "visible", TRUE,
                  NULL);
  priv->box =
    g_object_new (GTK_TYPE_BOX,
                  "hexpand", TRUE,
                  "margin-bottom", 3,
                  "margin-end", 6,
                  "margin-start", 6,
                  "margin-top", 3,
                  "orientation", GTK_ORIENTATION_HORIZONTAL,
                  "visible", TRUE,
                  NULL);
  priv->entry =
    g_object_connect (g_object_new (GTK_TYPE_SEARCH_ENTRY,
                                    "placeholder-text", _("Search"),
                                    "visible", TRUE,
                                    NULL),
                      "swapped_object_signal::activate", egg_search_bar__entry_activate, self,
                      NULL);
  priv->close_button =
    g_object_new (GTK_TYPE_BUTTON,
                  "child", g_object_new (GTK_TYPE_IMAGE,
                                         "icon-name", "window-close-symbolic",
                                         "visible", TRUE,
                                         NULL),
                  "visible", FALSE,
                  NULL);

  style_context = gtk_widget_get_style_context (GTK_WIDGET (box));
  gtk_style_context_add_class (style_context, "search-bar");

  gtk_container_add (GTK_CONTAINER (priv->revealer), GTK_WIDGET (box));
  gtk_container_add (GTK_CONTAINER (box), GTK_WIDGET (priv->box));
  gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (priv->revealer));
  gtk_container_add_with_properties (GTK_CONTAINER (priv->box),
                                     GTK_WIDGET (priv->close_button),
                                     "fill", FALSE,
                                     "pack-type", GTK_PACK_END,
                                     NULL);
  gtk_box_set_center_widget (priv->box, GTK_WIDGET (priv->entry));
}
Exemple #5
0
void
glade_gtk_box_add_child (GladeWidgetAdaptor * adaptor,
                         GObject * object, GObject * child)
{
  GladeWidget *gbox, *gchild;
  gint num_children;
  gchar *special_child_type;

  g_return_if_fail (GTK_IS_BOX (object));
  g_return_if_fail (GTK_IS_WIDGET (child));

  gbox = glade_widget_get_from_gobject (object);

  special_child_type = g_object_get_data (child, "special-child-type");
  if (special_child_type && !strcmp (special_child_type, "center"))
    {
      gtk_box_set_center_widget (GTK_BOX (object), GTK_WIDGET (child));
       return;
    }

  /*
     Try to remove the last placeholder if any, this way GtkBox`s size 
     will not be changed.
   */
  if (glade_widget_superuser () == FALSE && !GLADE_IS_PLACEHOLDER (child))
    {
      GList *l, *children;
      GtkBox *box = GTK_BOX (object);

      children = gtk_container_get_children (GTK_CONTAINER (box));

      for (l = g_list_last (children); l; l = g_list_previous (l))
        {
          GtkWidget *child_widget = l->data;
          if (GLADE_IS_PLACEHOLDER (child_widget))
            {
              gtk_container_remove (GTK_CONTAINER (box), child_widget);
              break;
            }
        }
      g_list_free (children);
    }

  gtk_container_add (GTK_CONTAINER (object), GTK_WIDGET (child));
  num_children = glade_gtk_box_get_num_children (object);
  glade_widget_property_set (gbox, "size", num_children);

  gchild = glade_widget_get_from_gobject (child);

  /* The "Remove Slot" operation only makes sence on placeholders,
   * otherwise its a "Delete" operation on the child widget.
   */
  if (gchild)
    glade_widget_set_pack_action_visible (gchild, "remove_slot", FALSE);

  fix_response_id_on_child (gbox, child, TRUE);
  
  if (glade_widget_superuser ())
    return;
  
  /* Packing props arent around when parenting during a glade_widget_dup() */
  if (gchild && glade_widget_get_packing_properties (gchild))
    glade_widget_pack_property_set (gchild, "position", num_children - 1);
}