コード例 #1
0
ファイル: exampleappwin.c プロジェクト: endlessm/gtk
static void
search_text_changed (GtkEntry *entry)
{
  ExampleAppWindow *win;
  ExampleAppWindowPrivate *priv;
  const gchar *text;
  GtkWidget *tab;
  GtkWidget *view;
  GtkTextBuffer *buffer;
  GtkTextIter start, match_start, match_end;

  text = gtk_entry_get_text (entry);

  if (text[0] == '\0')
    return;

  win = EXAMPLE_APP_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (entry)));
  priv = example_app_window_get_instance_private (win);

  tab = gtk_stack_get_visible_child (GTK_STACK (priv->stack));
  view = gtk_bin_get_child (GTK_BIN (tab));
  buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));

  /* Very simple-minded search implementation */
  gtk_text_buffer_get_start_iter (buffer, &start);
  if (gtk_text_iter_forward_search (&start, text, GTK_TEXT_SEARCH_CASE_INSENSITIVE,
                                    &match_start, &match_end, NULL))
    {
      gtk_text_buffer_select_range (buffer, &match_start, &match_end);
      gtk_text_view_scroll_to_iter (GTK_TEXT_VIEW (view), &match_start,
                                    0.0, FALSE, 0.0, 0.0);
    }
}
コード例 #2
0
ファイル: code0_app.c プロジェクト: shawn-peng/Code0
static void preferences_activated(GSimpleAction *action, GVariant *parameter,
		gpointer app)
{
	Code0AppPrefs *prefs;
	GtkWindow *win;

	win = gtk_application_get_active_window(GTK_APPLICATION(app));
	prefs = example_app_prefs_new(EXAMPLE_APP_WINDOW(win));
	gtk_window_present(GTK_WINDOW(prefs));
}
コード例 #3
0
ファイル: exampleappwin.c プロジェクト: Distrotech/gtk
static void
example_app_window_dispose (GObject *object)
{
  ExampleAppWindow *win;
  ExampleAppWindowPrivate *priv;

  win = EXAMPLE_APP_WINDOW (object);
  priv = example_app_window_get_instance_private (win);

  g_clear_object (&priv->settings);

  G_OBJECT_CLASS (example_app_window_parent_class)->dispose (object);
}
コード例 #4
0
ファイル: exampleappwin.c プロジェクト: endlessm/gtk
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);
}
コード例 #5
0
ファイル: code0_app.c プロジェクト: shawn-peng/Code0
static void example_app_open(GApplication *app, GFile **files, gint n_files,
		const gchar *hint)
{
	GList *windows;
	Code0Window *win;
	int i;

	windows = gtk_application_get_windows(GTK_APPLICATION(app));
	if (windows)
		win = EXAMPLE_APP_WINDOW(windows->data);
	else
		win = example_app_window_new(EXAMPLE_APP(app));

	for (i = 0; i < n_files; i++)
		example_app_window_open(win, files[i]);

	gtk_window_present(GTK_WINDOW(win));
}