Exemplo n.º 1
0
static void
photos_searchbar_search_changed (PhotosSearchbar *self)
{
  PhotosSearchbarPrivate *priv = self->priv;

  if (priv->search_change_blocked)
    return;

  PHOTOS_SEARCHBAR_GET_CLASS (self)->entry_changed (self);
}
Exemplo n.º 2
0
static void
photos_searchbar_constructed (GObject *object)
{
  PhotosSearchbar *self = PHOTOS_SEARCHBAR (object);
  PhotosSearchbarPrivate *priv;
  GApplication *app;
  GtkToolItem *item;
  GVariant *state;

  priv = photos_searchbar_get_instance_private (self);

  G_OBJECT_CLASS (photos_searchbar_parent_class)->constructed (object);

  PHOTOS_SEARCHBAR_GET_CLASS (self)->create_search_widgets (self);

  item = gtk_tool_item_new ();
  gtk_tool_item_set_expand (item, TRUE);
  gtk_container_add (GTK_CONTAINER (item), priv->search_container);
  gtk_toolbar_insert (GTK_TOOLBAR (priv->toolbar), item, 0);

  g_signal_connect_swapped (priv->search_entry,
                            "search-changed",
                            G_CALLBACK (photos_searchbar_search_changed),
                            self);


  app = g_application_get_default ();
  priv->search = g_action_map_lookup_action (G_ACTION_MAP (app), "search");

  /* g_signal_connect_object will not be able to disconnect the
   * handler in time because we change the state of the action during
   * dispose.
   */
  priv->search_state_id = g_signal_connect_swapped (priv->search,
                                                    "change-state",
                                                    G_CALLBACK (photos_searchbar_change_state),
                                                    self);
  state = g_action_get_state (priv->search);
  photos_searchbar_change_state (self, state);
  g_variant_unref (state);

  gtk_widget_show_all (GTK_WIDGET (self));
}
Exemplo n.º 3
0
static void
photos_searchbar_constructed (GObject *object)
{
  PhotosSearchbar *self = PHOTOS_SEARCHBAR (object);
  PhotosSearchbarPrivate *priv = self->priv;
  GtkToolItem *item;
  GVariant *state;

  G_OBJECT_CLASS (photos_searchbar_parent_class)->constructed (object);

  PHOTOS_SEARCHBAR_GET_CLASS (self)->create_search_widgets (self);

  item = gtk_tool_item_new ();
  gtk_tool_item_set_expand (item, TRUE);
  gtk_container_add (GTK_CONTAINER (item), priv->search_container);
  gtk_toolbar_insert (GTK_TOOLBAR (priv->toolbar), item, 0);

  g_signal_connect_swapped (priv->search_entry,
                            "key-press-event",
                            G_CALLBACK (photos_searchbar_key_press_event),
                            self);
  g_signal_connect_swapped (priv->search_entry,
                            "search-changed",
                            G_CALLBACK (photos_searchbar_search_changed),
                            self);


  /* g_signal_connect_object will not be able to disconnect the
   * handler in time because we change the state of the action during
   * dispose.
   */
  priv->search_state_id = g_signal_connect_swapped (priv->app,
                                                    "action-state-changed::search",
                                                    G_CALLBACK (photos_searchbar_action_state_changed),
                                                    self);
  state = g_action_group_get_action_state (G_ACTION_GROUP (priv->app), "search");
  photos_searchbar_action_state_changed (self, "search", state);
  g_variant_unref (state);

  gtk_widget_show_all (GTK_WIDGET (self));
}