static GtkWidget* CreateScrollbarWidget(WidgetNodeType aWidgetType, GtkOrientation aOrientation) { GtkWidget* widget = gtk_scrollbar_new(aOrientation, nullptr); AddToWindowContainer(widget); return widget; }
int main (int argc, char *argv[]) { GtkWidget *win, *box, *tv, *sw, *sb; GtkAdjustment *adj; gtk_init (NULL, NULL); win = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size (GTK_WINDOW (win), 640, 480); box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5); gtk_container_add (GTK_CONTAINER (win), box); sw = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_NEVER, GTK_POLICY_EXTERNAL); gtk_box_pack_start (GTK_BOX (box), sw, TRUE, TRUE, 0); tv = gtk_text_view_new (); fill_text_view (tv, "Left"); gtk_container_add (GTK_CONTAINER (sw), tv); adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (sw)); sw = gtk_scrolled_window_new (NULL, adj); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_NEVER, GTK_POLICY_EXTERNAL); gtk_box_pack_start (GTK_BOX (box), sw, TRUE, TRUE, 0); tv = gtk_text_view_new (); fill_text_view (tv, "Middle"); gtk_container_add (GTK_CONTAINER (sw), tv); sw = gtk_scrolled_window_new (NULL, adj); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_NEVER, GTK_POLICY_EXTERNAL); gtk_box_pack_start (GTK_BOX (box), sw, TRUE, TRUE, 0); tv = gtk_text_view_new (); fill_text_view (tv, "Right"); gtk_container_add (GTK_CONTAINER (sw), tv); sb = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, adj); gtk_container_add (GTK_CONTAINER (box), sb); gtk_widget_show_all (win); gtk_main (); return 0; }
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; }
static void create_disassembly( GtkBox *parent, gtkui_font font ) { size_t i; GtkWidget *scrollbar; static const gchar *const titles[] = { "Address", "Instruction" }; /* A box to hold the disassembly listing and the scrollbar */ disassembly_box = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 0 ); gtk_box_pack_start( parent, disassembly_box, TRUE, TRUE, 0 ); /* The disassembly itself */ disassembly_model = gtk_list_store_new( DISASSEMBLY_COLUMN_COUNT, G_TYPE_STRING, G_TYPE_STRING ); disassembly = gtk_tree_view_new_with_model( GTK_TREE_MODEL( disassembly_model ) ); for( i = 0; i < DISASSEMBLY_COLUMN_COUNT; i++ ) { GtkCellRenderer *renderer = gtk_cell_renderer_text_new(); GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes( titles[i], renderer, "text", i, NULL ); g_object_set( G_OBJECT( renderer ), "font-desc", font, "height", 18, NULL ); gtk_tree_view_append_column( GTK_TREE_VIEW( disassembly ), column ); } gtk_box_pack_start( GTK_BOX( disassembly_box ), disassembly, TRUE, TRUE, 0 ); /* The disassembly scrollbar */ disassembly_scrollbar_adjustment = GTK_ADJUSTMENT( gtk_adjustment_new( 0, 0x0000, 0x10000, 1, 20, 20 ) ); g_signal_connect( G_OBJECT( disassembly_scrollbar_adjustment ), "value-changed", G_CALLBACK( move_disassembly ), NULL ); scrollbar = gtk_scrollbar_new( GTK_ORIENTATION_VERTICAL, disassembly_scrollbar_adjustment ); gtk_box_pack_start( GTK_BOX( disassembly_box ), scrollbar, FALSE, FALSE, 0 ); /* Scrolling with keys */ g_signal_connect( GTK_TREE_VIEW( disassembly ), "key-press-event", G_CALLBACK( disassembly_key_press ), disassembly_scrollbar_adjustment ); /* Scrolling with mouse wheel */ g_signal_connect( GTK_TREE_VIEW( disassembly ), "scroll-event", G_CALLBACK( disassembly_wheel_scroll ), disassembly_scrollbar_adjustment ); }
static int gtkCanvasMapMethod(Ihandle* ih) { GtkWidget* sb_win; #if !GTK_CHECK_VERSION(3, 0, 0) void* visual; #endif if (!ih->parent) return IUP_ERROR; ih->data->sb = iupBaseGetScrollbar(ih); #if !GTK_CHECK_VERSION(3, 0, 0) visual = (void*)IupGetAttribute(ih, "VISUAL"); /* defined by the OpenGL Canvas in X11 or NULL */ if (visual) iupgtkPushVisualAndColormap(visual, (void*)iupAttribGet(ih, "COLORMAP")); #endif ih->handle = iupgtkNativeContainerNew(); /* canvas is also a container */ #if !GTK_CHECK_VERSION(3, 0, 0) if (visual) gtk_widget_pop_colormap(); #endif if (!ih->handle) return IUP_ERROR; /* CD will NOT work properly without this, must use always the CD-GDK driver */ iupgtkNativeContainerSetHasWindow(ih->handle, TRUE); sb_win = iupgtkNativeContainerNew(); if (!sb_win) return IUP_ERROR; iupgtkNativeContainerAdd(sb_win, ih->handle); gtk_widget_show(sb_win); iupAttribSetStr(ih, "_IUP_EXTRAPARENT", (char*)sb_win); /* add to the parent, all GTK controls must call this. */ iupgtkAddToParent(ih); g_signal_connect(G_OBJECT(ih->handle), "focus-in-event", G_CALLBACK(iupgtkFocusInOutEvent), ih); g_signal_connect(G_OBJECT(ih->handle), "focus-out-event", G_CALLBACK(iupgtkFocusInOutEvent), ih); g_signal_connect(G_OBJECT(ih->handle), "key-press-event", G_CALLBACK(iupgtkKeyPressEvent), ih); g_signal_connect(G_OBJECT(ih->handle), "key-release-event", G_CALLBACK(iupgtkKeyReleaseEvent), ih); g_signal_connect(G_OBJECT(ih->handle), "enter-notify-event", G_CALLBACK(iupgtkEnterLeaveEvent), ih); g_signal_connect(G_OBJECT(ih->handle), "leave-notify-event", G_CALLBACK(iupgtkEnterLeaveEvent), ih); g_signal_connect(G_OBJECT(ih->handle), "show-help", G_CALLBACK(iupgtkShowHelp), ih); #if GTK_CHECK_VERSION(3, 0, 0) g_signal_connect(G_OBJECT(ih->handle), "draw", G_CALLBACK(gtkCanvasDraw), ih); #else g_signal_connect(G_OBJECT(ih->handle), "expose-event", G_CALLBACK(gtkCanvasExposeEvent), ih); #endif g_signal_connect(G_OBJECT(ih->handle), "button-press-event", G_CALLBACK(gtkCanvasButtonEvent), ih); g_signal_connect(G_OBJECT(ih->handle), "button-release-event",G_CALLBACK(gtkCanvasButtonEvent), ih); g_signal_connect(G_OBJECT(ih->handle), "motion-notify-event",G_CALLBACK(iupgtkMotionNotifyEvent), ih); g_signal_connect(G_OBJECT(ih->handle), "scroll-event",G_CALLBACK(gtkCanvasScrollEvent), ih); g_signal_connect(G_OBJECT(ih->handle), "size-allocate", G_CALLBACK(gtkCanvasSizeAllocate), ih); /* To receive mouse events on a drawing area, you will need to enable them. */ gtk_widget_add_events(ih->handle, GDK_EXPOSURE_MASK| GDK_POINTER_MOTION_MASK|GDK_POINTER_MOTION_HINT_MASK| GDK_BUTTON_PRESS_MASK|GDK_BUTTON_RELEASE_MASK|GDK_BUTTON_MOTION_MASK| GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK| GDK_ENTER_NOTIFY_MASK|GDK_LEAVE_NOTIFY_MASK| GDK_FOCUS_CHANGE_MASK|GDK_STRUCTURE_MASK); /* To receive keyboard events, you will need to set the GTK_CAN_FOCUS flag on the drawing area. */ if (ih->iclass->is_interactive) { if (iupAttribGetBoolean(ih, "CANFOCUS")) iupgtkSetCanFocus(ih->handle, 1); } if (iupAttribGetBoolean(ih, "BORDER")) { iupAttribSetInt(ih, "BORDERWIDTH", 1); #if GTK_CHECK_VERSION(3, 0, 0) g_signal_connect(G_OBJECT(sb_win), "draw", G_CALLBACK(gtkCanvasBorderDraw), NULL); #else g_signal_connect(G_OBJECT(sb_win), "expose-event", G_CALLBACK(gtkCanvasBorderExposeEvent), NULL); #endif } gtk_widget_realize(sb_win); if (ih->data->sb & IUP_SB_HORIZ) { #if GTK_CHECK_VERSION(3, 0, 0) GtkWidget* sb_horiz = gtk_scrollbar_new(GTK_ORIENTATION_HORIZONTAL, NULL); #else GtkWidget* sb_horiz = gtk_hscrollbar_new(NULL); #endif iupgtkNativeContainerAdd(sb_win, sb_horiz); gtk_widget_show(sb_horiz); gtk_widget_realize(sb_horiz); g_signal_connect(G_OBJECT(sb_horiz), "change-value",G_CALLBACK(gtkCanvasScrollHorizChangeValue), ih); g_signal_connect(G_OBJECT(gtk_range_get_adjustment(GTK_RANGE(sb_horiz))), "value-changed",G_CALLBACK(gtkCanvasAdjustHorizValueChanged), ih); iupAttribSetStr(ih, "_IUPGTK_SBHORIZ", (char*)sb_horiz); } if (ih->data->sb & IUP_SB_VERT) { #if GTK_CHECK_VERSION(3, 0, 0) GtkWidget* sb_vert = gtk_scrollbar_new(GTK_ORIENTATION_VERTICAL, NULL); #else GtkWidget* sb_vert = gtk_vscrollbar_new(NULL); #endif iupgtkNativeContainerAdd(sb_win, sb_vert); gtk_widget_show(sb_vert); gtk_widget_realize(sb_vert); g_signal_connect(G_OBJECT(sb_vert), "change-value",G_CALLBACK(gtkCanvasScrollVertChangeValue), ih); g_signal_connect(G_OBJECT(gtk_range_get_adjustment(GTK_RANGE(sb_vert))), "value-changed",G_CALLBACK(gtkCanvasAdjustVertValueChanged), ih); iupAttribSetStr(ih, "_IUPGTK_SBVERT", (char*)sb_vert); } gtk_widget_realize(ih->handle); /* configure for DRAG&DROP */ if (IupGetCallback(ih, "DROPFILES_CB")) iupAttribSetStr(ih, "DROPFILESTARGET", "YES"); /* update a mnemonic in a label if necessary */ iupgtkUpdateMnemonic(ih); /* force the update of BGCOLOR here, to let derived classes ignore it if ACTION is defined */ gtkCanvasSetBgColorAttrib(ih, iupAttribGetStr(ih, "BGCOLOR")); return IUP_NOERROR; }
Preview_t * make_preview (GimpDrawable *drawable) { Preview_t *data = g_new(Preview_t, 1); GtkAdjustment *hadj; GtkAdjustment *vadj; GtkWidget *preview; GtkWidget *window; GtkWidget *button, *arrow; GtkWidget *ruler; GtkWidget *table; GtkWidget *scrollbar; gint width, height; data->drawable = drawable; data->preview = preview = gimp_preview_area_new (); g_object_set_data (G_OBJECT (preview), "preview", data); gtk_widget_set_events(GTK_WIDGET(preview), PREVIEW_MASK); g_signal_connect_after(preview, "expose-event", G_CALLBACK(preview_expose), data); g_signal_connect (preview, "size-allocate", G_CALLBACK (preview_size_allocate), (gpointer)data); /* Handle drop of links in preview widget */ gtk_drag_dest_set(preview, GTK_DEST_DEFAULT_ALL, target_table, 2, GDK_ACTION_COPY); g_signal_connect(preview, "drag-data-received", G_CALLBACK(handle_drop), NULL); data->widget_width = data->width = gimp_drawable_width(drawable->drawable_id); data->widget_height = data->height = gimp_drawable_height(drawable->drawable_id); gtk_widget_set_size_request (preview, data->widget_width, data->widget_height); /* The main table */ data->window = table = gtk_table_new(3, 3, FALSE); gtk_table_set_col_spacings (GTK_TABLE (table), 1); gtk_table_set_row_spacings (GTK_TABLE (table), 1); /* Create button with arrow */ button = gtk_button_new(); gtk_widget_set_can_focus (button, FALSE); gtk_table_attach(GTK_TABLE(table), button, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0); gtk_widget_set_events(button, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK); g_signal_connect(button, "button-press-event", G_CALLBACK(arrow_cb), NULL); gtk_widget_show(button); arrow = gtk_arrow_new(GTK_ARROW_RIGHT, GTK_SHADOW_OUT); gtk_container_add(GTK_CONTAINER(button), arrow); gtk_widget_show(arrow); /* Create horizontal ruler */ data->hruler = ruler = gimp_ruler_new (GTK_ORIENTATION_HORIZONTAL); g_signal_connect_swapped(preview, "motion-notify-event", G_CALLBACK(GTK_WIDGET_GET_CLASS(ruler)->motion_notify_event), ruler); gtk_table_attach(GTK_TABLE(table), ruler, 1, 2, 0, 1, GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_FILL, 0, 0); gtk_widget_show(ruler); /* Create vertical ruler */ data->vruler = ruler = gimp_ruler_new (GTK_ORIENTATION_VERTICAL); g_signal_connect_swapped(preview, "motion-notify-event", G_CALLBACK(GTK_WIDGET_GET_CLASS(ruler)->motion_notify_event), ruler); gtk_table_attach(GTK_TABLE(table), ruler, 0, 1, 1, 2, GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0); gtk_widget_show(ruler); window = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(window), GTK_POLICY_NEVER, GTK_POLICY_NEVER); width = (data->width > 600) ? 600 : data->width; height = (data->height > 400) ? 400 : data->height; gtk_widget_set_size_request(window, width, height); gtk_table_attach(GTK_TABLE(table), window, 1, 2, 1, 2, GTK_FILL, GTK_FILL, 0, 0); gtk_widget_show(window); hadj = gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (window)); g_signal_connect (hadj, "changed", G_CALLBACK (scroll_adj_changed), data->hruler); g_signal_connect (hadj, "value-changed", G_CALLBACK (scroll_adj_changed), data->hruler); vadj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (window)); g_signal_connect (vadj, "changed", G_CALLBACK (scroll_adj_changed), data->vruler); g_signal_connect (vadj, "value-changed", G_CALLBACK (scroll_adj_changed), data->vruler); gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW(window), preview); scrollbar = gtk_scrollbar_new (GTK_ORIENTATION_HORIZONTAL, hadj); gtk_table_attach(GTK_TABLE(table), scrollbar, 1, 2, 2, 3, GTK_FILL | GTK_SHRINK, GTK_FILL | GTK_SHRINK, 0, 0); gtk_widget_show (scrollbar); scrollbar = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, vadj); gtk_table_attach(GTK_TABLE(table), scrollbar, 2, 3, 1, 2, GTK_FILL | GTK_SHRINK, GTK_FILL | GTK_SHRINK, 0, 0); gtk_widget_show (scrollbar); gtk_widget_show (preview); gimp_pixel_rgn_init(&data->src_rgn, drawable, 0, 0, data->width, data->height, FALSE, FALSE); render_preview(data, &data->src_rgn); gtk_widget_show(table); return data; }
C4Window* C4Window::Init(WindowKind windowKind, C4AbstractApp * pApp, const char * Title, const C4Rect * size) { Active = true; #ifdef GDK_WINDOWING_X11 if(!FindFBConfig(Config.Graphics.MultiSampling, &Info)) { // Disable multisampling if we don't find a visual which // supports the currently configured setting. if(!FindFBConfig(0, &Info)) return NULL; Config.Graphics.MultiSampling = 0; } #endif assert(!window); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); if (windowKind == W_Viewport) { C4ViewportWindow * vw = static_cast<C4ViewportWindow *>(this); // Cannot just use ScrolledWindow because this would just move // the GdkWindow of the DrawingArea. GtkWidget* table = gtk_grid_new(); render_widget = gtk_drawing_area_new(); gtk_widget_set_hexpand(GTK_WIDGET(render_widget), true); gtk_widget_set_vexpand(GTK_WIDGET(render_widget), true); gtk_grid_attach(GTK_GRID(table), GTK_WIDGET(render_widget), 0, 0, 1, 1); vw->h_scrollbar = gtk_scrollbar_new(GTK_ORIENTATION_HORIZONTAL, NULL); gtk_grid_attach(GTK_GRID(table), vw->h_scrollbar, 0, 1, 1, 1); vw->v_scrollbar = gtk_scrollbar_new(GTK_ORIENTATION_VERTICAL, NULL); gtk_grid_attach(GTK_GRID(table), vw->v_scrollbar, 1, 0, 1, 1); GtkAdjustment* adjustment = gtk_range_get_adjustment(GTK_RANGE(vw->h_scrollbar)); g_signal_connect( G_OBJECT(adjustment), "value-changed", G_CALLBACK(OnHScrollStatic), this ); adjustment = gtk_range_get_adjustment(GTK_RANGE(vw->v_scrollbar)); g_signal_connect( G_OBJECT(adjustment), "value-changed", G_CALLBACK(OnVScrollStatic), this ); gtk_container_add(GTK_CONTAINER(window), table); gtk_widget_add_events(GTK_WIDGET(window), GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_STRUCTURE_MASK | GDK_POINTER_MOTION_MASK); gtk_drag_dest_set(GTK_WIDGET(render_widget), GTK_DEST_DEFAULT_ALL, drag_drop_entries, 1, GDK_ACTION_COPY); g_signal_connect(G_OBJECT(render_widget), "drag-data-received", G_CALLBACK(OnDragDataReceivedStatic), this); g_signal_connect(G_OBJECT(render_widget), "draw", G_CALLBACK(OnExposeStatic), this); g_signal_connect(G_OBJECT(window), "key-press-event", G_CALLBACK(OnKeyPressStatic), this); g_signal_connect(G_OBJECT(window), "key-release-event", G_CALLBACK(OnKeyReleaseStatic), this); g_signal_connect(G_OBJECT(window), "scroll-event", G_CALLBACK(OnScrollVW), this); g_signal_connect(G_OBJECT(window), "button-press-event", G_CALLBACK(OnButtonPressStatic), this); g_signal_connect(G_OBJECT(window), "button-release-event", G_CALLBACK(OnButtonReleaseStatic), this); g_signal_connect(G_OBJECT(window), "motion-notify-event", G_CALLBACK(OnMotionNotifyStatic), this); g_signal_connect(G_OBJECT(window), "key-press-event", G_CALLBACK(OnKeyPress), this); g_signal_connect(G_OBJECT(window), "key-release-event", G_CALLBACK(OnKeyRelease), this); g_signal_connect(G_OBJECT(window), "configure-event", G_CALLBACK(OnConfigureStatic), this); g_signal_connect(G_OBJECT(window), "realize", G_CALLBACK(OnRealizeStatic), this); g_signal_connect_after(G_OBJECT(render_widget), "configure-event", G_CALLBACK(OnConfigureDareaStatic), this); #if !GTK_CHECK_VERSION(3,10,0) // do not draw the default background gtk_widget_set_double_buffered (GTK_WIDGET(render_widget), false); #endif gtk_window_set_transient_for(GTK_WINDOW(window), GTK_WINDOW(Console.window)); #if !GTK_CHECK_VERSION(3,14,0) gtk_window_set_has_resize_grip(GTK_WINDOW(window), false); #endif } else if (windowKind == W_Fullscreen) { render_widget = gtk_drawing_area_new(); gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(render_widget)); g_signal_connect(G_OBJECT(window), "configure-event", G_CALLBACK(OnConfigureNotify), this); g_signal_connect(G_OBJECT(window), "focus-in-event", G_CALLBACK(OnFocusInFS), this); g_signal_connect(G_OBJECT(window), "focus-out-event", G_CALLBACK(OnFocusOutFS), this); g_signal_connect(G_OBJECT(window), "unmap-event", G_CALLBACK(OnFocusOutFS), this); g_signal_connect(G_OBJECT(window), "button-press-event", G_CALLBACK(OnButtonPressFS), this); g_signal_connect(G_OBJECT(window), "button-release-event", G_CALLBACK(OnButtonRelease), this); g_signal_connect(G_OBJECT(window), "motion-notify-event", G_CALLBACK(OnMotionNotify), this); g_signal_connect(G_OBJECT(window), "key-press-event", G_CALLBACK(OnKeyPress), this); g_signal_connect(G_OBJECT(window), "key-release-event", G_CALLBACK(OnKeyRelease), this); g_signal_connect(G_OBJECT(window), "scroll-event", G_CALLBACK(OnScroll), this); gtk_widget_add_events(GTK_WIDGET(window), GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK); #if !GTK_CHECK_VERSION(3,10,0) gtk_widget_set_double_buffered (GTK_WIDGET(render_widget), false); #endif GValue val = {0,{{0}}}; g_value_init (&val, G_TYPE_BOOLEAN); g_value_set_boolean (&val, true); g_object_set_property (G_OBJECT (render_widget), "can-focus", &val); g_object_set_property (G_OBJECT (window), "can-focus", &val); g_value_unset (&val); #if !GTK_CHECK_VERSION(3,14,0) gtk_window_set_has_resize_grip(GTK_WINDOW(window), false); #endif } else if (windowKind == W_GuiWindow) { render_widget = window; g_signal_connect(G_OBJECT(window), "button-press-event", G_CALLBACK(OnButtonPressGD), this); g_signal_connect(G_OBJECT(window), "button-release-event", G_CALLBACK(OnButtonReleaseGD), this); g_signal_connect(G_OBJECT(window), "motion-notify-event", G_CALLBACK(OnMotionNotifyGD), this); g_signal_connect(G_OBJECT(window), "configure-event", G_CALLBACK(OnConfigureGD), this); g_signal_connect(G_OBJECT(window), "scroll-event", G_CALLBACK(OnScroll), this); gtk_window_set_transient_for(GTK_WINDOW(window), GTK_WINDOW(Console.window)); #if !GTK_CHECK_VERSION(3,14,0) gtk_window_set_has_resize_grip(GTK_WINDOW(window), false); #endif } else if (windowKind == W_Console) { render_widget = window; } assert(window); assert(render_widget); // Override gtk's default to match name/class of the XLib windows gtk_window_set_wmclass(GTK_WINDOW(window), C4ENGINENAME, C4ENGINENAME); gtk_window_set_default_size(GTK_WINDOW(window), size->Wdt, size->Hgt); g_signal_connect(G_OBJECT(window), "delete-event", G_CALLBACK(OnDelete), this); handlerDestroy = g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(OnDestroyStatic), this); gtk_widget_add_events(GTK_WIDGET(window), GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_SCROLL_MASK); // TODO: It would be nice to support GDK_SCROLL_SMOOTH_MASK and // smooth scrolling for scrolling in menus, however that should not // change the scroll wheel behaviour ingame for zooming or // inventory change. Note that when both GDK_SCROLL_MASK and // GDK_SMOOTH_SCROLL_MASK are enabled, both type of scroll events // are reported, so one needs to make sure to not double-process them. // It would be nice to have smooth scrolling also e.g. for zooming // ingame, but it probably requires the notion of smooth scrolling // other parts of the engine as well. #ifdef GDK_WINDOWING_X11 GdkScreen * scr = gtk_widget_get_screen(GTK_WIDGET(render_widget)); Display * const dpy = gdk_x11_display_get_xdisplay(gdk_display_get_default()); XVisualInfo *vis_info = glXGetVisualFromFBConfig(dpy, Info); assert(vis_info); GdkVisual * vis = gdk_x11_screen_lookup_visual(scr, vis_info->visualid); XFree(vis_info); gtk_widget_set_visual(GTK_WIDGET(render_widget),vis); #endif gtk_widget_show_all(GTK_WIDGET(window)); // XVisualInfo vitmpl; int blub; // vitmpl.visual = gdk_x11_visual_get_xvisual(gtk_widget_get_visual(window)); // vitmpl.visualid = XVisualIDFromVisual(vitmpl.visual); // Info = XGetVisualInfo(dpy, VisualIDMask, &vitmpl, &blub); // printf("%p\n", gtk_widget_get_visual(render_widget)); // Info = gdk_x11_visual_get_xvisual(gtk_widget_get_visual(render_widget)); // Default icon has been set right after gtk_init(), // so we don't need to take care about setting the icon here. SetTitle(Title); // Wait until window is mapped to get the window's XID gtk_widget_show_now(GTK_WIDGET(window)); GdkWindow* render_gdk_wnd; if (GTK_IS_LAYOUT(render_widget)) render_gdk_wnd = gtk_layout_get_bin_window(GTK_LAYOUT(render_widget)); else render_gdk_wnd = gtk_widget_get_window(GTK_WIDGET(render_widget)); #ifdef GDK_WINDOWING_X11 renderwnd = GDK_WINDOW_XID(render_gdk_wnd); #elif defined(GDK_WINDOWING_WIN32) renderwnd = reinterpret_cast<HWND>(gdk_win32_window_get_handle(render_gdk_wnd)); #endif // Make sure the window is shown and ready to be rendered into, // this avoids an async X error. gdk_flush(); if (windowKind == W_Fullscreen) gdk_window_set_cursor(gtk_widget_get_window(GTK_WIDGET(render_widget)), gdk_cursor_new_for_display(gdk_display_get_default(), GDK_BLANK_CURSOR)); return this; }
static void gsr2_create_table (GNCSplitReg2 *gsr) { GncTreeViewSplitReg *view; GncTreeModelSplitReg *model; GtkTreeModel *s_model; GtkWidget *scrolled_window; GtkTreeViewColumn *col; GNCLedgerDisplay2Type ledger_type; GtkWidget *hbox; gdouble num_of_trans; gchar *state_section; GKeyFile *state_file = gnc_state_get_current(); const GncGUID * guid; Account * account; account = gnc_ledger_display2_leader (gsr->ledger); guid = xaccAccountGetGUID (account); ENTER("create table gsr=%p", gsr); gnc_ledger_display2_set_user_data (gsr->ledger, (gpointer)gsr); gnc_ledger_display2_set_handlers (gsr->ledger, gnc_split_reg2_ld_destroy, gnc_split_reg2_get_parent); model = gnc_ledger_display2_get_split_model_register (gsr->ledger); view = gnc_tree_view_split_reg_new_with_model (model); g_object_unref (G_OBJECT (model)); /* State_section is used to store per register state: column widths, sort order,... */ ledger_type = gnc_ledger_display2_type (gsr->ledger); if (ledger_type == LD2_GL && model->type == GENERAL_JOURNAL2) state_section = g_strdup (STATE_SECTION_GEN_JOURNAL); else if (ledger_type == LD2_SUBACCOUNT) { gchar guidstr[GUID_ENCODING_LENGTH+1]; guid_to_string_buff (guid, guidstr); state_section = g_strconcat (STATE_SECTION_REG_PREFIX, " ", guidstr, " w/subaccounts", NULL); } else { gchar guidstr[GUID_ENCODING_LENGTH+1]; guid_to_string_buff (guid, guidstr); state_section = g_strconcat (STATE_SECTION_REG_PREFIX, " ", guidstr, NULL); } g_object_set (G_OBJECT (view), "state-section", state_section, "show-column-menu", FALSE, NULL); // Create a hbox for treeview and scrollbar. hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_set_homogeneous (GTK_BOX (hbox), FALSE); gtk_widget_show (hbox); scrolled_window = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_widget_show (scrolled_window); gtk_box_pack_start (GTK_BOX (gsr), hbox, TRUE, TRUE, 0); num_of_trans = model->number_of_trans_in_full_tlist - 1; gsr->scroll_adj = GTK_ADJUSTMENT (gtk_adjustment_new (model->position_of_trans_in_full_tlist, 0.0, num_of_trans + 10, 1.0, 10.0, 10.0)); gsr->scroll_bar = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, GTK_ADJUSTMENT (gsr->scroll_adj)); gtk_widget_show (gsr->scroll_bar); gtk_box_pack_start (GTK_BOX (hbox), gsr->scroll_bar, FALSE, FALSE, 2); gtk_box_pack_start (GTK_BOX (hbox), scrolled_window, TRUE, TRUE, 0); gnc_ledger_display2_set_split_view_register (gsr->ledger, view); /* Synchronize model state with view state * (needed to properly set up the internal query) */ /* Restore the sort depth from saved state */ model->sort_depth = g_key_file_get_integer (state_file, state_section, "sort_depth", NULL); g_free(state_section); s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view)); if (s_model) { gint sort_col; GtkSortType type; if (gtk_tree_sortable_get_sort_column_id (GTK_TREE_SORTABLE (s_model), &sort_col, &type)) { model->sort_col = sort_col; model->sort_direction = type; } } gnc_tree_view_configure_columns (GNC_TREE_VIEW (view)); if (ledger_type == LD2_GL && model->type == GENERAL_JOURNAL2) gnc_tree_view_set_show_column_menu (GNC_TREE_VIEW (view), TRUE); else gnc_tree_view_set_show_column_menu (GNC_TREE_VIEW (view), FALSE); /* This column gets all the free space */ gnc_tree_view_expand_columns (GNC_TREE_VIEW (view), "descnotes", NULL); /* This sets the status color column, 4 is the minimum */ col = gnc_tree_view_find_column_by_name (GNC_TREE_VIEW (view), "status"); if (col != NULL) g_object_set (G_OBJECT(col), "resizable", FALSE, "sizing", GTK_TREE_VIEW_COLUMN_FIXED, "fixed-width", 4, NULL); gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (view), TRUE); gtk_widget_show (GTK_WIDGET (view)); gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET (view)); gtk_widget_show (GTK_WIDGET (gsr)); /* Should this be read only */ gnc_tree_view_split_reg_set_read_only (view, gsr->read_only); /* This tells the ledger that we have a valid tree view */ gnc_ledger_display2_set_split_view_refresh (gsr->ledger, TRUE); /* This triggers the update of the summary bar */ g_signal_connect_after (model, "refresh_status_bar", G_CALLBACK (gsr2_redraw_all_cb), gsr); //this works // This will keep scrollbar in sync. g_signal_connect (model, "scroll_sync", G_CALLBACK (gsr2_scroll_sync_cb), gsr); /* This triggers the update of the help text */ g_signal_connect (view, "help_signal", G_CALLBACK (gsr2_emit_help_changed), gsr); // this works gsr2_scroll_value_changed_cb (GTK_ADJUSTMENT (gsr->scroll_adj), gsr); /* This triggers the tooltip to change when scrolling */ g_signal_connect (gsr->scroll_adj, "value-changed", G_CALLBACK (gsr2_scroll_value_changed_cb), gsr); // this works /* This triggers the model update when mouse button released */ g_signal_connect (gsr->scroll_bar, "button-release-event", G_CALLBACK (gsr2_scroll_button_event_cb), gsr); // Connect a call back to update the sort settings. g_signal_connect (GTK_TREE_SORTABLE (s_model), "sort-column-changed", G_CALLBACK (gnc_split_reg2_sort_changed_cb), gsr); LEAVE(" "); }
static GtkWidget * gnucash_register_create_widget (Table *table) { GnucashRegister *reg; GtkWidget *header; GtkWidget *widget; GtkWidget *sheet; GtkWidget *scrollbar; GtkWidget *box; reg = g_object_new (GNUCASH_TYPE_REGISTER, NULL); widget = GTK_WIDGET(reg); sheet = gnucash_sheet_new (table); reg->sheet = sheet; GNUCASH_SHEET(sheet)->reg = widget; header = gnc_header_new (GNUCASH_SHEET(sheet)); gtk_grid_attach (GTK_GRID(widget), header, 0, 0, 1, 1); gtk_widget_set_hexpand (header, TRUE); gtk_widget_set_halign (header, GTK_ALIGN_FILL); gtk_widget_set_vexpand (header, FALSE); gtk_widget_set_valign (header, GTK_ALIGN_FILL); g_object_set (header, "margin", 0, NULL); gtk_widget_show (header); gtk_grid_attach (GTK_GRID(widget), sheet, 0, 1, 1, 1); gtk_widget_set_hexpand (sheet, TRUE); gtk_widget_set_halign (sheet, GTK_ALIGN_FILL); gtk_widget_set_vexpand (sheet, TRUE); gtk_widget_set_valign (sheet, GTK_ALIGN_FILL); g_object_set (sheet, "margin", 0, NULL); gtk_widget_show (sheet); scrollbar = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, GNUCASH_SHEET(sheet)->vadj); gtk_grid_attach (GTK_GRID(widget), GTK_WIDGET(scrollbar), 1, 0, 1, 2); gtk_widget_set_hexpand (GTK_WIDGET(scrollbar), FALSE); gtk_widget_set_halign (GTK_WIDGET(scrollbar), GTK_ALIGN_FILL); gtk_widget_set_vexpand (GTK_WIDGET(scrollbar), TRUE); gtk_widget_set_valign (GTK_WIDGET(scrollbar), GTK_ALIGN_FILL); g_object_set (GTK_WIDGET(scrollbar), "margin", 0, NULL); gtk_widget_show (scrollbar); GNUCASH_SHEET(sheet)->vscrollbar = scrollbar; g_signal_connect(G_OBJECT(scrollbar), "enter-notify-event", G_CALLBACK(gnucash_register_enter_scrollbar), reg); scrollbar = gtk_scrollbar_new (GTK_ORIENTATION_HORIZONTAL, GNUCASH_SHEET(sheet)->hadj); gtk_grid_attach (GTK_GRID(widget), GTK_WIDGET(scrollbar), 0, 2, 1, 1); gtk_widget_set_hexpand (GTK_WIDGET(scrollbar), TRUE); gtk_widget_set_halign (GTK_WIDGET(scrollbar), GTK_ALIGN_FILL); gtk_widget_set_vexpand (GTK_WIDGET(scrollbar), FALSE); gtk_widget_set_valign (GTK_WIDGET(scrollbar), GTK_ALIGN_FILL); g_object_set (GTK_WIDGET(scrollbar), "margin", 0, NULL); reg->hscrollbar = scrollbar; gtk_widget_show (reg->hscrollbar); reg->hscrollbar_visible = TRUE; GNUCASH_SHEET(sheet)->hscrollbar = scrollbar; g_signal_connect(G_OBJECT(scrollbar), "enter-notify-event", G_CALLBACK(gnucash_register_enter_scrollbar), reg); g_signal_connect (GNUCASH_SHEET(sheet)->hadj, "changed", G_CALLBACK (gnucash_register_update_hadjustment), reg); return widget; }
struct tilda_term_ *tilda_term_init (struct tilda_window_ *tw) { DEBUG_FUNCTION ("tilda_term_init"); DEBUG_ASSERT (tw != NULL); int ret; struct tilda_term_ *term; GError *error = NULL; tilda_term *current_tt; gint current_tt_index; char *current_tt_dir = NULL; term = g_malloc (sizeof (struct tilda_term_)); /* Add to GList list of tilda_term structures in tilda_window structure */ tw->terms = g_list_append (tw->terms, term); /* Check for a failed allocation */ if (!term) return NULL; /* Set the PID to unset value */ term->pid = -1; /* Add the parent window reference */ term->tw = tw; /* Create a non-homogenous hbox, with 0px spacing between members */ term->hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); /* Create the terminal */ term->vte_term = vte_terminal_new (); /* Create the scrollbar for the terminal */ term->scrollbar = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (VTE_TERMINAL(term->vte_term)))); /* Initialize to false, we have not yet dropped to the default shell */ term->dropped_to_default_shell = FALSE; /* Set properties of the terminal */ tilda_term_config_defaults (term); /* Update the font scale because the newly created terminal uses the default font size */ tilda_term_adjust_font_scale(term, tw->current_scale_factor); /* Pack everything into the hbox */ gtk_box_pack_end (GTK_BOX(term->hbox), term->scrollbar, FALSE, FALSE, 0); gtk_box_pack_end (GTK_BOX(term->hbox), term->vte_term, TRUE, TRUE, 0); gtk_widget_show (term->scrollbar); /* Set the scrollbar position */ tilda_term_set_scrollbar_position (term, config_getint ("scrollbar_pos")); /** Signal Connection **/ g_signal_connect (G_OBJECT(term->vte_term), "child-exited", G_CALLBACK(child_exited_cb), term); g_signal_connect (G_OBJECT(term->vte_term), "window-title-changed", G_CALLBACK(window_title_changed_cb), term); g_signal_connect (G_OBJECT(term->vte_term), "eof", G_CALLBACK(child_exited_cb), term); g_signal_connect (G_OBJECT(term->vte_term), "status-line-changed", G_CALLBACK(status_line_changed_cb), term); g_signal_connect (G_OBJECT(term->vte_term), "button-press-event", G_CALLBACK(button_press_cb), term); g_signal_connect (G_OBJECT(term->vte_term), "key-press-event", G_CALLBACK(key_press_cb), term); //needs GDK_KEY_PRESS_MASK /* Connect to application request signals. */ g_signal_connect (G_OBJECT(term->vte_term), "iconify-window", G_CALLBACK(iconify_window_cb), tw->window); g_signal_connect (G_OBJECT(term->vte_term), "deiconify-window", G_CALLBACK(deiconify_window_cb), tw->window); g_signal_connect (G_OBJECT(term->vte_term), "raise-window", G_CALLBACK(raise_window_cb), tw->window); g_signal_connect (G_OBJECT(term->vte_term), "lower-window", G_CALLBACK(lower_window_cb), tw->window); g_signal_connect (G_OBJECT(term->vte_term), "maximize-window", G_CALLBACK(maximize_window_cb), tw->window); g_signal_connect (G_OBJECT(term->vte_term), "restore-window", G_CALLBACK(restore_window_cb), tw->window); g_signal_connect (G_OBJECT(term->vte_term), "refresh-window", G_CALLBACK(refresh_window_cb), tw->window); g_signal_connect (G_OBJECT(term->vte_term), "move-window", G_CALLBACK(move_window_cb), tw->window); g_signal_connect (G_OBJECT (tw->notebook), "switch-page", G_CALLBACK (tilda_terminal_switch_page_cb), tw); /* Match URL's, etc */ term->http_regexp=g_regex_new(HTTP_REGEXP, G_REGEX_CASELESS, G_REGEX_MATCH_NOTEMPTY, &error); ret = vte_terminal_match_add_gregex(VTE_TERMINAL(term->vte_term), term->http_regexp,0); vte_terminal_match_set_cursor_type (VTE_TERMINAL(term->vte_term), ret, GDK_HAND2); /* Show the child widgets */ gtk_widget_show (term->vte_term); gtk_widget_show (term->hbox); /* Get current term's working directory */ current_tt_index = gtk_notebook_get_current_page (GTK_NOTEBOOK(tw->notebook)); current_tt = g_list_nth_data (tw->terms, current_tt_index); if (current_tt != NULL) { current_tt_dir = tilda_term_get_cwd(current_tt); } /* Fork the appropriate command into the terminal */ ret = start_shell (term, FALSE, current_tt_dir); g_free(current_tt_dir); if (ret) goto err_fork; return term; err_fork: g_free (term); return NULL; }
struct tilda_term_ *tilda_term_init (struct tilda_window_ *tw) { DEBUG_FUNCTION ("tilda_term_init"); DEBUG_ASSERT (tw != NULL); int ret; struct tilda_term_ *term; GError *error = NULL; term = g_malloc (sizeof (struct tilda_term_)); /* Check for a failed allocation */ if (!term) return NULL; /* Add the parent window reference */ term->tw = tw; /* Create a non-homogenous hbox, with 0px spacing between members */ term->hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); /* Create the terminal */ term->vte_term = vte_terminal_new (); /* Create the scrollbar for the terminal */ term->scrollbar = gtk_scrollbar_new (GTK_ORIENTATION_HORIZONTAL, gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (VTE_TERMINAL(term->vte_term)))); /* Set properties of the terminal */ tilda_term_config_defaults (term); /* Pack everything into the hbox */ gtk_box_pack_end (GTK_BOX(term->hbox), term->scrollbar, FALSE, FALSE, 0); gtk_box_pack_end (GTK_BOX(term->hbox), term->vte_term, TRUE, TRUE, 0); gtk_widget_show (term->scrollbar); /* Set the scrollbar position */ tilda_term_set_scrollbar_position (term, config_getint ("scrollbar_pos")); /** Signal Connection **/ g_signal_connect (G_OBJECT(term->vte_term), "child-exited", G_CALLBACK(child_exited_cb), term); g_signal_connect (G_OBJECT(term->vte_term), "window-title-changed", G_CALLBACK(window_title_changed_cb), term); g_signal_connect (G_OBJECT(term->vte_term), "eof", G_CALLBACK(child_exited_cb), term); g_signal_connect (G_OBJECT(term->vte_term), "status-line-changed", G_CALLBACK(status_line_changed_cb), term); g_signal_connect (G_OBJECT(term->vte_term), "button-press-event", G_CALLBACK(button_press_cb), term); /* Connect to application request signals. */ g_signal_connect (G_OBJECT(term->vte_term), "iconify-window", G_CALLBACK(iconify_window_cb), tw->window); g_signal_connect (G_OBJECT(term->vte_term), "deiconify-window", G_CALLBACK(deiconify_window_cb), tw->window); g_signal_connect (G_OBJECT(term->vte_term), "raise-window", G_CALLBACK(raise_window_cb), tw->window); g_signal_connect (G_OBJECT(term->vte_term), "lower-window", G_CALLBACK(lower_window_cb), tw->window); g_signal_connect (G_OBJECT(term->vte_term), "maximize-window", G_CALLBACK(maximize_window_cb), tw->window); g_signal_connect (G_OBJECT(term->vte_term), "restore-window", G_CALLBACK(restore_window_cb), tw->window); g_signal_connect (G_OBJECT(term->vte_term), "refresh-window", G_CALLBACK(refresh_window_cb), tw->window); g_signal_connect (G_OBJECT(term->vte_term), "move-window", G_CALLBACK(move_window_cb), tw->window); /* Connect to font tweakage. */ g_signal_connect (G_OBJECT(term->vte_term), "increase-font-size", G_CALLBACK(increase_font_size_cb), tw->window); g_signal_connect (G_OBJECT(term->vte_term), "decrease-font-size", G_CALLBACK(decrease_font_size_cb), tw->window); /* Match URL's, etc */ term->http_regexp=g_regex_new(HTTP_REGEXP, G_REGEX_CASELESS, G_REGEX_MATCH_NOTEMPTY, &error); ret = vte_terminal_match_add_gregex(VTE_TERMINAL(term->vte_term), term->http_regexp,0); vte_terminal_match_set_cursor_type (VTE_TERMINAL(term->vte_term), ret, GDK_HAND2); /* Show the child widgets */ gtk_widget_show (term->vte_term); gtk_widget_show (term->hbox); /* Fork the appropriate command into the terminal */ ret = start_shell (term); if (ret) goto err_fork; return term; err_fork: g_free (term); return NULL; }
//____________________________________________________ SliderDemoWidget::SliderDemoWidget( void ) { // main widget GtkWidget* mainWidget( gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 0 ) ); gtk_box_set_spacing( GTK_BOX( mainWidget ), 5 ); setWidget( mainWidget ); // setup setName( "Sliders" ); setComments( "Shows the appearance of sliders, progress bars and scrollbars" ); setIconName( "measure" ); realize(); // horizontal sliders { // frame GtkWidget* frame( gtk_frame_new( "Horizontal" ) ); gtk_box_pack_start( GTK_BOX( mainWidget ), frame, true, true, 0 ); gtk_widget_show( frame ); // container GtkWidget* box( gtk_box_new( GTK_ORIENTATION_VERTICAL, 0 ) ); gtk_container_set_border_width( GTK_CONTAINER( box ), 5 ); gtk_box_set_spacing( GTK_BOX( box ), 2 ); gtk_widget_show( box ); gtk_container_add( GTK_CONTAINER( frame ), box ); // scale _horizontalSliders._scale = gtk_scale_new_with_range( GTK_ORIENTATION_HORIZONTAL, 0, 100, 1 ); gtk_scale_set_draw_value( GTK_SCALE( _horizontalSliders._scale ), false ); gtk_box_pack_start( GTK_BOX( box ), _horizontalSliders._scale, false, true, 0 ); gtk_widget_show( _horizontalSliders._scale ); // progress entry _horizontalSliders._progressEntry = gtk_entry_new(); gtk_entry_set_text( GTK_ENTRY( _horizontalSliders._progressEntry ), "Progress Bar Entry" ); gtk_box_pack_start( GTK_BOX( box ), _horizontalSliders._progressEntry, false, true, 0 ); gtk_widget_show( _horizontalSliders._progressEntry ); // progress bar _horizontalSliders._progressBar = gtk_progress_bar_new(); gtk_progress_bar_set_show_text( GTK_PROGRESS_BAR( _horizontalSliders._progressBar ), true ); gtk_orientable_set_orientation( GTK_ORIENTABLE( _horizontalSliders._progressBar ), GTK_ORIENTATION_HORIZONTAL ); gtk_box_pack_start( GTK_BOX( box ), _horizontalSliders._progressBar, false, true, 0 ); gtk_widget_show( _horizontalSliders._progressBar ); // pulse progressBar _pulseProgressBar = gtk_progress_bar_new(); gtk_orientable_set_orientation( GTK_ORIENTABLE( _pulseProgressBar ), GTK_ORIENTATION_HORIZONTAL ); gtk_progress_bar_set_pulse_step( GTK_PROGRESS_BAR( _pulseProgressBar ), 0.01 ); gtk_box_pack_start( GTK_BOX( box ), _pulseProgressBar, false, true, 0 ); gtk_widget_show( _pulseProgressBar ); // scrollbar GtkAdjustment* adjustment( GTK_ADJUSTMENT( gtk_adjustment_new( 25, 0, 110, 1, 1, 10 ) ) ); _horizontalSliders._scrollBar = gtk_scrollbar_new( GTK_ORIENTATION_HORIZONTAL, adjustment ); gtk_box_pack_start( GTK_BOX( box ), _horizontalSliders._scrollBar, false, true, 0 ); gtk_widget_show( _horizontalSliders._scrollBar ); } // vertical sliders { // frame GtkWidget* frame( gtk_frame_new( "Vertical" ) ); gtk_box_pack_start( GTK_BOX( mainWidget ), frame, false, true, 0 ); gtk_widget_show( frame ); // container GtkWidget* box( gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 0 ) ); gtk_container_set_border_width( GTK_CONTAINER( box ), 5 ); gtk_box_set_spacing( GTK_BOX( box ), 5 ); gtk_widget_show( box ); gtk_container_add( GTK_CONTAINER( frame ), box ); // scale _verticalSliders._scale = gtk_scale_new_with_range( GTK_ORIENTATION_VERTICAL, 0, 100, 1 ); gtk_scale_set_draw_value( GTK_SCALE( _verticalSliders._scale ), false ); gtk_box_pack_start( GTK_BOX( box ), _verticalSliders._scale, false, true, 0 ); gtk_widget_show( _verticalSliders._scale ); // progress bar _verticalSliders._progressBar = gtk_progress_bar_new(); gtk_progress_bar_set_show_text( GTK_PROGRESS_BAR( _verticalSliders._progressBar ), true ); gtk_orientable_set_orientation( GTK_ORIENTABLE( _verticalSliders._progressBar ), GTK_ORIENTATION_VERTICAL ); gtk_box_pack_start( GTK_BOX( box ), _verticalSliders._progressBar, false, true, 0 ); gtk_widget_show( _verticalSliders._progressBar ); // scrollbar GtkAdjustment* adjustment( GTK_ADJUSTMENT( gtk_adjustment_new( 25, 0, 110, 1, 1, 10 ) ) ); _verticalSliders._scrollBar = gtk_scrollbar_new( GTK_ORIENTATION_VERTICAL, adjustment ); gtk_box_pack_start( GTK_BOX( box ), _verticalSliders._scrollBar, false, true, 0 ); gtk_widget_show( _verticalSliders._scrollBar ); } // connections connect( G_OBJECT( _horizontalSliders._scale ), "value-changed", GCallback( valueChanged ), this ); connect( G_OBJECT( _horizontalSliders._scrollBar ), "value-changed", GCallback( valueChanged ), this ); connect( G_OBJECT( _verticalSliders._scale ), "value-changed", GCallback( valueChanged ), this ); connect( G_OBJECT( _verticalSliders._scrollBar ), "value-changed", GCallback( valueChanged ), this ); // Initialize all gtk_range_set_value( GTK_RANGE( _verticalSliders._scale ), 25 ); }
static gboolean nimf_candidate_start (NimfService *service) { g_debug (G_STRLOC ": %s", G_STRFUNC); NimfCandidate *candidate = NIMF_CANDIDATE (service); if (candidate->active) return TRUE; GtkCellRenderer *renderer; GtkTreeViewColumn *column[N_COLUMNS]; GtkListStore *store; gint fixed_height = 32; gint horizontal_space; gtk_init (NULL, NULL); /* gtk entry */ candidate->entry = gtk_entry_new (); gtk_editable_set_editable (GTK_EDITABLE (candidate->entry), FALSE); gtk_widget_set_no_show_all (candidate->entry, TRUE); g_signal_connect_after (candidate->entry, "draw", G_CALLBACK (on_entry_draw), NULL); /* gtk tree view */ store = gtk_list_store_new (N_COLUMNS, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING); candidate->treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store)); g_object_unref (store); gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (candidate->treeview), FALSE); gtk_widget_style_get (candidate->treeview, "horizontal-separator", &horizontal_space, NULL); candidate->cell_height = fixed_height + horizontal_space / 2; gtk_widget_set_size_request (candidate->treeview, (gint) (candidate->cell_height * 10 / 1.6), candidate->cell_height * 10); g_signal_connect (candidate->treeview, "row-activated", (GCallback) on_tree_view_row_activated, candidate); /* column */ renderer = gtk_cell_renderer_text_new (); g_object_set (renderer, "height", fixed_height, "font", "Sans 14", NULL); column[INDEX_COLUMN] = gtk_tree_view_column_new_with_attributes ("Index", renderer, "text", INDEX_COLUMN, NULL); column[MAIN_COLUMN] = gtk_tree_view_column_new_with_attributes ("Main", renderer, "text", MAIN_COLUMN, NULL); column[EXTRA_COLUMN] = gtk_tree_view_column_new_with_attributes ("Extra", renderer, "text", EXTRA_COLUMN, NULL); gtk_tree_view_column_set_sizing (column[INDEX_COLUMN], GTK_TREE_VIEW_COLUMN_AUTOSIZE); gtk_tree_view_column_set_sizing (column[MAIN_COLUMN], GTK_TREE_VIEW_COLUMN_AUTOSIZE); gtk_tree_view_column_set_sizing (column[EXTRA_COLUMN], GTK_TREE_VIEW_COLUMN_AUTOSIZE); gtk_tree_view_append_column (GTK_TREE_VIEW (candidate->treeview), column[INDEX_COLUMN]); gtk_tree_view_append_column (GTK_TREE_VIEW (candidate->treeview), column[MAIN_COLUMN]); gtk_tree_view_append_column (GTK_TREE_VIEW (candidate->treeview), column[EXTRA_COLUMN]); /* scrollbar */ GtkAdjustment *adjustment = gtk_adjustment_new (1.0, 1.0, 2.0, 1.0, 1.0, 1.0); candidate->scrollbar = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, adjustment); gtk_range_set_slider_size_fixed (GTK_RANGE (candidate->scrollbar), FALSE); g_signal_connect (candidate->scrollbar, "change-value", G_CALLBACK (on_range_change_value), candidate); GtkCssProvider *provider; GtkStyleContext *style_context; provider = gtk_css_provider_new (); gtk_css_provider_load_from_data (GTK_CSS_PROVIDER (provider), ".scrollbar {" " -GtkScrollbar-has-backward-stepper: true;" " -GtkScrollbar-has-forward-stepper: true;" " -GtkScrollbar-has-secondary-forward-stepper: true;" "}" , -1, NULL); style_context = gtk_widget_get_style_context (candidate->scrollbar); gtk_style_context_add_provider (style_context, GTK_STYLE_PROVIDER (provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); g_object_unref (provider); /* gtk box */ GtkWidget *vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); GtkWidget *hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_pack_start (GTK_BOX (vbox), candidate->entry, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (hbox), candidate->treeview, TRUE, TRUE, 0); gtk_box_pack_end (GTK_BOX (hbox), candidate->scrollbar, FALSE, TRUE, 0); /* gtk window */ candidate->window = gtk_window_new (GTK_WINDOW_POPUP); gtk_window_set_type_hint (GTK_WINDOW (candidate->window), GDK_WINDOW_TYPE_HINT_POPUP_MENU); gtk_container_set_border_width (GTK_CONTAINER (candidate->window), 1); gtk_container_add (GTK_CONTAINER (candidate->window), vbox); gtk_widget_realize (candidate->window); candidate->active = TRUE; return TRUE; }
static GObject * mud_subwindow_constructor (GType gtype, guint n_properties, GObjectConstructParam *properties) { GtkWidget *term_box; MudWindow *app; GtkWidget *main_window; MudSubwindow *self; GObject *obj; MudSubwindowClass *klass; GObjectClass *parent_class; GtkBuilder *builder; /* Chain up to parent constructor */ klass = MUD_SUBWINDOW_CLASS( g_type_class_peek(MUD_TYPE_SUBWINDOW) ); parent_class = G_OBJECT_CLASS( g_type_class_peek_parent(klass) ); obj = parent_class->constructor(gtype, n_properties, properties); self = MUD_SUBWINDOW(obj); if(!self->priv->parent_view) { g_printf("ERROR: Tried to instantiate MudSubwindow without passing parent view\n"); g_error("Tried to instantiate MudSubwindow without passing parent view"); } if(!self->priv->title) { g_printf("ERROR: Tried to instantiate MudSubwindow without passing title\n"); g_error("Tried to instantiate MudSubwindow without passing title."); } if(!self->priv->identifier) { g_printf("ERROR: Tried to instantiate MudSubwindow without passing identifier\n"); g_error("Tried to instantiate MudSubwindow without passing identifier."); } if(self->priv->width == 0 || self->priv->height == 0) { g_printf("ERROR: Tried to instantiate MudSubwindow without passing valid width/height\n"); g_error("Tried to instantiate MudSubwindow without passing valid width/height."); } self->priv->old_width = self->priv->width; self->priv->old_height = self->priv->height; self->priv->initial_width = self->priv->width; self->priv->initial_height = self->priv->height; /* start glading */ builder = gtk_builder_new_from_resource ("/org/gnome/MUD/main.ui"); self->priv->window = GTK_WIDGET(gtk_builder_get_object(builder, "subwindow")); g_object_unref(builder); gtk_window_set_type_hint(GTK_WINDOW(self->priv->window), GDK_WINDOW_TYPE_HINT_UTILITY); gtk_window_set_skip_taskbar_hint(GTK_WINDOW(self->priv->window), TRUE); gtk_window_set_skip_pager_hint(GTK_WINDOW(self->priv->window), TRUE); g_object_get(self->priv->parent_view, "window", &app, NULL); g_object_get(app, "window", &main_window, NULL); gtk_window_set_transient_for(GTK_WINDOW(self->priv->window), GTK_WINDOW(main_window)); self->priv->vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); self->priv->entry = gtk_entry_new(); gtk_widget_hide(self->priv->entry); self->priv->terminal = vte_terminal_new(); self->priv->scrollbar = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (self->priv->terminal))); term_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); vte_terminal_set_encoding(VTE_TERMINAL(self->priv->terminal), "ISO-8859-1", NULL); /* TODO: This is deprecated; if keeping, at least add error handling? */ /* TODO: set_emulation doesn't exist anymore. We don't really care, but does it affect TTYPE queries? */ /* vte_terminal_set_emulation(VTE_TERMINAL(self->priv->terminal), "xterm"); */ vte_terminal_set_cursor_shape(VTE_TERMINAL(self->priv->terminal), VTE_CURSOR_SHAPE_UNDERLINE); vte_terminal_set_cursor_blink_mode(VTE_TERMINAL(self->priv->terminal), VTE_CURSOR_BLINK_OFF); vte_terminal_set_size(VTE_TERMINAL(self->priv->terminal), self->priv->initial_width, self->priv->initial_height); gtk_box_pack_start(GTK_BOX(term_box), self->priv->terminal, TRUE, TRUE, 0); gtk_box_pack_end(GTK_BOX(term_box), self->priv->scrollbar, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(self->priv->vbox), term_box, TRUE, TRUE, 0); gtk_box_pack_end(GTK_BOX(self->priv->vbox), self->priv->entry, FALSE, FALSE, 0); gtk_container_add(GTK_CONTAINER(self->priv->window), self->priv->vbox); gtk_window_set_title(GTK_WINDOW(self->priv->window), self->priv->title); gtk_widget_show(term_box); gtk_widget_show(self->priv->vbox); if(self->priv->scroll) gtk_widget_show(self->priv->scrollbar); gtk_widget_show(self->priv->terminal); gtk_widget_show(self->priv->window); gtk_window_get_size(GTK_WINDOW(self->priv->window), &self->priv->pixel_width, &self->priv->pixel_height); return obj; }