示例#1
0
static gboolean
wrap_table_child_focus_in (GtkWidget *widget,
                           GdkEventFocus *event,
                           gpointer data)
{
    gint x, y;
    GtkWidget *container, *viewport = NULL;

    container = gtk_widget_get_parent (widget);
    if (container)
    {
        viewport = gtk_widget_get_parent (container);
    }
    g_assert (container && viewport);
    g_assert (GTK_IS_VIEWPORT (viewport));
    g_return_val_if_fail (gtk_widget_get_realized (viewport), FALSE);

    if (!wrap_table_child_visible_in (widget, viewport))
    {
        GtkAdjustment *hadj, *vadj;

        hadj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (viewport));
        vadj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (viewport));

        gtk_widget_translate_coordinates (widget, container, 0, 0, &x, &y);

        gtk_adjustment_set_value (hadj, MIN (x, gtk_adjustment_get_upper(hadj) - gtk_adjustment_get_page_size(hadj)));
        gtk_adjustment_set_value (vadj, MIN (y, gtk_adjustment_get_upper(vadj) - gtk_adjustment_get_page_size(vadj)));
    }

    return FALSE;
}
static GObject *
terminal_screen_container_constructor (GType type,
                                       guint n_construct_properties,
                                       GObjectConstructParam *construct_params)
{
	GObject *object;
	TerminalScreenContainer *container;
	TerminalScreenContainerPrivate *priv;

	object = G_OBJECT_CLASS (terminal_screen_container_parent_class)->constructor
	         (type, n_construct_properties, construct_params);

	container = TERMINAL_SCREEN_CONTAINER (object);
	priv = container->priv;

	g_assert (priv->screen != NULL);

#ifdef USE_SCROLLED_WINDOW
	priv->scrolled_window = gtk_scrolled_window_new (NULL, gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (priv->screen)));

	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->scrolled_window),
	                                priv->hscrollbar_policy,
	                                priv->vscrollbar_policy);
	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (priv->scrolled_window),
	                                     GTK_SHADOW_NONE);
	gtk_container_add (GTK_CONTAINER (priv->scrolled_window), GTK_WIDGET (priv->screen));
	gtk_widget_show (GTK_WIDGET (priv->screen));
	gtk_box_pack_end (GTK_BOX (container), priv->scrolled_window, TRUE, TRUE, 0);
	gtk_widget_show (priv->scrolled_window);

#ifdef MATE_ENABLE_DEBUG
	g_signal_connect (priv->scrolled_window, "size-allocate", G_CALLBACK (size_allocate_cb), container);
#endif

#else

	priv->hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);

	priv->vscrollbar = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (priv->screen)));

	gtk_box_pack_start (GTK_BOX (priv->hbox), GTK_WIDGET (priv->screen), TRUE, TRUE, 0);
	gtk_box_pack_start (GTK_BOX (priv->hbox), priv->vscrollbar, FALSE, FALSE, 0);

	gtk_box_pack_end (GTK_BOX (container), priv->hbox, TRUE, TRUE, 0);
	gtk_widget_show_all (priv->hbox);
#endif /* USE_SCROLLED_WINDOW */

	_terminal_screen_update_scrollbar (priv->screen);

	return object;
}
示例#3
0
static void
e_canvas_show_area (GnomeCanvas *canvas,
                    gdouble x1,
                    gdouble y1,
                    gdouble x2,
                    gdouble y2)
{
	GtkAdjustment *h, *v;
	gint dx = 0, dy = 0;
	gdouble page_size;
	gdouble lower;
	gdouble upper;
	gdouble value;

	g_return_if_fail (canvas != NULL);
	g_return_if_fail (GNOME_IS_CANVAS (canvas));

	h = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (canvas));
	page_size = gtk_adjustment_get_page_size (h);
	lower = gtk_adjustment_get_lower (h);
	upper = gtk_adjustment_get_upper (h);
	value = gtk_adjustment_get_value (h);
	dx = compute_offset (x1, x2, value, value + page_size);
	if (dx)
		gtk_adjustment_set_value (h, CLAMP (value + dx, lower, upper - page_size));

	v = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (canvas));
	page_size = gtk_adjustment_get_page_size (v);
	lower = gtk_adjustment_get_lower (v);
	upper = gtk_adjustment_get_upper (v);
	value = gtk_adjustment_get_value (v);
	dy = compute_offset (y1, y2, value, value + page_size);
	if (dy)
		gtk_adjustment_set_value (v, CLAMP (value + dy, lower, upper - page_size));
}
示例#4
0
/* Code stolen from pidgin/gtkimhtml.c */
static gboolean
chat_text_view_scroll_cb (EmpathyChatTextView *view)
{
	EmpathyChatTextViewPriv *priv;
	GtkAdjustment      *adj;
	gdouble             max_val;

	priv = GET_PRIV (view);

	adj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (view));
	max_val = gtk_adjustment_get_upper (adj) - gtk_adjustment_get_page_size (adj);

	g_return_val_if_fail (priv->scroll_time != NULL, FALSE);

	if (g_timer_elapsed (priv->scroll_time, NULL) > MAX_SCROLL_TIME) {
		/* time's up. jump to the end and kill the timer */
		gtk_adjustment_set_value (adj, max_val);
		chat_text_view_scroll_stop (view);
		return FALSE;
	}

	/* scroll by 1/3rd the remaining distance */
	gtk_adjustment_set_value (adj, gtk_adjustment_get_value (adj) + ((max_val - gtk_adjustment_get_value (adj)) / 3));
	return TRUE;
}
static void
cainteoir_document_view_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
{
	CainteoirDocumentViewPrivate *priv = CAINTEOIR_DOCUMENT_VIEW_PRIVATE(object);
	GtkScrollable *scroll = GTK_SCROLLABLE(priv->text_view);
	switch (prop_id)
	{
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
		break;
	// GtkScrollable interface:
	case PROP_HADJUSTMENT:
		g_value_set_object(value, gtk_scrollable_get_hadjustment(scroll));
		break;
	case PROP_VADJUSTMENT:
		g_value_set_object(value, gtk_scrollable_get_vadjustment(scroll));
		break;
	case PROP_HSCROLL_POLICY:
		g_value_set_enum(value, gtk_scrollable_get_hscroll_policy(scroll));
		break;
	case PROP_VSCROLL_POLICY:
		g_value_set_enum(value, gtk_scrollable_get_vscroll_policy(scroll));
		break;
	}
}
示例#6
0
void
nemo_icon_dnd_begin_drag (NemoIconContainer *container,
			      GdkDragAction actions,
			      int button,
			      GdkEventMotion *event,
			      int                    start_x,
			      int                    start_y)
{
	NemoIconDndInfo *dnd_info;
	
	g_return_if_fail (NEMO_IS_ICON_CONTAINER (container));
	g_return_if_fail (event != NULL);

	dnd_info = container->details->dnd_info;
	g_return_if_fail (dnd_info != NULL);
	
	/* Notice that the event is in bin_window coordinates, because of
           the way the canvas handles events.
	*/
	dnd_info->drag_info.start_x = start_x -
		gtk_adjustment_get_value (gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (container)));
	dnd_info->drag_info.start_y = start_y -
		gtk_adjustment_get_value (gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (container)));	

	/* start the drag */
	gtk_drag_begin (GTK_WIDGET (container),
			dnd_info->drag_info.target_list,
			actions,
			button,
			(GdkEvent *) event);
}
示例#7
0
static void
drag_begin_callback (GtkWidget      *widget,
		     GdkDragContext *context,
		     gpointer        data)
{
	NemoIconContainer *container;
	cairo_surface_t *surface;
	double x1, y1, x2, y2, winx, winy;
	int x_offset, y_offset;
	int start_x, start_y;

	container = NEMO_ICON_CONTAINER (widget);

	start_x = container->details->dnd_info->drag_info.start_x +
		gtk_adjustment_get_value (gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (container)));
	start_y = container->details->dnd_info->drag_info.start_y +
		gtk_adjustment_get_value (gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (container)));

        /* create a pixmap and mask to drag with */
        surface = nemo_icon_canvas_item_get_drag_surface (container->details->drag_icon->item);

        /* compute the image's offset */
	eel_canvas_item_get_bounds (EEL_CANVAS_ITEM (container->details->drag_icon->item),
				    &x1, &y1, &x2, &y2);
	eel_canvas_world_to_window (EEL_CANVAS (container), 
				    x1, y1,  &winx, &winy);
        x_offset = start_x - winx;
        y_offset = start_y - winy;

        cairo_surface_set_device_offset (surface, -x_offset, -y_offset);
        gtk_drag_set_icon_surface (context, surface);
        cairo_surface_destroy (surface);
}
示例#8
0
static void
ide_terminal_page_connect_terminal (IdeTerminalPage *self,
                                    VteTerminal     *terminal)
{
  GtkAdjustment *vadj;

  vadj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (terminal));

  gtk_range_set_adjustment (GTK_RANGE (self->top_scrollbar), vadj);

  g_signal_connect_object (terminal,
                           "focus-in-event",
                           G_CALLBACK (focus_in_event_cb),
                           self,
                           0);

  g_signal_connect_object (terminal,
                           "window-title-changed",
                           G_CALLBACK (window_title_changed_cb),
                           self,
                           0);

  if (terminal_has_notification_signal ())
    {
      g_signal_connect_object (terminal,
                               "notification-received",
                               G_CALLBACK (notification_received_cb),
                               self,
                               0);
    }
}
示例#9
0
static void
nemo_icon_container_receive_dropped_icons (NemoIconContainer *container,
					       GdkDragContext *context,
					       int x, int y)
{
	char *drop_target;
	gboolean local_move_only;
	double world_x, world_y;
	gboolean icon_hit;
	GdkDragAction action, real_action;

	drop_target = NULL;

	if (container->details->dnd_info->drag_info.selection_list == NULL) {
		return;
	}

	real_action = gdk_drag_context_get_selected_action (context);

	if (real_action == GDK_ACTION_ASK) {
		/* FIXME bugzilla.gnome.org 42485: This belongs in FMDirectoryView, not here. */
		/* Check for special case items in selection list */
		if (nemo_drag_selection_includes_special_link (container->details->dnd_info->drag_info.selection_list)) {
			/* We only want to move the trash */
			action = GDK_ACTION_MOVE;
		} else {
			action = GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_LINK;
		}
		real_action = nemo_drag_drop_action_ask (GTK_WIDGET (container), action);
	}

	if (real_action > 0) {
		eel_canvas_window_to_world (EEL_CANVAS (container),
					    x + gtk_adjustment_get_value (gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (container))),
					    y + gtk_adjustment_get_value (gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (container))),
					    &world_x, &world_y);

		drop_target = nemo_icon_container_find_drop_target (container, 
									context, x, y, &icon_hit, FALSE);

		local_move_only = FALSE;
		if (!icon_hit && real_action == GDK_ACTION_MOVE) {
			/* we can just move the icon positions if the move ended up in
			 * the item's parent container
			 */
			local_move_only = nemo_icon_container_selection_items_local
				(container, container->details->dnd_info->drag_info.selection_list);
		}

		if (local_move_only) {
			handle_local_move (container, world_x, world_y);
		} else {
			handle_nonlocal_move (container, real_action, world_x, world_y, drop_target, icon_hit);
		}
	}

	g_free (drop_target);
	nemo_drag_destroy_selection_list (container->details->dnd_info->drag_info.selection_list);
	container->details->dnd_info->drag_info.selection_list = NULL;
}
示例#10
0
文件: compat.c 项目: pcwalton/NetSurf
GtkAdjustment *nsgtk_layout_get_vadjustment(GtkLayout *layout)
{
#if GTK_CHECK_VERSION(3,0,0)
	return gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(layout));
#else
	return gtk_layout_get_vadjustment(layout);
#endif
}
示例#11
0
static void
get_adjustments (SoliPrintPreview  *preview,
		 GtkAdjustment     **hadj,
		 GtkAdjustment     **vadj)
{
	*hadj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (preview->layout));
	*vadj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (preview->layout));
}
示例#12
0
static void
disconnect_view (GtkSourceMap *map)
{
	GtkSourceMapPrivate *priv;
	GtkAdjustment *vadj;

	priv = gtk_source_map_get_instance_private (map);

	if (priv->view == NULL)
	{
		return;
	}

	disconnect_buffer (map);

	if (priv->buffer_binding != NULL)
	{
		g_object_remove_weak_pointer (G_OBJECT (priv->buffer_binding),
		                              (gpointer *)&priv->buffer_binding);
		g_binding_unbind (priv->buffer_binding);
		priv->buffer_binding = NULL;
	}

	if (priv->indent_width_binding != NULL)
	{
		g_object_remove_weak_pointer (G_OBJECT (priv->indent_width_binding),
		                              (gpointer *)&priv->indent_width_binding);
		g_binding_unbind (priv->indent_width_binding);
		priv->indent_width_binding = NULL;
	}

	if (priv->tab_width_binding != NULL)
	{
		g_object_remove_weak_pointer (G_OBJECT (priv->tab_width_binding),
		                              (gpointer *)&priv->tab_width_binding);
		g_binding_unbind (priv->tab_width_binding);
		priv->tab_width_binding = NULL;
	}

	if (priv->view_notify_buffer_handler != 0)
	{
		g_signal_handler_disconnect (priv->view, priv->view_notify_buffer_handler);
		priv->view_notify_buffer_handler = 0;
	}

	vadj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (priv->view));
	if (vadj != NULL)
	{
		g_signal_handler_disconnect (vadj, priv->view_vadj_value_changed_handler);
		priv->view_vadj_value_changed_handler = 0;

		g_signal_handler_disconnect (vadj, priv->view_vadj_notify_upper_handler);
		priv->view_vadj_notify_upper_handler = 0;
	}

	g_object_remove_weak_pointer (G_OBJECT (priv->view), (gpointer *)&priv->view);
	priv->view = NULL;
}
示例#13
0
static void
canvas_widget_to_world (EelCanvas *canvas,
			double widget_x, double widget_y,
			double *world_x, double *world_y)
{
	eel_canvas_window_to_world (canvas,
				    widget_x + gtk_adjustment_get_value (gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (canvas))),
				    widget_y + gtk_adjustment_get_value (gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (canvas))),
				    world_x, world_y);
}
示例#14
0
文件: gtktexthandle.c 项目: GYGit/gtk
static void
_gtk_text_handle_set_scrollable (GtkTextHandle *handle,
                                 GtkScrollable *scrollable)
{
  GtkTextHandlePrivate *priv;

  priv = handle->priv;

  if (priv->parent_scrollable)
    {
      if (priv->vadj)
        {
          g_signal_handlers_disconnect_by_data (priv->vadj, handle);
          g_object_unref (priv->vadj);
          priv->vadj = NULL;
        }

      if (priv->hadj)
        {
          g_signal_handlers_disconnect_by_data (priv->hadj, handle);
          g_object_unref (priv->hadj);
          priv->hadj = NULL;
        }
 
      g_object_remove_weak_pointer (G_OBJECT (priv->parent_scrollable), (gpointer *) &priv->parent_scrollable);
    }

  priv->parent_scrollable = scrollable;

  if (scrollable)
    {
      g_object_add_weak_pointer (G_OBJECT (priv->parent_scrollable), (gpointer *) &priv->parent_scrollable);

      priv->vadj = gtk_scrollable_get_vadjustment (scrollable);
      priv->hadj = gtk_scrollable_get_hadjustment (scrollable);

      if (priv->vadj)
        {
          g_object_ref (priv->vadj);
          g_signal_connect (priv->vadj, "changed",
                            G_CALLBACK (adjustment_changed_cb), handle);
          g_signal_connect (priv->vadj, "value-changed",
                            G_CALLBACK (adjustment_changed_cb), handle);
        }

      if (priv->hadj)
        {
          g_object_ref (priv->hadj);
          g_signal_connect (priv->hadj, "changed",
                            G_CALLBACK (adjustment_changed_cb), handle);
          g_signal_connect (priv->hadj, "value-changed",
                            G_CALLBACK (adjustment_changed_cb), handle);
        }
    }
}
示例#15
0
Terminal::Terminal() {
    dock_hint = GdkRectangle{0, 0, 0, 0};
    vte = vte_terminal_new();
    char *argv[] = { vte_get_user_shell(), NULL };
    vte_terminal_spawn_sync(VTE_TERMINAL(vte), VTE_PTY_DEFAULT, NULL, argv, NULL,
                            (GSpawnFlags)0, NULL,
                            NULL, &child_pid, NULL, NULL);
    set_orientation(Gtk::ORIENTATION_VERTICAL);
    scrollbox.set_orientation(Gtk::ORIENTATION_HORIZONTAL);
    scrollbar.set_orientation(Gtk::ORIENTATION_VERTICAL);

    eventbox.add(label);
    eventbox.signal_button_press_event().connect(mem_fun(this, &Terminal::header_button_press));

    VteRegex *regex = vte_regex_new_for_match("(https?://|www\\.)[^\\s]*", -1, PCRE2_MULTILINE, NULL);
    vte_terminal_match_add_regex(VTE_TERMINAL(vte), regex, 0);
    vte_terminal_set_scrollback_lines(VTE_TERMINAL(vte), 10000);
    g_signal_connect(vte, "bell", G_CALLBACK(Terminal::vte_beep), this);
    g_signal_connect(vte, "child-exited", G_CALLBACK(Terminal::vte_child_exited), this);
    g_signal_connect(vte, "button-press-event", G_CALLBACK(Terminal::vte_click), this);
    g_signal_connect(vte, "focus-in-event", G_CALLBACK(Terminal::vte_got_focus), this);
    g_signal_connect(vte, "focus-out-event", G_CALLBACK(Terminal::vte_lost_focus), this);
    g_signal_connect(vte, "selection-changed", G_CALLBACK(Terminal::vte_selection_changed), this);
    g_signal_connect(vte, "window-title-changed", G_CALLBACK(Terminal::vte_title_changed), this);

    searchbar.add(searchentry);
    searchbar.connect_entry(searchentry);
    searchentry.signal_focus_out_event().connect(mem_fun(this, &Terminal::searchentry_lost_focus));
    searchentry.signal_key_release_event().connect(mem_fun(this, &Terminal::searchentry_keypress));

    pack_start(eventbox, false, false, 0);
    pack_start(scrollbox, true, true, 0);
    pack_start(searchbar, false, false, 0);
    gtk_box_pack_start(GTK_BOX(scrollbox.gobj()), vte, true, true, 0);
    scrollbox.pack_start(scrollbar, false, false, 0);
    gtk_range_set_adjustment(GTK_RANGE(scrollbar.gobj()), gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(vte)));
    show_all_children();

    find_label.terminal = this;
    find_label.set_alignment(0.0, 0.5);
    find_window->list_box.prepend(find_label);

    std::vector<Gtk::TargetEntry> listTargets;
    listTargets.push_back(Gtk::TargetEntry("SvanTerminal", Gtk::TARGET_SAME_APP, 0));

    eventbox.drag_source_set(listTargets);

    drag_dest_set(listTargets);
    eventbox.signal_drag_begin().connect(sigc::mem_fun(this, &Terminal::on_my_drag_begin));
    eventbox.signal_drag_failed().connect(sigc::mem_fun(this, &Terminal::on_my_drag_failed));
    eventbox.signal_drag_end().connect(sigc::mem_fun(this, &Terminal::on_my_drag_end));
    signal_drag_motion().connect(sigc::mem_fun(this, &Terminal::on_my_drag_motion));
    signal_drag_drop().connect(sigc::mem_fun(this, &Terminal::on_my_drag_drop));
    signal_drag_leave().connect(sigc::mem_fun(this, &Terminal::on_my_drag_leave));
}
示例#16
0
文件: reflect.c 项目: GNOME/vte
static GtkAdjustment *
terminal_adjustment(GtkWidget *terminal)
{
#ifdef USE_TEXT_VIEW
	return terminal_adjustment_text_view(terminal);
#endif
#ifdef USE_VTE
	return gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(terminal));
#endif
	g_assert_not_reached();
}
示例#17
0
static gboolean
begin_scroll2 (gpointer data)
{
    GtkAdjustment *adj = gtk_scrollable_get_vadjustment (data);

    gb_object_animate(adj, GB_ANIMATION_EASE_IN_OUT_QUAD, 3000,
                      "value", 0.0,
                      NULL);

    return G_SOURCE_REMOVE;
}
示例#18
0
static gboolean
begin_scroll (gpointer data)
{
    GtkAdjustment *adj = gtk_scrollable_get_vadjustment (data);
    gdouble value = gtk_adjustment_get_upper (adj);

    gb_object_animate(adj, GB_ANIMATION_EASE_IN_OUT_QUAD, 5000,
                      "value", value / 2.0,
                      NULL);

    return G_SOURCE_REMOVE;
}
示例#19
0
static void
update_child_vadjustment (GtkSourceMap *map)
{
	GtkSourceMapPrivate *priv;
	GtkAdjustment *vadj;
	GtkAdjustment *child_vadj;
	gdouble value;
	gdouble upper;
	gdouble page_size;
	gdouble child_upper;
	gdouble child_page_size;
	gdouble new_value = 0.0;

	priv = gtk_source_map_get_instance_private (map);

	vadj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (priv->view));
	g_object_get (vadj,
	              "upper", &upper,
	              "value", &value,
	              "page-size", &page_size,
	              NULL);

	child_vadj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (priv->child_view));
	g_object_get (child_vadj,
	              "upper", &child_upper,
	              "page-size", &child_page_size,
	              NULL);

	/*
	 * FIXME:
         * Technically we should take into account lower here, but in practice
	 *       it is always 0.0.
	 */
	if (child_page_size < child_upper)
	{
		new_value = (value / (upper - page_size)) * (child_upper - child_page_size);
	}

	gtk_adjustment_set_value (child_vadj, new_value);
}
示例#20
0
static void
gb_terminal_view_connect_terminal (GbTerminalView *self,
                                   VteTerminal    *terminal)
{
  GtkAdjustment *vadj;
  GQuark quark;
  guint signal_id;

  vadj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (terminal));

  if (terminal == self->terminal_top)
    gtk_range_set_adjustment (GTK_RANGE (self->top_scrollbar), vadj);
  else
    gtk_range_set_adjustment (GTK_RANGE (self->bottom_scrollbar), vadj);

  g_signal_connect_object (terminal,
                           "size-allocate",
                           G_CALLBACK (size_allocate_cb),
                           self,
                           0);

  g_signal_connect_object (terminal,
                           "child-exited",
                           G_CALLBACK (child_exited_cb),
                           self,
                           0);

  g_signal_connect_object (terminal,
                           "focus-in-event",
                           G_CALLBACK (focus_in_event_cb),
                           self,
                           0);

  g_signal_connect_object (terminal,
                           "window-title-changed",
                           G_CALLBACK (window_title_changed_cb),
                           self,
                           0);

  if (g_signal_parse_name ("notification-received",
                           VTE_TYPE_TERMINAL,
                           &signal_id,
                           &quark,
                           FALSE))
    {
      g_signal_connect_object (terminal,
                               "notification-received",
                               G_CALLBACK (notification_received_cb),
                               self,
                               0);
    }
}
示例#21
0
static void
test_position (GtkTreeView *tree_view,
	       GtkTreePath *path,
	       gboolean     use_align,
	       gdouble      row_align)
{
	gint pos;
	gchar *path_str;
	GdkRectangle rect;
	GtkTreeModel *model;
	gint row_start;

	/* Get the location of the path we scrolled to */
	gtk_tree_view_get_background_area (GTK_TREE_VIEW (tree_view),
					   path, NULL, &rect);

	row_start = get_row_start_for_index (GTK_TREE_VIEW (tree_view),
					     gtk_tree_path_get_indices (path)[0]);

	/* Ugh */
	pos = get_pos_from_path (GTK_TREE_VIEW (tree_view),
				 path, rect.height,
			         gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (tree_view)));

	/* This is only tested for during test_single() */
	model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view));
	if (gtk_tree_model_iter_n_children (model, NULL) == 1) {
                GtkAllocation allocation;
		GtkTreePath *tmppath;

		/* Test nothing is dangling at the bottom; read
		 * description for test_single() for more information.
		 */

		/* FIXME: hardcoded width */
                gtk_widget_get_allocation (GTK_WIDGET (tree_view), &allocation);
		if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (tree_view), 0, allocation.height - 30, &tmppath, NULL, NULL, NULL)) {
			g_assert_not_reached ();
			gtk_tree_path_free (tmppath);
		}
	}

	path_str = gtk_tree_path_to_string (path);
	if (use_align) {
		assert_position_with_align (tree_view, pos, rect.y,
                                            row_start, rect.height, row_align);
	} else {
		assert_position_without_align (tree_view, row_start, rect.height);
	}

	g_free (path_str);
}
示例#22
0
static void
assert_position_without_align (GtkTreeView *tree_view,
                               gdouble      row_start,
                               gdouble      row_height)
{
  GtkAdjustment *vadjustment = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (tree_view));

  /* Without align the tree view does as less work as possible,
   * so basically we only have to check whether the row
   * is visible on the screen.
   */
  g_assert (gtk_adjustment_get_value (vadjustment) <= row_start);
  g_assert (gtk_adjustment_get_value (vadjustment) + gtk_adjustment_get_page_size (vadjustment) >= row_start + row_height);
}
示例#23
0
static void
scroll_new_row_tree (ScrollFixture *fixture,
		     gconstpointer  test_data)
{
	GtkTreeModel *model;
	GtkAdjustment *vadjustment;
	int i;

	/* The goal of this test is to append new rows at the end of a tree
	 * store and immediately scroll to them.  If there is a parent
	 * node with a couple of childs in the "area above" to explore,
	 * this used to lead to unexpected results due to a bug.
	 *
	 * This issue has been reported by Miroslav Rajcic on
	 * gtk-app-devel-list:
	 * http://mail.gnome.org/archives/gtk-app-devel-list/2008-December/msg00068.html
	 */

	gtk_widget_show_all (fixture->window);

	gtk_tree_view_expand_all (GTK_TREE_VIEW (fixture->tree_view));

	while (gtk_events_pending ())
		gtk_main_iteration ();

	model = gtk_tree_view_get_model (GTK_TREE_VIEW (fixture->tree_view));
	vadjustment = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (fixture->tree_view));

	for (i = 0; i < 5; i++) {
		GtkTreeIter scroll_iter;
		GtkTreePath *scroll_path;

		gtk_tree_store_append (GTK_TREE_STORE (model), &scroll_iter,
				       NULL);
		gtk_tree_store_set (GTK_TREE_STORE (model), &scroll_iter,
				    0, "New node", -1);

		scroll_path = gtk_tree_model_get_path (model, &scroll_iter);
		gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (fixture->tree_view),
					      scroll_path, NULL, FALSE, 0.0, 0.0);
		gtk_tree_path_free (scroll_path);

		while (gtk_events_pending ())
			gtk_main_iteration ();

		/* Test position, the scroll bar must be at the end */
		g_assert (gtk_adjustment_get_value (vadjustment) == gtk_adjustment_get_upper (vadjustment) - gtk_adjustment_get_page_size (vadjustment));
	}
}
示例#24
0
void
app_resizer_set_vadjustment_value (GtkWidget * widget, gdouble value)
{
	GtkAdjustment *adjust;

	adjust = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (widget));

	gdouble upper = gtk_adjustment_get_upper (adjust);
	gdouble page_size = gtk_adjustment_get_page_size (adjust);
	if (value > upper - page_size)
	{
		value = upper - page_size;
	}
	gtk_adjustment_set_value (adjust, value);
}
示例#25
0
文件: hotssh-tab.c 项目: GNOME/hotssh
static void
hotssh_tab_init (HotSshTab *self)
{
  HotSshTabPrivate *priv = hotssh_tab_get_instance_private (self);

  priv->settings = g_settings_new ("org.gnome.hotssh");

  gtk_widget_init_template (GTK_WIDGET (self));

  gtk_notebook_set_show_tabs ((GtkNotebook*)self, FALSE);

  g_signal_connect (priv->create_and_connect_button, "clicked", G_CALLBACK (on_create_and_connect), self);
  g_signal_connect (priv->add_new_connection_button, "clicked", G_CALLBACK (on_add_new_connection), self);
  g_signal_connect (priv->connect_cancel_button, "clicked", G_CALLBACK (on_connect_cancel), self);
  g_signal_connect (priv->error_disconnect, "clicked", G_CALLBACK (on_connect_cancel), self);
  g_signal_connect (priv->auth_cancel_button, "clicked", G_CALLBACK (on_connect_cancel), self);
  g_signal_connect (priv->approve_hostkey_button, "clicked", G_CALLBACK (on_approve_hostkey_clicked), self);
  g_signal_connect (priv->disapprove_hostkey_button, "clicked", G_CALLBACK (on_connect_cancel), self);
  g_signal_connect_swapped (priv->password_entry, "activate", G_CALLBACK (submit_password), self);
  g_signal_connect_swapped (priv->password_submit, "clicked", G_CALLBACK (submit_password), self);
  g_signal_connect (priv->connections_treeview, "row-activated", G_CALLBACK (on_connection_row_activated), self);

  priv->password_interaction = hotssh_password_interaction_new ((GtkEntry*)priv->password_entry);
  
  priv->terminal = vte_terminal_new ();
  g_signal_connect (priv->terminal, "realize", G_CALLBACK (on_vte_realize), self);
  vte_terminal_set_audible_bell ((VteTerminal*)priv->terminal, FALSE);  /* Audible bell is a terrible idea */
  g_signal_connect ((GObject*)priv->terminal, "size-allocate", G_CALLBACK (on_terminal_size_allocate), self);
  g_signal_connect ((GObject*)priv->terminal, "commit", G_CALLBACK (on_terminal_commit), self);
  gtk_box_pack_start ((GtkBox*)priv->terminal_box, priv->terminal, TRUE, TRUE, 0);
  gtk_range_set_adjustment ((GtkRange*)priv->terminal_vscrollbar,
                            gtk_scrollable_get_vadjustment ((GtkScrollable*)priv->terminal));
  gtk_widget_show_all (priv->terminal_box);

  g_queue_init (&priv->write_queue);

  {
    gs_unref_object HotSshHostDB *hostdb = hotssh_hostdb_get_instance ();
    gs_unref_object GtkTreeModel *hostdb_model = hotssh_hostdb_get_model (hostdb);
    priv->host_completion = gtk_entry_completion_new ();
    gtk_entry_completion_set_match_func (priv->host_completion, host_entry_match, self, NULL);
    gtk_entry_completion_set_model (priv->host_completion, hostdb_model);
    gtk_entry_completion_set_text_column (priv->host_completion, 0);
    gtk_entry_completion_set_inline_completion (priv->host_completion, TRUE);
    gtk_entry_set_completion ((GtkEntry*)priv->host_entry, priv->host_completion);
  }
}
static void
ide_source_view_movements_scroll_by_lines (Movement *mv,
                                           gint      lines)
{
  GtkTextView *text_view = (GtkTextView *)mv->self;
  GtkAdjustment *vadj;
  GtkTextBuffer *buffer;
  GtkTextIter begin;
  GtkTextIter end;
  GdkRectangle rect;
  gdouble amount;
  gdouble value;
  gdouble upper;

  if (lines == 0)
    return;

  vadj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (mv->self));
  buffer = gtk_text_view_get_buffer (text_view);

  gtk_text_buffer_get_bounds (buffer, &begin, &end);

  if (lines > 0)
    {
      if (gtk_text_iter_get_line (&end) == gtk_text_iter_get_line (&mv->insert))
        return;
    }
  else if (lines < 0)
    {
      if (gtk_text_iter_get_line (&begin) == gtk_text_iter_get_line (&mv->insert))
        return;
    }
  else
    g_assert_not_reached ();

  gtk_text_view_get_iter_location (text_view, &mv->insert, &rect);

  amount = lines * rect.height;

  value = gtk_adjustment_get_value (vadj);
  upper = gtk_adjustment_get_upper (vadj);
  gtk_adjustment_set_value (vadj, CLAMP (value + amount, 0, upper));

  mv->ignore_scroll_to_insert = TRUE;
  ide_source_view_place_cursor_onscreen (mv->self);
}
示例#27
0
static gboolean
chat_text_view_is_scrolled_down (EmpathyChatTextView *view)
{
	GtkAdjustment *vadj;
	gdouble value;
	gdouble upper;
	gdouble page_size;

	vadj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (view));
	value = gtk_adjustment_get_value (vadj);
	upper = gtk_adjustment_get_upper (vadj);
	page_size = gtk_adjustment_get_page_size (vadj);

	if (value < upper - page_size) {
		return FALSE;
	}

	return TRUE;
}
示例#28
0
static void
chat_text_view_size_allocate (GtkWidget     *widget,
			      GtkAllocation *alloc)
{
	gboolean down;

	down = chat_text_view_is_scrolled_down (EMPATHY_CHAT_TEXT_VIEW (widget));

	GTK_WIDGET_CLASS (empathy_chat_text_view_parent_class)->size_allocate (widget, alloc);

	if (down) {
		GtkAdjustment *adj;

		adj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (widget));
		gtk_adjustment_set_value (adj,
					  gtk_adjustment_get_upper (adj) -
					  gtk_adjustment_get_page_size (adj));
	}
}
示例#29
0
/* Test for GNOME bugzilla bug 359231; tests "recovery when removing a bunch of
 * rows at the bottom.
 */
static void
test_bug316689 (ScrollFixture *fixture,
		gconstpointer  test_data)
{
	GtkTreeIter iter;
	GtkTreePath *path;
	GtkAdjustment *vadjustment;
	GtkTreeModel *model;

	/* The aim of this test is to scroll to the bottom of a TreeView,
	 * remove at least one page_size of items and check if TreeView
	 * correctly corrects the scroll bar (else they will look "broken").
	 *
	 * See #316689.
	 */

	g_test_bug ("316689");

	/* Scroll to some place close to the end */
	path = gtk_tree_path_new_from_indices (N_ROWS - 4, -1);
	scroll (fixture, path, FALSE, 0.0);
	gtk_tree_path_free (path);

	/* No need for a while events pending loop here, scroll() does this for us.
	 *
	 * We now remove a bunch of rows, wait for events to process and then
	 * check the adjustments to see if the TreeView gracefully recovered.
	 */
	model = gtk_tree_view_get_model (GTK_TREE_VIEW (fixture->tree_view));

	while (gtk_tree_model_iter_nth_child (model, &iter, NULL, N_ROWS - 15))
		gtk_list_store_remove (GTK_LIST_STORE (model), &iter);

	while (gtk_events_pending ())
		gtk_main_iteration ();

	vadjustment = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (fixture->tree_view));

	g_assert (gtk_adjustment_get_value (vadjustment) + gtk_adjustment_get_page_size (vadjustment) <= gtk_adjustment_get_upper (vadjustment));
	g_assert (gtk_adjustment_get_value (vadjustment) == gtk_adjustment_get_upper (vadjustment) - gtk_adjustment_get_page_size (vadjustment));
}
示例#30
0
void fl_refresh(gboolean keep_scroll_pos)
{
	const char *ent_wd_text;
	GtkAdjustment *adj;
	double saved_value;


	adj = gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(tv_files));
	saved_value = gtk_adjustment_get_value(adj);

	ent_wd_text = gtk_entry_get_text(ent_wd);
	if (strcmp(working_dir_utf8->str, ent_wd_text) != 0)
		fl_set_working_dir_utf8(ent_wd_text);
	else
		load_file_list();

	if (keep_scroll_pos) {
		if (saved_value <= gtk_adjustment_get_upper(adj))
			gtk_adjustment_set_value(adj, saved_value);
	}
}