Ejemplo n.º 1
0
/* Code adapted from gtktreeview.c:gtk_tree_view_key_press() and
 * gtk_tree_view_real_start_interactive_seach()
 */
static gboolean
tab_search_key_press_cb (WebKitWebView *web_view,
			 GdkEventKey *event,
			 EphyFindToolbar *toolbar)
{
	GtkWidget *widget = (GtkWidget *) toolbar;

	g_return_val_if_fail (event != NULL, FALSE);

	/* check for / and ' which open the find toolbar in text resp. link mode */
	if (gtk_search_bar_get_search_mode (GTK_SEARCH_BAR (widget)) == FALSE)
	{
		if (event->keyval == GDK_KEY_slash)
		{
			ephy_find_toolbar_open (toolbar, FALSE, TRUE);
			return TRUE;
		}
		else if (event->keyval == GDK_KEY_apostrophe)
		{
			ephy_find_toolbar_open (toolbar, TRUE, TRUE);
			return TRUE;
		}
	}

	return FALSE;
}
Ejemplo n.º 2
0
static void
gtk_search_bar_add (GtkContainer *container,
                    GtkWidget    *child)
{
  GtkSearchBar *bar = GTK_SEARCH_BAR (container);
  GtkSearchBarPrivate *priv = gtk_search_bar_get_instance_private (bar);

  /* When constructing the widget, we want the revealer to be added
   * as the first child of the search bar, as an implementation detail.
   * After that, the child added by the application should be added
   * to box_center.
   */
  if (priv->box_center == NULL)
    {
      GTK_CONTAINER_CLASS (gtk_search_bar_parent_class)->add (container, child);
    }
  else
    {
      gtk_container_add (GTK_CONTAINER (priv->box_center), child);
      /* If an entry is the only child, save the developer a couple of
       * lines of code
       */
      if (GTK_IS_ENTRY (child))
        gtk_search_bar_connect_entry (bar, GTK_ENTRY (child));
    }
}
Ejemplo n.º 3
0
static void 
create_proc_view(GsmApplication *app, GtkBuilder * builder)
{
    GsmTreeView *proctree;
    GtkScrolledWindow *scrolled;

    proctree = proctable_new (app);
    scrolled = GTK_SCROLLED_WINDOW (gtk_builder_get_object (builder, "processes_scrolled"));

    gtk_container_add (GTK_CONTAINER (scrolled), GTK_WIDGET (proctree));

    app->proc_actionbar_revealer = GTK_REVEALER (gtk_builder_get_object (builder, "proc_actionbar_revealer"));

    /* create popup_menu for the processes tab */
    GMenuModel *menu_model = G_MENU_MODEL (gtk_builder_get_object (builder, "process-popup-menu"));
    app->popup_menu = GTK_MENU (gtk_menu_new_from_model (menu_model));
    gtk_menu_attach_to_widget (app->popup_menu, GTK_WIDGET (app->main_window), NULL);
    
    app->search_bar = GTK_SEARCH_BAR (gtk_builder_get_object (builder, "proc_searchbar"));
    app->search_entry = GTK_SEARCH_ENTRY (gtk_builder_get_object (builder, "proc_searchentry"));
    
    gtk_search_bar_connect_entry (app->search_bar, GTK_ENTRY (app->search_entry));
    g_signal_connect (app->main_window, "key-press-event",
                      G_CALLBACK (cb_window_key_press_event), app->search_bar);
                  
    g_signal_connect (app->search_entry, "changed", G_CALLBACK (search_text_changed), app);

    g_object_bind_property (app->search_bar, "search-mode-enabled", app->search_button, "active", (GBindingFlags)(G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE));
}
Ejemplo n.º 4
0
gboolean
gt_games_view_handle_event(GtGamesView* self, GdkEvent* event)
{
    GtGamesViewPrivate* priv = gt_games_view_get_instance_private(self);

    return gtk_search_bar_handle_event(GTK_SEARCH_BAR(priv->search_bar), event);
}
Ejemplo n.º 5
0
void
ephy_find_toolbar_request_close (EphyFindToolbar *toolbar)
{
	if (gtk_search_bar_get_search_mode (GTK_SEARCH_BAR (toolbar)))
	{
		g_signal_emit (toolbar, signals[CLOSE], 0);
	}
}
Ejemplo n.º 6
0
void
gb_editor_tab_find (GbEditorTab *tab)
{
   g_return_if_fail (GB_IS_EDITOR_TAB (tab));

   gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (tab->priv->search_bar), TRUE);
   gtk_widget_grab_focus (tab->priv->search_entry);
}
Ejemplo n.º 7
0
void
ephy_find_toolbar_open (EphyFindToolbar *toolbar,
			gboolean links_only,
			gboolean typing_ahead)
{
	g_return_if_fail (toolbar->web_view != NULL);

	toolbar->typing_ahead = typing_ahead;
	toolbar->links_only = links_only;

	clear_status (toolbar);

	gtk_editable_select_region (GTK_EDITABLE (toolbar->entry), 0, -1);

	gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (toolbar), TRUE);
	gtk_search_bar_set_show_close_button (GTK_SEARCH_BAR (toolbar), TRUE);
	gtk_widget_grab_focus (toolbar->entry);
}
Ejemplo n.º 8
0
void
ephy_find_toolbar_close (EphyFindToolbar *toolbar)
{
	gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (toolbar), FALSE);

	if (toolbar->web_view == NULL) return;

        webkit_find_controller_search_finish (toolbar->controller);
}
Ejemplo n.º 9
0
static void
gtk_search_bar_dispose (GObject *object)
{
  GtkSearchBar *bar = GTK_SEARCH_BAR (object);

  gtk_search_bar_set_entry (bar, NULL);

  G_OBJECT_CLASS (gtk_search_bar_parent_class)->dispose (object);
}
Ejemplo n.º 10
0
static gboolean
cb_window_key_press_event (GtkWidget *widget, GdkEvent *event, gpointer user_data)
{
    const char *current_page = gtk_stack_get_visible_child_name (GTK_STACK (GsmApplication::get()->stack));

    if (strcmp (current_page, "processes") == 0)
        return gtk_search_bar_handle_event (GTK_SEARCH_BAR (user_data), event);
    
    return FALSE;
}
Ejemplo n.º 11
0
static void
activate_search (GSimpleAction *action,
                 GVariant      *parameter,
                 gpointer       user_data)
{
  GtkWidget *window = user_data;
  GtkWidget *searchbar;

  searchbar = GTK_WIDGET (g_object_get_data (G_OBJECT (window), "searchbar"));
  gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (searchbar), TRUE);
}
Ejemplo n.º 12
0
static void
ephy_find_toolbar_load_changed_cb (WebKitWebView   *web_view,
				   WebKitLoadEvent  load_event,
				   EphyFindToolbar *toolbar)
{
	if (load_event == WEBKIT_LOAD_STARTED &&
	    gtk_search_bar_get_search_mode (GTK_SEARCH_BAR (toolbar)))
	{
		ephy_find_toolbar_close (toolbar);
	}
}
Ejemplo n.º 13
0
void
ephy_find_toolbar_toggle_state (EphyFindToolbar *toolbar)
{
	if (gtk_search_bar_get_search_mode (GTK_SEARCH_BAR (toolbar)))
	{
		ephy_find_toolbar_close (toolbar);
	}
	else
	{
		ephy_find_toolbar_open (toolbar, FALSE, FALSE);
	}
}
Ejemplo n.º 14
0
gboolean
bjb_window_base_get_show_search_bar (BjbWindowBase *self)
{

  /* There is no search bar at startup,
   * when main toolbar is first built... */
  if (!self->priv->search_bar)
    return FALSE;

  return gtk_search_bar_get_search_mode (
            GTK_SEARCH_BAR (self->priv->search_bar));
}
Ejemplo n.º 15
0
static void
gt_container_view_init(GtContainerView* self)
{
    GtContainerViewPrivate* priv = gt_container_view_get_instance_private(self);

    gtk_widget_init_template(GTK_WIDGET(self));

    gtk_search_bar_connect_entry(GTK_SEARCH_BAR(priv->search_bar),
        GTK_ENTRY(priv->search_entry));

    g_object_bind_property(self, "search-active",
        priv->search_bar, "search-mode-enabled",
        G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
}
Ejemplo n.º 16
0
static void
gtk_search_bar_dispose (GObject *object)
{
    GtkSearchBar *bar = GTK_SEARCH_BAR (object);
    GtkSearchBarPrivate *priv = gtk_search_bar_get_instance_private (bar);

    if (priv->entry)
    {
        g_signal_handlers_disconnect_by_func (priv->entry, entry_key_pressed_event_cb, bar);
        g_object_remove_weak_pointer (G_OBJECT (priv->entry), (gpointer *) &priv->entry);
        priv->entry = NULL;
    }

    G_OBJECT_CLASS (gtk_search_bar_parent_class)->dispose (object);
}
Ejemplo n.º 17
0
static void
visible_child_changed (GObject    *stack,
                       GParamSpec *pspec)
{
  ExampleAppWindow *win;
  ExampleAppWindowPrivate *priv;

  if (gtk_widget_in_destruction (GTK_WIDGET (stack)))
    return;

  win = EXAMPLE_APP_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (stack)));
  priv = example_app_window_get_instance_private (win);
  gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (priv->searchbar), FALSE);
  update_words (win);
  update_lines (win);
}
Ejemplo n.º 18
0
static void
gtk_search_bar_set_property (GObject      *object,
                             guint         prop_id,
                             const GValue *value,
                             GParamSpec   *pspec)
{
  GtkSearchBar *bar = GTK_SEARCH_BAR (object);

  switch (prop_id)
    {
    case PROP_SEARCH_MODE_ENABLED:
      gtk_search_bar_set_search_mode (bar, g_value_get_boolean (value));
      break;
    case PROP_SHOW_CLOSE_BUTTON:
      gtk_search_bar_set_show_close_button (bar, g_value_get_boolean (value));
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}
Ejemplo n.º 19
0
static void
gtk_search_bar_get_property (GObject    *object,
                             guint       prop_id,
                             GValue     *value,
                             GParamSpec *pspec)
{
  GtkSearchBar *bar = GTK_SEARCH_BAR (object);
  GtkSearchBarPrivate *priv = gtk_search_bar_get_instance_private (bar);

  switch (prop_id)
    {
    case PROP_SEARCH_MODE_ENABLED:
      g_value_set_boolean (value, priv->reveal_child);
      break;
    case PROP_SHOW_CLOSE_BUTTON:
      g_value_set_boolean (value, gtk_search_bar_get_show_close_button (bar));
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}
Ejemplo n.º 20
0
static void
construct_appchooser_widget (GtkAppChooserDialog *self)
{
  GAppInfo *info;

  /* Need to build the appchooser widget after, because of the content-type construct-only property */
  self->priv->app_chooser_widget = gtk_app_chooser_widget_new (self->priv->content_type);
  gtk_widget_set_vexpand (self->priv->app_chooser_widget, TRUE);
  gtk_box_pack_start (GTK_BOX (self->priv->inner_box), self->priv->app_chooser_widget);


  g_signal_connect (self->priv->app_chooser_widget, "application-selected",
                    G_CALLBACK (widget_application_selected_cb), self);
  g_signal_connect (self->priv->app_chooser_widget, "application-activated",
                    G_CALLBACK (widget_application_activated_cb), self);
  g_signal_connect (self->priv->app_chooser_widget, "notify::show-other",
                    G_CALLBACK (widget_notify_for_button_cb), self);
  g_signal_connect (self->priv->app_chooser_widget, "populate-popup",
                    G_CALLBACK (widget_populate_popup_cb), self);

  /* Add the custom button to the new appchooser */
  gtk_box_pack_start (GTK_BOX (self->priv->inner_box),
                      self->priv->show_more_button);

  gtk_box_pack_start (GTK_BOX (self->priv->inner_box),
                      self->priv->software_button);

  info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (self->priv->app_chooser_widget));
  gtk_dialog_set_response_sensitive (GTK_DIALOG (self), GTK_RESPONSE_OK, info != NULL);
  if (info)
    g_object_unref (info);

  _gtk_app_chooser_widget_set_search_entry (GTK_APP_CHOOSER_WIDGET (self->priv->app_chooser_widget),
                                            GTK_ENTRY (self->priv->search_entry));

  gtk_search_bar_set_key_capture_widget (GTK_SEARCH_BAR (self->priv->search_bar),
                                         GTK_WIDGET (self));
}
Ejemplo n.º 21
0
GtkWidget *
do_search_entry2 (GtkWidget *do_widget)
{
  GtkWidget *vbox;
  GtkWidget *hbox;
  GtkWidget *label;
  GtkWidget *entry;
  GtkWidget *container;
  GtkWidget *searchbar;
  GtkWidget *button;

  if (!window)
    {
      window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
      gtk_window_set_title (GTK_WINDOW (window), "Delayed Search Entry");
      gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
      gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
      gtk_widget_set_size_request (window, 200, -1);

      g_signal_connect (window, "destroy",
                        G_CALLBACK (search_entry_destroyed), &window);

      vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
      gtk_container_add (GTK_CONTAINER (window), vbox);
      gtk_container_set_border_width (GTK_CONTAINER (vbox), 0);

      entry = gtk_search_entry_new ();
      container = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
      gtk_widget_set_halign (container, GTK_ALIGN_CENTER);
      gtk_box_pack_start (GTK_BOX (container), entry, FALSE, FALSE, 0);
      searchbar = gtk_search_bar_new ();
      gtk_search_bar_connect_entry (GTK_SEARCH_BAR (searchbar), GTK_ENTRY (entry));
      gtk_search_bar_set_show_close_button (GTK_SEARCH_BAR (searchbar), FALSE);
      gtk_container_add (GTK_CONTAINER (searchbar), container);
      gtk_box_pack_start (GTK_BOX (vbox), searchbar, FALSE, FALSE, 0);

      /* Hook the search bar to key presses */
      g_signal_connect (window, "key-press-event",
                        G_CALLBACK (window_key_press_event_cb), searchbar);

      /* Help */
      label = gtk_label_new ("Start Typing to search");
      gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);

      /* Toggle button */
      button = gtk_toggle_button_new_with_label ("Search");
      g_object_bind_property (button, "active",
                              searchbar, "search-mode-enabled",
                              G_BINDING_BIDIRECTIONAL);
      gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);

      /* Result */
      hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
      gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
      gtk_container_set_border_width (GTK_CONTAINER (hbox), 0);

      label = gtk_label_new ("Result:");
      gtk_label_set_xalign (GTK_LABEL (label), 0.0);
      gtk_widget_set_margin_start (label, 6);
      gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);

      label = gtk_label_new ("");
      gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);

      g_signal_connect (entry, "search-changed",
                        G_CALLBACK (search_changed_cb), label);
      g_signal_connect (entry, "changed",
                        G_CALLBACK (changed_cb), label);

      hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
      gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
      gtk_container_set_border_width (GTK_CONTAINER (hbox), 0);

      label = gtk_label_new ("Signal:");
      gtk_label_set_xalign (GTK_LABEL (label), 0.0);
      gtk_widget_set_margin_start (label, 6);
      gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);

      label = gtk_label_new ("");
      gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);

      g_signal_connect (entry, "search-changed",
                        G_CALLBACK (search_changed), label);
      g_signal_connect (entry, "next-match",
                        G_CALLBACK (next_match), label);
      g_signal_connect (entry, "previous-match",
                        G_CALLBACK (previous_match), label);
      g_signal_connect (entry, "stop-search",
                        G_CALLBACK (stop_search), label);
    }

  if (!gtk_widget_get_visible (window))
    gtk_widget_show_all (window);
  else
    {
      gtk_widget_destroy (window);
      window = NULL;
    }

  return window;
}
Ejemplo n.º 22
0
static void
ephy_find_toolbar_init (EphyFindToolbar *toolbar)
{
	GtkWidget *box;
	GtkSizeGroup *size_group;

	size_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);

	box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	gtk_style_context_add_class (gtk_widget_get_style_context (box),
				     GTK_STYLE_CLASS_RAISED);
	gtk_style_context_add_class (gtk_widget_get_style_context (box),
				     GTK_STYLE_CLASS_LINKED);
	gtk_container_add (GTK_CONTAINER (toolbar), box);

	toolbar->entry = gtk_entry_new ();
	gtk_entry_set_width_chars (GTK_ENTRY (toolbar->entry), 32);
	gtk_entry_set_max_length (GTK_ENTRY (toolbar->entry), 512);
	gtk_entry_set_placeholder_text (GTK_ENTRY (toolbar->entry), _("Type to search…"));
	gtk_container_add (GTK_CONTAINER (box), toolbar->entry);

	/* Prev */
	toolbar->prev = gtk_button_new_from_icon_name ("go-up-symbolic", GTK_ICON_SIZE_MENU);
	gtk_widget_set_tooltip_text (toolbar->prev,
				     _("Find previous occurrence of the search string"));
	gtk_container_add (GTK_CONTAINER (box), toolbar->prev);
	gtk_widget_show_all (toolbar->prev);
	gtk_widget_set_sensitive (toolbar->prev, FALSE);

	/* Next */
	toolbar->next = gtk_button_new_from_icon_name ("go-down-symbolic", GTK_ICON_SIZE_MENU);
	gtk_widget_set_tooltip_text (toolbar->next,
				     _("Find next occurrence of the search string"));
	gtk_container_add (GTK_CONTAINER (box), toolbar->next);
	gtk_widget_set_sensitive (toolbar->next, FALSE);

	gtk_size_group_add_widget (size_group, toolbar->entry);
	gtk_size_group_add_widget (size_group, toolbar->next);
	gtk_size_group_add_widget (size_group, toolbar->prev);
	g_object_unref (size_group);

	/* connect signals */
	g_signal_connect (toolbar->entry, "icon-release",
			  G_CALLBACK (search_entry_clear_cb), toolbar);
	g_signal_connect (toolbar->entry, "key-press-event",
			  G_CALLBACK (entry_key_press_event_cb), toolbar);
	g_signal_connect_after (toolbar->entry, "changed",
				G_CALLBACK (search_entry_changed_cb), toolbar);
	g_signal_connect (toolbar->entry, "activate",
			  G_CALLBACK (entry_activate_cb), toolbar);
	g_signal_connect_swapped (toolbar->next, "clicked",
				  G_CALLBACK (ephy_find_toolbar_find_next), toolbar);
	g_signal_connect_swapped (toolbar->prev, "clicked",
				  G_CALLBACK (ephy_find_toolbar_find_previous), toolbar);
	gtk_search_bar_connect_entry (GTK_SEARCH_BAR (toolbar),
				      GTK_ENTRY (toolbar->entry));

	search_entry_changed_cb (GTK_ENTRY (toolbar->entry), toolbar);

	gtk_widget_show_all (GTK_WIDGET (toolbar));
}
Ejemplo n.º 23
0
Archivo: gtk_glue.c Proyecto: Blei/rgtk
GtkSearchBar* cast_GtkSearchBar(GtkWidget* widget) {
    return GTK_SEARCH_BAR(widget);
}