Пример #1
0
void
ddisplay_update_scrollbars(DDisplay *ddisp)
{
  Rectangle *extents = &ddisp->diagram->data->extents;
  Rectangle *visible = &ddisp->visible;
  GtkAdjustment *hsbdata, *vsbdata;

  hsbdata = ddisp->hsbdata;
  /* Horizontal: */
  gtk_adjustment_set_lower (hsbdata, MIN(extents->left, visible->left));
  gtk_adjustment_set_upper (hsbdata, MAX(extents->right, visible->right));
  gtk_adjustment_set_page_size (hsbdata, visible->right - visible->left - 0.0001);
  /* remove some to fix strange behaviour in gtk_range_adjustment_changed */
  gtk_adjustment_set_page_increment (hsbdata, (visible->right - visible->left) / 2.0);
  gtk_adjustment_set_step_increment (hsbdata, (visible->right - visible->left) / 10.0);
  gtk_adjustment_set_value (hsbdata, visible->left);

  g_signal_emit_by_name (G_OBJECT (ddisp->hsbdata), "changed");

  /* Vertical: */
  vsbdata = ddisp->vsbdata;
  gtk_adjustment_set_lower (vsbdata, MIN(extents->top, visible->top));
  gtk_adjustment_set_upper (vsbdata, MAX(extents->bottom, visible->bottom));
  gtk_adjustment_set_page_size (vsbdata, visible->bottom - visible->top - 0.00001);
  /* remove some to fix strange behaviour in gtk_range_adjustment_changed */
  gtk_adjustment_set_page_increment (vsbdata, (visible->bottom - visible->top) / 2.0);
  gtk_adjustment_set_step_increment (vsbdata, (visible->bottom - visible->top) / 10.0);
  gtk_adjustment_set_value (vsbdata, visible->top);

  g_signal_emit_by_name (G_OBJECT (ddisp->vsbdata), "changed");
}
Пример #2
0
JNIEXPORT void JNICALL
Java_org_gnome_gtk_GtkAdjustment_gtk_1adjustment_1set_1page_1increment
(
    JNIEnv* env,
    jclass cls,
    jlong _self,
    jdouble _value
)
{
    GtkAdjustment* self;
    gdouble value;

    // convert parameter self
    self = (GtkAdjustment*) _self;

    // convert parameter value
    value = (gdouble) _value;

    // call function
    gtk_adjustment_set_page_increment(self, value);

    // cleanup parameter self

    // cleanup parameter value
}
Пример #3
0
void edosu_view_set_max_time(EdosuView *self, uint64_t max_time, double page_range)
{
    self->time_max = max_time;
    gtk_adjustment_set_upper(self->time_adjust, (gdouble) max_time);
    gtk_range_set_fill_level(self->time_range, (gdouble) max_time);
    gtk_adjustment_set_page_increment(self->time_adjust, page_range);
}
Пример #4
0
static void
dma_sparse_view_update_adjustement (DmaSparseView *view)
{
	PangoLayout *layout;
	GdkRectangle text_area;
	int height;

	gtk_text_view_get_visible_rect(GTK_TEXT_VIEW (view), &text_area);
	layout = gtk_widget_create_pango_layout (GTK_WIDGET(view), "0123456789ABCDEFGHIJKLMNOPQRSTUVWWYZ,");
	pango_layout_get_pixel_size(layout, NULL, &height);
	g_object_unref (G_OBJECT (layout));
	
	view->priv->line_by_page = text_area.height / height;
	view->priv->char_by_line = 8;	

	if (view->priv->vadjustment != NULL)
	{
		GtkAdjustment *vadj = view->priv->vadjustment;
		gdouble step_increment, page_size;

		step_increment = view->priv->char_by_line;
		page_size = (view->priv->line_by_page - 1) * step_increment;
		
		gtk_adjustment_set_step_increment (vadj, step_increment);
		gtk_adjustment_set_page_size (vadj, page_size);
		gtk_adjustment_set_page_increment (vadj, page_size * 0.9);
		gtk_adjustment_changed (vadj); 
	}
}
Пример #5
0
/* Auxiliary methods */
static gboolean
update_grid_scroll_position (GcalWeekView *self)
{
  g_autoptr(GDateTime) week_start = NULL;
  g_autoptr(GDateTime) week_end = NULL;
  g_autoptr(GDateTime) now = NULL;
  GtkAdjustment *vadjustment;
  gdouble minutes, real_value;
  gdouble max, page, page_increment, value;

  /* While the scrolled window is not mapped, we keep waiting */
  if (!gtk_widget_get_realized (self->scrolled_window) ||
      !gtk_widget_get_mapped (self->scrolled_window))
    {
      GCAL_RETURN (G_SOURCE_CONTINUE);
    }

  now = g_date_time_new_now_local ();
  week_start = get_start_of_week (self->date);
  week_end = get_end_of_week (self->date);

  /* Don't animate when not today */
  if (datetime_compare_date (now, week_start) < 0 || datetime_compare_date (now, week_end) >= 0)
    GCAL_GOTO (out);

  vadjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (self->scrolled_window));
  minutes = g_date_time_get_hour (now) * 60 + g_date_time_get_minute (now);
  page = gtk_adjustment_get_page_size (vadjustment);
  max = gtk_adjustment_get_upper (vadjustment);

  real_value = max / MINUTES_PER_DAY * minutes - (page / 2.0);
  page_increment = gtk_adjustment_get_page_increment (vadjustment);
  value = gtk_adjustment_get_value (vadjustment);

  gtk_adjustment_set_page_increment (vadjustment, real_value - value);

  g_signal_emit_by_name (self->scrolled_window,
                         "scroll-child",
                         GTK_SCROLL_PAGE_FORWARD,
                         FALSE);

  gtk_adjustment_set_page_increment (vadjustment, page_increment);

out:
  self->scroll_grid_timeout_id = 0;
  GCAL_RETURN (G_SOURCE_REMOVE);
}
Пример #6
0
/* Configure the page and step increment of the volume slider,
 * according to the current preferences.
 */
static void
configure_vol_increment(GtkAdjustment *vol_scale_adj)
{
	gdouble scroll_step;
	gdouble fine_scroll_step;

	scroll_step = prefs_get_double("ScrollStep", 5);
	fine_scroll_step =  prefs_get_double("FineScrollStep", 1);

	gtk_adjustment_set_page_increment(vol_scale_adj, scroll_step);
	gtk_adjustment_set_step_increment(vol_scale_adj, fine_scroll_step);
}
Пример #7
0
void
update_vscrollbar (DenemoProject * gui)
{
  if(Denemo.non_interactive)
    return;
  GtkAdjustment *adj = GTK_ADJUSTMENT (Denemo.vadjustment);
  gtk_adjustment_set_upper (adj, g_list_length (gui->movement->thescore) + 1.0);
  gtk_adjustment_set_page_size (adj, gui->movement->bottom_staff - gui->movement->top_staff + 1.0);
  gtk_adjustment_set_page_increment (adj, gui->movement->bottom_staff - gui->movement->top_staff + 1.0);
  gtk_adjustment_set_value (adj, gui->movement->top_staff);

  gtk_adjustment_changed (adj);
  //gtk_range_slider_update (GTK_RANGE (Denemo.vscrollbar));
}
Пример #8
0
/**
 * update_hscrollbar should be called as a cleanup whenever
 * si->leftmeasurenum or si->rightmeasurenum may have been altered,
 *  e.g., by preceding calls to set_rightmeasurenum; or when the
 *  number of measures may have changed.
 */
void
update_hscrollbar (DenemoProject * gui)
{
  if(Denemo.non_interactive)
    return;
  GtkAdjustment *adj = GTK_ADJUSTMENT (Denemo.hadjustment);
  gdouble upper = g_list_length (gui->movement->measurewidths) + 1.0, page_size = gui->movement->rightmeasurenum - gui->movement->leftmeasurenum + 1.0;
  gdouble left = gtk_adjustment_get_value (adj);
  gtk_adjustment_set_upper (adj, upper);
  gtk_adjustment_set_page_size (adj, page_size);
  gtk_adjustment_set_page_increment (adj, page_size);
  gtk_adjustment_set_value (adj, gui->movement->leftmeasurenum);
  gtk_adjustment_changed (adj);
  //g_debug("steps %d Difference %d\n",transition_steps, (gint)(left-gui->movement->leftmeasurenum));
  set_viewport_transition ((gint) (gui->movement->leftmeasurenum) - left);
}
Пример #9
0
/**
 * @param ddisp The diagram display object that a window is created for
 * @param width Diagram widgth
 * @param height Diagram Height
 * @param title Window title
 * @param use_mbar Flag to indicate whether to add a menubar to the window
 */
void
create_display_shell(DDisplay *ddisp,
		     int width, int height,
		     char *title, int use_mbar)
{
  GtkWidget *table, *widget;
  GtkWidget *status_hbox;
  GtkWidget *root_vbox = NULL;
  GtkWidget *zoom_hbox, *zoom_label;
  int s_width, s_height;

  if (app_is_interactive() && is_integrated_ui())
  {
    use_integrated_ui_for_display_shell(ddisp, title);
    return;
  }
 
  ddisp->is_standalone_window = TRUE;
  ddisp->container            = NULL;

  s_width = gdk_screen_width ();
  s_height = gdk_screen_height ();
  if (width > s_width)
    width = s_width;
  if (height > s_height)
    height = s_height;

  /*  The toplevel shell */
  ddisp->shell = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (ddisp->shell), title);
  gtk_window_set_role (GTK_WINDOW (ddisp->shell), "diagram_window");
  gtk_window_set_icon_name (GTK_WINDOW (ddisp->shell), "dia");
  gtk_window_set_default_size(GTK_WINDOW (ddisp->shell), width, height);
  /* set_icon_name needs registered theme icons, not always available: provide fallback */
  if (!gtk_window_get_icon (GTK_WINDOW (ddisp->shell))) {
    static GdkPixbuf *pixbuf = NULL;

    if (!pixbuf)
      pixbuf = gdk_pixbuf_new_from_inline(-1, dia_diagram_icon, FALSE, NULL);
    if (pixbuf)
      gtk_window_set_icon (GTK_WINDOW (ddisp->shell), pixbuf);
  }

  g_object_set_data (G_OBJECT (ddisp->shell), "user_data", (gpointer) ddisp);

  _ddisplay_setup_events (ddisp, ddisp->shell);
  /* following two not shared with integrated UI */
  g_signal_connect (G_OBJECT (ddisp->shell), "delete_event",
		    G_CALLBACK (ddisplay_delete), ddisp);
  g_signal_connect (G_OBJECT (ddisp->shell), "destroy",
		    G_CALLBACK (ddisplay_destroy), ddisp);

  /*  the table containing all widgets  */
  table = gtk_table_new (4, 3, FALSE);
  gtk_table_set_col_spacing (GTK_TABLE (table), 0, 1);
  gtk_table_set_col_spacing (GTK_TABLE (table), 1, 2);
  gtk_table_set_row_spacing (GTK_TABLE (table), 0, 1);
  gtk_table_set_row_spacing (GTK_TABLE (table), 1, 2);
  gtk_container_set_border_width (GTK_CONTAINER (table), 2);
  if (use_mbar) 
  {
      root_vbox = gtk_vbox_new (FALSE, 1);
      gtk_container_add (GTK_CONTAINER (ddisp->shell), root_vbox);
      gtk_box_pack_end (GTK_BOX (root_vbox), table, TRUE, TRUE, 0);
  }
  else
  {
      gtk_container_add (GTK_CONTAINER (ddisp->shell), table);
  }
  

  /*  scrollbars, rulers, canvas, menu popup button  */
  if (!use_mbar) {
      ddisp->origin = gtk_button_new();
#if GTK_CHECK_VERSION(2,18,0)
      gtk_widget_set_can_focus (ddisp->origin, FALSE);
#else
      GTK_WIDGET_UNSET_FLAGS(ddisp->origin, GTK_CAN_FOCUS);
#endif
      widget = gtk_arrow_new(GTK_ARROW_RIGHT, GTK_SHADOW_OUT);
      gtk_container_add(GTK_CONTAINER(ddisp->origin), widget);
      gtk_widget_set_tooltip_text(widget, _("Diagram menu."));
      gtk_widget_show(widget);
      g_signal_connect(G_OBJECT(ddisp->origin), "button_press_event",
		     G_CALLBACK(origin_button_press), ddisp);
  }
  else {
      ddisp->origin = gtk_frame_new (NULL);
      gtk_frame_set_shadow_type (GTK_FRAME (ddisp->origin), GTK_SHADOW_OUT);
  }
  
  _ddisplay_setup_rulers (ddisp, ddisp->shell, table);
  _ddisplay_setup_scrollbars (ddisp, table, width, height);
  _ddisplay_setup_navigation (ddisp, table);

  ddisp->canvas = create_canvas (ddisp);

  /*  pack all remaining widgets  */
  gtk_table_attach (GTK_TABLE (table), ddisp->origin, 0, 1, 0, 1,
                    GTK_FILL, GTK_FILL, 0, 0);
  gtk_table_attach (GTK_TABLE (table), ddisp->canvas, 1, 2, 1, 2,
                    GTK_EXPAND | GTK_SHRINK | GTK_FILL,
                    GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);

  /* TODO rob use per window accel */
  ddisp->accel_group = menus_get_display_accels ();
  gtk_window_add_accel_group(GTK_WINDOW(ddisp->shell), ddisp->accel_group);

  if (use_mbar) 
  {
    ddisp->menu_bar = menus_create_display_menubar (&ddisp->ui_manager, &ddisp->actions);
    g_assert (ddisp->menu_bar);
    gtk_box_pack_start (GTK_BOX (root_vbox), ddisp->menu_bar, FALSE, TRUE, 0);
  }

  /* the statusbars */
  status_hbox = gtk_hbox_new (FALSE, 2);

  /* Zoom status pseudo-optionmenu */
  ddisp->zoom_status = create_zoom_widget(ddisp);
  zoom_hbox = gtk_hbox_new(FALSE, 0);
  zoom_label = gtk_label_new(_("Zoom"));
  gtk_box_pack_start (GTK_BOX(zoom_hbox), zoom_label,
		      FALSE, FALSE, 0);
  gtk_box_pack_start (GTK_BOX(zoom_hbox), ddisp->zoom_status,
		      FALSE, FALSE, 0);

  gtk_box_pack_start (GTK_BOX (status_hbox), zoom_hbox, FALSE, FALSE, 0);

  /* Grid on/off button */
  ddisp->grid_status = dia_toggle_button_new_with_icons(dia_on_grid_icon,
							dia_off_grid_icon);
  
  g_signal_connect(G_OBJECT(ddisp->grid_status), "toggled",
		   G_CALLBACK (grid_toggle_snap), ddisp);
  gtk_widget_set_tooltip_text(ddisp->grid_status,
		       _("Toggles snap-to-grid for this window."));
  gtk_box_pack_start (GTK_BOX (status_hbox), ddisp->grid_status,
		      FALSE, FALSE, 0);


  ddisp->mainpoint_status = dia_toggle_button_new_with_icons(dia_mainpoints_on_icon,
							dia_mainpoints_off_icon);
  
  g_signal_connect(G_OBJECT(ddisp->mainpoint_status), "toggled",
		   G_CALLBACK (interface_toggle_mainpoint_magnetism), ddisp);
  gtk_widget_set_tooltip_text(ddisp->mainpoint_status,
		       _("Toggles object snapping for this window."));
  gtk_box_pack_start (GTK_BOX (status_hbox), ddisp->mainpoint_status,
		      FALSE, FALSE, 0);


  /* Statusbar */
  ddisp->modified_status = gtk_statusbar_new ();

  gtk_box_pack_start (GTK_BOX (status_hbox), ddisp->modified_status,
		      TRUE, TRUE, 0);

  gtk_table_attach (GTK_TABLE (table), status_hbox, 0, 3, 3, 4,
                    GTK_FILL, GTK_FILL, 0, 0);

  display_rulers_show (ddisp);
  gtk_widget_show (ddisp->zoom_status);
  gtk_widget_show (zoom_hbox);
  gtk_widget_show (zoom_label);
  gtk_widget_show (ddisp->grid_status);
  gtk_widget_show (ddisp->mainpoint_status);
  gtk_widget_show (ddisp->modified_status);
  gtk_widget_show (status_hbox);
  gtk_widget_show (table);
  if (use_mbar) 
  {
      gtk_widget_show (ddisp->menu_bar);
      gtk_widget_show (root_vbox);
  }
  gtk_widget_show (ddisp->shell);

  /* before showing up, checking canvas's REAL size */
  if (use_mbar && ddisp->hrule->allocation.width > width) 
  {
    /* The menubar is not shrinkable, so the shell will have at least
     * the menubar's width. If the diagram's requested width is smaller,
     * the canvas will be enlarged to fit the place. In this case, we
     * need to adjust the horizontal scrollbar according to the size
     * that will be allocated, which the same as the hrule got.
     */

    width = ddisp->hrule->allocation.width;

    gtk_adjustment_set_upper (ddisp->hsbdata, width);
    gtk_adjustment_set_page_increment (ddisp->hsbdata, (width - 1) / 4);
    gtk_adjustment_set_page_size (ddisp->hsbdata, width - 1);

    gtk_adjustment_changed (GTK_ADJUSTMENT(ddisp->hsbdata));
  }
  gtk_widget_show (ddisp->canvas);

  /*  set the focus to the canvas area  */
  gtk_widget_grab_focus (ddisp->canvas);
}
Пример #10
0
static void
dma_data_view_size_allocate (GtkWidget *widget,
                             GtkAllocation *allocation)
{
	DmaDataView *view = DMA_DATA_VIEW (widget);
	GtkStyle *style;
	GtkAllocation child_allocation;
	GtkRequisition range_requisition;
	GtkRequisition address_requisition;
	GtkRequisition data_requisition;
	GtkRequisition ascii_requisition;
	gint width;
	gint height;
	gint bytes_by_line;
	gint step;
	guint border_width;
	gboolean need_fill = FALSE;
	
	gtk_widget_set_allocation (widget, allocation);
	
 	gtk_widget_get_child_requisition (view->range, &range_requisition);
	border_width = gtk_container_get_border_width (GTK_CONTAINER (view));
	style = gtk_widget_get_style (widget);
	dma_data_view_address_size_request (view, &address_requisition);
	dma_data_view_data_size_request (view, &data_requisition);
	dma_data_view_ascii_size_request (view, &ascii_requisition);
	
	/* Compute number of byte per line */
	width = allocation->width
	        - 2 * border_width
	        - (view->shadow_type == GTK_SHADOW_NONE ? 0 : 2 * style->xthickness)
	        - ADDRESS_BORDER
	        - ASCII_BORDER
	        - SCROLLBAR_SPACING
	        - range_requisition.width
	        - address_requisition.width
	        - data_requisition.width * view->char_by_byte
	        - ascii_requisition.width;

	step = (ascii_requisition.width + data_requisition.width * (view->char_by_byte + 1));
	for (bytes_by_line = 1; width >= step * bytes_by_line; bytes_by_line *= 2)
	{
		width -=  step * bytes_by_line;
	}
	
	if (bytes_by_line != view->bytes_by_line)
	{
		need_fill = TRUE;
		view->bytes_by_line = bytes_by_line;
	}

	/* Compute number of line by page */
	height = allocation->height
	        - 2 * border_width
	        - (view->shadow_type == GTK_SHADOW_NONE ? 0 : 2 * style->ythickness);
	
	if (view->line_by_page != (height / address_requisition.height))
	{
		need_fill = TRUE;
		view->line_by_page = (height / address_requisition.height);
	}

	child_allocation.y = allocation->y + border_width;
	child_allocation.height = MAX (1, (gint) allocation->height - (gint) border_width * 2);

	/* Scroll bar */
	child_allocation.x = allocation->x + allocation->width - border_width - range_requisition.width;
	child_allocation.width = range_requisition.width;
	gtk_widget_size_allocate (view->range, &child_allocation);

	child_allocation.x = allocation->x + border_width;
	
	/* Frame */
	if (view->shadow_type != GTK_SHADOW_NONE)
	{
		GtkStyle *style = gtk_widget_get_style (widget);

		view->frame.x = allocation->x + border_width;
		view->frame.y = allocation->y + border_width;
		view->frame.width = allocation->width - range_requisition.width - SCROLLBAR_SPACING - 2 * border_width;
		view->frame.height = allocation->height - 2 * border_width;
		child_allocation.x += style->xthickness;
		child_allocation.y += style->ythickness;
		child_allocation.height -= 2 * style->ythickness;
	}
	
	/* Address */
	child_allocation.width = address_requisition.width;
	gtk_widget_size_allocate (view->address, &child_allocation);
	child_allocation.x += child_allocation.width;

	child_allocation.x += ADDRESS_BORDER;

	/* Data */

	child_allocation.width = (view->bytes_by_line * (view->char_by_byte + 1) - 1) * data_requisition.width;
	gtk_widget_size_allocate (view->data, &child_allocation);
	child_allocation.x += child_allocation.width;

	child_allocation.x += ASCII_BORDER;

	/* Ascii */
	child_allocation.width = view->bytes_by_line * ascii_requisition.width;
	gtk_widget_size_allocate (view->ascii, &child_allocation);
	child_allocation.x += child_allocation.width;

	if (need_fill)
	{
		gdouble page_increment, page_size, upper;

		page_increment = view->bytes_by_line * (view->line_by_page - 1);
		upper = gtk_adjustment_get_upper (view->buffer_range);
                page_size = (gulong) upper % view->bytes_by_line + page_increment;

		gtk_adjustment_set_step_increment (view->buffer_range, view->bytes_by_line);
		gtk_adjustment_set_page_increment (view->buffer_range, page_increment);
		gtk_adjustment_set_page_size (view->buffer_range, page_size);

		if (view->start + page_size > upper)
		{
			view->start = upper - page_size + view->bytes_by_line - 1;
			view->start -= view->start % view->bytes_by_line;
		}
		dma_data_view_refresh (view);
	}

}
Пример #11
0
void Scrollbar::setPageIncrement(int inc) {
	XOJ_CHECK_TYPE(Scrollbar);

	gtk_adjustment_set_page_increment(this->adj, inc);
}