/**************************************************************************** Update a font option which is not attached to a widget. ****************************************************************************/ void gui_update_font_full(const char *font_name, const char *font_value, GtkStyle **pstyle) { GtkSettings *settings; GdkScreen *screen; GtkStyle *style; char buf[64]; gui_update_font(font_name, font_value); screen = gdk_screen_get_default(); settings = gtk_settings_get_for_screen(screen); fc_snprintf(buf, sizeof(buf), "Freeciv*.%s", font_name); style = gtk_rc_get_style_by_paths(settings, buf, NULL, G_TYPE_NONE); if (style) { g_object_ref(style); } else { style = gtk_style_new(); } if (*pstyle) { g_object_unref(*pstyle); } *pstyle = style; }
/* * Change font used to display log text, NULL means reset to default */ void GTK_change_log_font(gchar *fontname) { #if 0 // old GTK GtkRcStyle *rcstyle = gtk_rc_style_new(); #else GtkStyle *rcstyle = gtk_style_new(); #endif // if (GTK_OBJECT(v9t9_command_log)->flags & GTK_DESTROYED) {//2.0 if (!v9t9_command_log) { g_free(rcstyle); return; } if (fontname && *fontname) { #if 0 // old GTK rcstyle->font_name = fontname; gtk_widget_modify_style(v9t9_command_log, rcstyle); #else gtk_style_set_font(rcstyle, gdk_font_load(fontname)); gtk_widget_set_style(v9t9_command_log, rcstyle); #endif } else { // this is probably too harsh for a cancel gtk_widget_restore_default_style(v9t9_command_log); } // g_free(rcstyle); }
void SetBG(char * image) { GdkPixbuf * pixbuf = NULL; GdkPixmap * pixmap = NULL; GtkStyle * style = NULL; GtkWidget * p_win = (GtkWidget *) gtk_builder_get_object (g_interface, "window"); char * lien = (char*)calloc (sizeof IMG_FOLDER + sizeof image, sizeof(char)); if(image != NULL) { strcpy(lien,IMG_FOLDER); strcat(lien,image); pixbuf = gdk_pixbuf_new_from_file_at_scale(lien,SizeWin[0],SizeWin[1],FALSE,NULL); gdk_pixbuf_render_pixmap_and_mask (pixbuf, &pixmap, NULL, 0); g_object_unref(pixbuf); style = gtk_style_new(); style->bg_pixmap[0] = pixmap; if(strcmp(BackMenu,image) != 0) { BackMenu = (char*)realloc(NULL, sizeof image * sizeof(char)); strcpy(BackMenu,image); } gtk_widget_set_style (p_win, style); } else { BackMenu = NULL; gtk_widget_set_style(p_win, NULL); } }
void draw_init_font (drawctx_t *ctx, int type, int reset) { if (reset || !ctx->pango_ready) { if (ctx->pangoctx) { g_object_unref (ctx->pangoctx); ctx->pangoctx = NULL; } if (ctx->pangolayout) { g_object_unref (ctx->pangolayout); ctx->pangolayout = NULL; } if (ctx->font_style) { g_object_unref (ctx->font_style); ctx->font_style = NULL; } ctx->font_style = gtk_style_new (); if (ctx->font_style->font_desc) { pango_font_description_free (ctx->font_style->font_desc); ctx->font_style->font_desc = get_new_font_description_from_type (type); } ctx->pangoctx = gdk_pango_context_get (); ctx->pangolayout = pango_layout_new (ctx->pangoctx); pango_layout_set_ellipsize (ctx->pangolayout, PANGO_ELLIPSIZE_END); PangoFontDescription *desc = ctx->font_style->font_desc; ctx->font_weight = pango_font_description_get_weight (desc); pango_layout_set_font_description (ctx->pangolayout, desc); ctx->pango_ready = 1; } else if (ctx->pango_ready) { PangoFontDescription *desc = ctx->font_style->font_desc; pango_layout_set_font_description (ctx->pangolayout, desc); } }
/** * @param stock_id stock name * @return this @a stock_id's pixbuf (or NULL for invalid stock ids) * * Return the pixbuf associated with @a stock_id, the pixbuf is * owned by the stock system and persists throughout runtime. * To display stock icons in widgets use gxk_stock_image() and not * this pixbuf. */ GdkPixbuf* gxk_stock_fallback_pixbuf (const gchar *stock_id) { static GData *stock_pixbuf_repo = NULL; GdkPixbuf *pixbuf; g_return_val_if_fail (stock_id != NULL, NULL); pixbuf = g_datalist_get_data (&stock_pixbuf_repo, stock_id); if (!pixbuf) { GtkIconSet *iset = gtk_icon_factory_lookup_default (stock_id); if (iset) { static GtkStyle *style = NULL; /* FIXME: GTKFIX: gtk_icon_set_render_icon() shouldn't demand a style */ if (!style) style = gtk_style_new (); pixbuf = gtk_icon_set_render_icon (iset, style, GTK_TEXT_DIR_NONE, GTK_STATE_NORMAL, -1, NULL, NULL); g_datalist_set_data (&stock_pixbuf_repo, stock_id, pixbuf); } } return pixbuf; }
/* It updates controls from values of variables, and connects control * signals to callback functions */ void init_diagram (GladeXML *xml) { GtkStyle *style; GtkWidget *canvas; /* Creates trees */ canvas_nodes = g_tree_new_full ( (GCompareDataFunc)canvas_node_compare, NULL, NULL, (GDestroyNotify)canvas_node_delete); canvas_links = g_tree_new_full( (GCompareDataFunc)canvas_link_compare, NULL, NULL, (GDestroyNotify)canvas_link_delete); initialize_pref_controls(); /* Sets canvas background to black */ canvas = glade_xml_get_widget (appdata.xml, "canvas1"); gdk_color_parse ("black", &black_color); gdk_colormap_alloc_color (gdk_colormap_get_system (), &black_color, TRUE, TRUE); style = gtk_style_new (); style->bg[GTK_STATE_NORMAL] = black_color; style->base[GTK_STATE_NORMAL] = black_color; gtk_widget_set_style (canvas, style); gtk_style_set_background (canvas->style, canvas->window, GTK_STATE_NORMAL); /* Initialize the known_protocols table */ delete_gui_protocols (); /* Set the already_updating global flag */ already_updating = FALSE; stop_requested = FALSE; } /* init_diagram */
int iupdrvOpen(int *argc, char ***argv) { GtkStyle* style; if (!gtk_init_check(argc, argv)) return IUP_ERROR; IupSetGlobal("DRIVER", "GTK"); IupStoreGlobal("SYSTEMLANGUAGE", pango_language_to_string(gtk_get_default_language())); /* driver system version */ IupSetfAttribute(NULL, "GTKVERSION", "%d.%d.%d", gtk_major_version, gtk_minor_version, gtk_micro_version); IupSetfAttribute(NULL, "GTKDEVVERSION", "%d.%d.%d", GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION); gtkSetDrvGlobalAttrib(); style = gtk_style_new(); iupgtkUpdateGlobalColors(style); IupSetGlobal("_IUP_RESET_GLOBALCOLORS", "YES"); /* will update the global colors when the first dialog is mapped */ g_object_unref(style); return IUP_NOERROR; }
int setupwindow() { GdkPixmap *background; GdkPixbuf *pixbuf; GdkPixbuf *scaled; GdkScreen *screen; GdkColormap *colormap; GError *error=NULL; GtkStyle *style; window=gtk_window_new(GTK_WINDOW_TOPLEVEL); g_signal_connect(G_OBJECT(window), "expose_event", G_CALLBACK(expose_window),NULL); gtk_window_set_title(GTK_WINDOW(window), "clock"); gtk_window_stick(GTK_WINDOW(window)); gtk_window_set_resizable(GTK_WINDOW(window),TRUE); gtk_window_set_skip_taskbar_hint(GTK_WINDOW(window),TRUE); gtk_window_set_keep_above(GTK_WINDOW(window),TRUE); gtk_container_set_border_width(GTK_CONTAINER(window), 3); gtk_window_set_decorated(GTK_WINDOW(window),TRUE); gtk_window_set_default_size(GTK_WINDOW(window),100,100); gtk_widget_set_app_paintable(window,TRUE); /* Get the screen to get the colormap */ screen=gtk_widget_get_screen(window); colormap = gdk_screen_get_rgba_colormap(screen); if(colormap != NULL){ alpha_channel_support=TRUE; } else { alpha_channel_support=FALSE; colormap=gdk_screen_get_rgb_colormap(screen); g_print("Sorry, no alpha!\n"); } /* Tell the window to use the colormap */ gtk_widget_set_colormap(window,colormap); /* Get a pixbuf from the image file */ pixbuf=gdk_pixbuf_new_from_file("clockface.png",&error); if(pixbuf==NULL){ g_print("Failed to open background image: %s\n", error->message); g_error_free(error); error=NULL; return 0; } /* Make it the same size as the window */ scaled=gdk_pixbuf_scale_simple(pixbuf,100,100, GDK_INTERP_BILINEAR); /* Render it using the colormap of the window */ gdk_pixbuf_render_pixmap_and_mask_for_colormap(scaled,colormap,&background,NULL,0); /* Make a new style, stick the background in it, tell window to use it. */ style = gtk_style_new(); style->bg_pixmap[0] = background; gtk_widget_set_style(GTK_WIDGET(window),GTK_STYLE(style)); /*gtk_window_set_opacity(GTK_WINDOW(window),0.3);*/ gtk_window_move(GTK_WINDOW(window), 0, 0); gtk_widget_show_all(window); return 1; }
/* Init function. Here we setup all the gtk stuff */ static GtkWidget *init_fftscope_window() { GtkWidget *fftscope_win; GtkStyle *style; GdkColor color; guint32 colors[129]; int i; pthread_mutex_init(&fftscope_mutex, NULL); style = gtk_style_new(); fftscope_win = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(fftscope_win), "FFTscope"); gtk_widget_set_usize(fftscope_win, 256, SCOPE_HEIGHT); gtk_window_set_wmclass(GTK_WINDOW(fftscope_win), "FFTscope", "AlsaPlayer"); gtk_window_set_policy(GTK_WINDOW(fftscope_win), FALSE, FALSE, FALSE); style = gtk_style_copy(gtk_widget_get_style(GTK_WIDGET(fftscope_win))); color.red = SCOPE_BG_RED << 8; color.blue = SCOPE_BG_BLUE << 8; color.green = SCOPE_BG_GREEN << 8; gdk_color_alloc(gdk_colormap_get_system(), &color); gtk_widget_set_style(GTK_WIDGET(fftscope_win), style); for (i = 0; i < 32; i++) { colors[i * 2] = colors[i * 2 + 1] = ((i * 8) << 16) + (255 << 8); colors[i * 2 + 64] = colors[i * 2 + 65] = (255 << 16) + (((31 - i) * 8) << 8); } colors[128] = 0; color_map = gdk_rgb_cmap_new(colors, 129); area = gtk_drawing_area_new(); gtk_container_add(GTK_CONTAINER(fftscope_win), area); gtk_widget_realize(area); gdk_window_set_background(area->window, &color); gtk_widget_show(area); gtk_widget_show(fftscope_win); /* Signals */ gtk_signal_connect(GTK_OBJECT(fftscope_win), "delete_event", GTK_SIGNAL_FUNC(close_fftscope_window), fftscope_win); /* Clear and show the window */ gdk_window_clear(fftscope_win->window); gdk_flush(); ready_state = 1; return fftscope_win; }
void ascii_open (void) { int do_unref = TRUE; int i, j, val; unsigned char name[2], num[4]; GtkWidget *wid, *but, *hbox, *vbox, *win; GtkStyle *style; style = gtk_style_new (); gdk_font_unref (style->font); if (menu_sess && menu_sess->type == SESS_DIALOG) { style->font = dialog_font_normal; gdk_font_ref (dialog_font_normal); } else { style->font = font_normal; gdk_font_ref (font_normal); } win = maingui_window ("asciichart", _("Ascii Chart"), TRUE, TRUE, NULL, NULL, 0, 0, NULL); vbox = wins_get_vbox (win); name[1] = 0; for (i = 0; i < 16; i++) { hbox = gtk_hbox_new (0, 0); sprintf (num, "%03d", i * 16); wid = gtk_label_new (num); gtk_widget_set_usize (wid, 36, 20); gtk_container_add (GTK_CONTAINER (hbox), wid); gtk_widget_show (wid); for (j = 0; j < 16; j++) { val = j + (i * 16); name[0] = val; but = gtk_button_new_with_label (name); gtk_widget_set_style (GTK_BIN (but)->child, style); if (do_unref) { do_unref = FALSE; gtk_style_unref (style); } gtk_signal_connect (GTK_OBJECT (but), "clicked", GTK_SIGNAL_FUNC (ascii_click), GINT_TO_POINTER (val)); gtk_widget_set_usize (but, 24, 20); gtk_container_add (GTK_CONTAINER (hbox), but); gtk_widget_show (but); } gtk_container_add (GTK_CONTAINER (vbox), hbox); gtk_widget_show (hbox); } gtk_widget_show (win); }
/* called from ui_open_canvas_window */ void ui_init_checkbox_style(void) { ui_style_red = gtk_style_new(); ui_style_red->fg[GTK_STATE_NORMAL] = drive_led_on_red_pixel; ui_style_red->fg[GTK_STATE_ACTIVE] = drive_led_on_red_pixel; ui_style_red->fg[GTK_STATE_SELECTED] = drive_led_on_red_pixel; ui_style_red->fg[GTK_STATE_PRELIGHT] = drive_led_on_red_pixel; gtk_widget_set_style(video_ctrl_checkbox_label, ui_style_red); if (machine_class != VICE_MACHINE_VSID) { gtk_widget_set_style(event_rec_checkbox_label, ui_style_red); ui_style_green = gtk_style_new(); ui_style_green->fg[GTK_STATE_NORMAL] = drive_led_on_green_pixel; ui_style_green->fg[GTK_STATE_ACTIVE] = drive_led_on_green_pixel; ui_style_green->fg[GTK_STATE_SELECTED] = drive_led_on_green_pixel; ui_style_green->fg[GTK_STATE_PRELIGHT] = drive_led_on_green_pixel; gtk_widget_set_style(event_playback_checkbox_label, ui_style_green); } }
void setWindow(GtkWidget *widget,gpointer data ) { GdkPixbuf *LoadImage = NULL; GtkStyle *StyleNew = NULL; GdkPixmap *LoadPixmap = NULL; LoadImage = load_pixbuf_from_file ((gchar*)data); gdk_pixbuf_render_pixmap_and_mask (LoadImage, &LoadPixmap, NULL, 0); StyleNew = gtk_style_new (); StyleNew->bg_pixmap [0] = LoadPixmap; gtk_widget_set_style (GTK_WIDGET(window), GTK_STYLE (StyleNew)); }
GtkStyle * create_inputgad_style (void) { GtkStyle *style; style = gtk_style_new (); gdk_font_unref (style->font); gdk_font_ref (font_normal); style->font = font_normal; style->base[GTK_STATE_NORMAL] = colors[19]; style->bg[GTK_STATE_NORMAL] = colors[19]; style->fg[GTK_STATE_NORMAL] = colors[18]; return style; }
GR_Font * GR_UnixCairoGraphics::getGUIFont(void) { if (!m_pPFontGUI) { // get the font resource #if GTK_CHECK_VERSION(3,0,0) GtkStyleContext *tempCtxt = gtk_style_context_new(); GtkWidgetPath *path = gtk_widget_path_new(); gtk_widget_path_append_type (path, GTK_TYPE_WINDOW); gtk_style_context_set_path(tempCtxt, path); gtk_widget_path_free(path); const char *guiFontName = pango_font_description_get_family(gtk_style_context_get_font(tempCtxt, GTK_STATE_FLAG_NORMAL)); #else GtkStyle *tempStyle = gtk_style_new(); const char *guiFontName = pango_font_description_get_family(tempStyle->font_desc); #endif if (!guiFontName) guiFontName = "'Times New Roman'"; UT_UTF8String s = XAP_EncodingManager::get_instance()->getLanguageISOName(); const char * pCountry = XAP_EncodingManager::get_instance()->getLanguageISOTerritory(); if(pCountry) { s += "-"; s += pCountry; } m_pPFontGUI = new GR_PangoFont(guiFontName, 11.0, this, s.utf8_str(), true); #if GTK_CHECK_VERSION(3,0,0) g_object_unref(G_OBJECT(tempCtxt)); #else g_object_unref(G_OBJECT(tempStyle)); #endif UT_ASSERT(m_pPFontGUI); } return m_pPFontGUI; }
void main_window_show_gui(main_window_t win, gboolean fullscreen) { GtkWidget *frame = gtk_widget_get_parent(win->video); if( frame->style == NULL ) { gtk_widget_set_style( frame, gtk_style_new() ); } if( fullscreen ) { gtk_widget_hide( win->menubar ); gtk_widget_hide( win->toolbar ); gtk_widget_hide( win->statusbar ); frame->style->xthickness = 0; frame->style->ythickness = 0; } else { frame->style->xthickness = 2; frame->style->ythickness = 2; gtk_widget_show( win->menubar ); gtk_widget_show( win->toolbar ); gtk_widget_show( win->statusbar ); } gtk_widget_queue_draw( win->window ); }
void initGui( JunoControl* _junoControl, Settings* _settings, MidiInput* _midiInput, int numVoices) { junoControl = _junoControl; settings = _settings; midiInput = _midiInput; keyboard = new JunoKeyboard(numVoices); mainMenu = gtk_item_factory_new(GTK_TYPE_MENU, "<Main>", NULL); gtk_item_factory_create_items(mainMenu, mainwin_general_menu_entry_count, mainwin_general_menu_entries, NULL); GtkStyle* menuStyle = gtk_style_new(); // a default style gtk_widget_set_style( mainMenu->widget, menuStyle ); GtkWidget* mainContainer; mainWindow = gtk_window_new( GTK_WINDOW_TOPLEVEL ); gtk_widget_add_events( GTK_WIDGET( mainWindow ), GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK ); gtk_window_set_default_size( GTK_WINDOW( mainWindow ), 940, 224 ); gtk_window_set_policy(GTK_WINDOW(mainWindow), FALSE, FALSE, TRUE); gtk_widget_realize( mainWindow ); gdk_window_set_decorations( mainWindow->window, (GdkWMDecoration)0 ); gtk_widget_set_app_paintable(mainWindow, TRUE); gtk_signal_connect(GTK_OBJECT(mainWindow), "button_press_event", GTK_SIGNAL_FUNC(mainWindow_press), NULL); gtk_signal_connect(GTK_OBJECT(mainWindow), "button_release_event", GTK_SIGNAL_FUNC(mainWindow_release), NULL); gtk_signal_connect(GTK_OBJECT(mainWindow), "motion_notify_event", GTK_SIGNAL_FUNC(mainWindow_motion), NULL); gtk_signal_connect(GTK_OBJECT(mainWindow), "enter_notify_event", GTK_SIGNAL_FUNC(mainWindow_enter), NULL); gtk_signal_connect(GTK_OBJECT(mainWindow), "leave_notify_event", GTK_SIGNAL_FUNC(mainWindow_leave), NULL); mainContainer = gtk_fixed_new(); gtk_widget_show( mainWindow ); gtk_widget_show( mainContainer ); GdkPixmap* image = gdk_pixmap_create_from_xpm_d( mainWindow->window, NULL, NULL, juno_background_data ); GtkWidget* pixmap = gtk_pixmap_new( image, NULL ); gtk_widget_show( pixmap ); gtk_fixed_put( GTK_FIXED( mainContainer ), pixmap, 0, 0 ); gtk_container_add( GTK_CONTAINER( mainWindow ), mainContainer ); init(); layout( GTK_FIXED( mainContainer ) ); GdkBitmap* mask = gdk_bitmap_create_from_data( mainWindow->window, juno_background_mask_bits, juno_background_mask_width, juno_background_mask_height ); gtk_widget_shape_combine_mask( mainWindow, mask, 0, 0 ); }
void about_dialog_create() { GtkStyle *style; GtkWidget *vbox; GtkWidget *aboutframe; GtkWidget *label; GtkWidget *alignment; if (!about_dialog) { about_dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_wmclass(GTK_WINDOW(about_dialog), "about_dialog", "Aube"); gtk_window_set_title(GTK_WINDOW(about_dialog), "About AUBE"); gtk_window_set_policy(GTK_WINDOW(about_dialog), FALSE, FALSE, FALSE); gtk_window_position(GTK_WINDOW(about_dialog), GTK_WIN_POS_CENTER); g_signal_connect(G_OBJECT(about_dialog), "destroy", (GtkSignalFunc) about_dialog_destroy, NULL); g_signal_connect(G_OBJECT(about_dialog), "button_press_event", (GtkSignalFunc) about_dialog_button, NULL); gtk_widget_set_events(about_dialog, GDK_BUTTON_PRESS_MASK); if (!about_dialog_load_logo(about_dialog)) { gtk_widget_destroy(about_dialog); about_dialog = NULL; return; } vbox = gtk_vbox_new(FALSE, 1); gtk_container_border_width(GTK_CONTAINER(vbox), 1); gtk_container_add(GTK_CONTAINER(about_dialog), vbox); gtk_widget_show(vbox); aboutframe = gtk_frame_new(NULL); gtk_frame_set_shadow_type(GTK_FRAME(aboutframe), GTK_SHADOW_IN); gtk_container_border_width(GTK_CONTAINER(aboutframe), 0); gtk_box_pack_start(GTK_BOX(vbox), aboutframe, TRUE, TRUE, 0); gtk_widget_show(aboutframe); logo_area = gtk_drawing_area_new(); g_signal_connect(G_OBJECT(logo_area), "expose_event", (GtkSignalFunc) about_dialog_logo_expose, NULL); gtk_drawing_area_size(GTK_DRAWING_AREA(logo_area), logo_width, logo_height); gtk_widget_set_events(logo_area, GDK_EXPOSURE_MASK); gtk_container_add(GTK_CONTAINER(aboutframe), logo_area); gtk_widget_show(logo_area); gtk_widget_realize(logo_area); gdk_window_set_background(logo_area->window, &logo_area->style->black); style = gtk_style_new(); /* FIXME: use pango or remove entirely? gdk_font_unref(style->font); style->font = gdk_font_load("-Adobe-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*"); gtk_widget_push_style(style); */ label = gtk_label_new("This is AUBE Version " VERSION); gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0); gtk_widget_show(label); label = gtk_label_new ("Copyright (c) 1998 - 2002 Conrad Parker, [email protected]"); gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0); gtk_widget_show(label); /* FIXME gtk_widget_pop_style(); */ alignment = gtk_alignment_new(0.5, 0.5, 0.0, 0.0); gtk_box_pack_start(GTK_BOX(vbox), alignment, FALSE, TRUE, 0); gtk_widget_show(alignment); #ifndef HAVE_LIBSNDFILE label = gtk_label_new ("This copy of AUBE was built without sample support\ndue to libsndfile being unavailable on the build host"); gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0); gtk_widget_show(label); alignment = gtk_alignment_new(0.5, 0.5, 0.0, 0.0); gtk_box_pack_start(GTK_BOX(vbox), alignment, FALSE, TRUE, 0); gtk_widget_show(alignment); #endif label = gtk_label_new ("Visit http://www.metadecks.org/software/aube/ for more info"); gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0); gtk_widget_show(label); } if (!GTK_WIDGET_MAPPED(about_dialog)) { gtk_widget_show(about_dialog); } else { gdk_window_raise(about_dialog->window); } }
/* Checks whether there is already a legend entry for each known * protocol. If not, create it */ static void check_new_protocol (GtkWidget *prot_table, const protostack_t *pstk) { const GList *protocol_item; const protocol_t *protocol; GdkColor color; GtkStyle *style; GtkLabel *lab; GtkWidget *newlab; GList *childlist; if (!pstk) return; /* nothing to do */ childlist = gtk_container_get_children(GTK_CONTAINER(prot_table)); protocol_item = pstk->protostack[pref.stack_level]; while (protocol_item) { const GList *cur; protocol = protocol_item->data; /* prepare next */ protocol_item = protocol_item->next; /* First, we check whether the diagram already knows about this protocol, * checking whether it is shown on the legend. */ cur = childlist; while (cur) { lab = GTK_LABEL(cur->data); if (lab && !strcmp(protocol->name, gtk_label_get_label(lab))) break; /* found */ cur = cur->next; } if (cur) continue; /* found, skip to next */ g_my_debug ("Protocol '%s' not found. Creating legend item", protocol->name); /* It's not, so we build a new entry on the legend */ /* we add the new label widgets */ newlab = gtk_label_new (protocol->name); gtk_widget_show (newlab); gtk_misc_set_alignment(GTK_MISC(newlab), 0, 0); color = protohash_color(protocol->name); if (!gdk_colormap_alloc_color (gdk_colormap_get_system(), &color, FALSE, TRUE)) g_warning (_("Unable to allocate color for new protocol %s"), protocol->name); style = gtk_style_new (); style->fg[GTK_STATE_NORMAL] = color; gtk_widget_set_style (newlab, style); g_object_unref (style); gtk_container_add(GTK_CONTAINER(prot_table), newlab); known_protocols++; } g_list_free(childlist); } /* check_new_protocol */
int main (int argc, char **argv) { gtk_init (&argc, &argv); read_config (); // Read options from command-line arguments. GError *error = NULL; GOptionContext *context; context = g_option_context_new (" - show X11 windows as colour mosaic"); g_option_context_add_main_entries (context, entries, NULL); g_option_context_add_group (context, gtk_get_option_group (TRUE)); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_printerr ("option parsing failed: %s\n", error->message); exit (1); } g_option_context_free (context); if(options.format && !options.read_stdin) { g_printerr("You must provide option --read-stdin!"); exit(1); } #ifdef X11 atoms_init (); #endif if (already_opened ()) { g_printerr ("Another instance of xwinmosaic is opened.\n"); exit (1); } if (options.read_stdin) { if(!options.format) { options.show_icons = FALSE; options.show_desktop = FALSE; } read_stdin (); } else { #ifdef X11 // Checks whether WM supports EWMH specifications. if (!wm_supports_ewmh ()) { GtkWidget *dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "Error: your WM does not support EWMH specifications."); gtk_dialog_run (GTK_DIALOG (dialog)); g_signal_connect_swapped (dialog, "response", G_CALLBACK (gtk_main_quit), NULL); return 1; } active_window = (Window *) property (gdk_x11_get_default_root_xwindow (), a_NET_ACTIVE_WINDOW, XA_WINDOW, NULL); #endif } if (options.color_file) read_colors (); #ifdef WIN32 if (options.persistent) { #ifdef DEBUG g_printerr ("Installing Alt-Tab hook"); #endif install_alt_tab_hook(); } #endif window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (window), "XWinMosaic"); GdkRectangle rect = current_monitor_size (); width = rect.width; height = rect.height; if (options.at_pointer) { gdk_display_get_pointer (gdk_display_get_default (), NULL, &options.center_x, &options.center_y, NULL); gint monitors = gdk_screen_get_n_monitors (gdk_screen_get_default ()); if (monitors > 1) { guint xm = 0, ym = 0; gint current_monitor = gdk_screen_get_monitor_at_point (gdk_screen_get_default (), options.center_x, options.center_y); for (int i = 0; i < current_monitor; i++) { GdkRectangle mon_rect; gdk_screen_get_monitor_geometry (gdk_screen_get_default (), i, &mon_rect); xm += mon_rect.width; ym += mon_rect.height; } if (xm && ym) { options.center_x %= xm; options.center_y %= ym; } } if (options.center_x < options.box_width/2) options.center_x = options.box_width/2 + 1; else if (options.center_x > width - options.box_width/2) options.center_x = width - options.box_width/2 - 1; if (options.center_y < options.box_height/2) options.center_y = options.box_height/2 + 1; else if (options.center_y > height - options.box_height/2) options.center_y = height - options.box_height/2 - 1; } else { options.center_x = width/2; options.center_y = height/2; } gtk_window_set_default_size (GTK_WINDOW (window), width, height); gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER); gtk_window_set_decorated (GTK_WINDOW (window), 0); gtk_window_set_type_hint (GTK_WINDOW (window), GDK_WINDOW_TYPE_HINT_DIALOG); gtk_window_set_skip_taskbar_hint (GTK_WINDOW (window), 1); gtk_window_set_skip_pager_hint (GTK_WINDOW (window), 1); /**/ gtk_widget_add_events (GTK_WIDGET (window), GDK_FOCUS_CHANGE); g_signal_connect (G_OBJECT (window), "focus-out-event", G_CALLBACK (on_focus_change), NULL); /**/ layout = gtk_layout_new (NULL, NULL); gtk_container_add (GTK_CONTAINER (window), layout); if (options.screenshot) { gtk_window_fullscreen (GTK_WINDOW (window)); GdkPixbuf *screenshot; GdkPixmap *background = NULL; GtkStyle *style = NULL; screenshot = get_screenshot (); gdk_pixbuf_render_pixmap_and_mask (screenshot, &background, NULL, 0); style = gtk_style_new (); style->bg_pixmap [0] = background; gtk_widget_set_style (window, style); gtk_widget_set_style (layout, style); } search = mosaic_search_box_new (); mosaic_box_set_font (MOSAIC_BOX (search), options.font); gtk_widget_set_can_focus (search, FALSE); GtkRequisition s_req; gtk_widget_size_request (search, &s_req); gtk_layout_put (GTK_LAYOUT (layout), search, (width - s_req.width)/2, height - s_req.height - options.box_height); g_signal_connect (G_OBJECT (search), "changed", G_CALLBACK (refilter), NULL); g_signal_connect (G_OBJECT (window), "key-press-event", G_CALLBACK (on_key_press), NULL); g_signal_connect_swapped(G_OBJECT (window), "destroy", G_CALLBACK(gtk_main_quit), NULL); if (!options.screenshot) { window_shape_bitmap = (GdkDrawable *) gdk_pixmap_new (NULL, width, height, 1); draw_mask (window_shape_bitmap, 0); gtk_widget_shape_combine_mask (window, window_shape_bitmap, 0, 0); } gtk_widget_show_all (window); gtk_widget_hide (search); gtk_window_present (GTK_WINDOW (window)); gtk_window_set_keep_above (GTK_WINDOW (window), TRUE); if (options.persistent) gtk_widget_hide (window); GdkWindow *gdk_window = gtk_widget_get_window (GTK_WIDGET (window)); #ifdef X11 myown_window = GDK_WINDOW_XID (gdk_window); if (!options.read_stdin) { // Get PropertyNotify events from root window. XSelectInput (gdk_x11_get_default_xdisplay (), gdk_x11_get_default_root_xwindow (), PropertyChangeMask); gdk_window_add_filter (NULL, (GdkFilterFunc) event_filter, NULL); } #endif #ifdef WIN32 myown_window = GDK_WINDOW_HWND (gdk_window); #endif update_box_list (); draw_mosaic (GTK_LAYOUT (layout), boxes, wsize, 0, options.box_width, options.box_height); #ifdef X11 // Window will be shown on all desktops (and so hidden in windows list) unsigned int desk = 0xFFFFFFFF; // -1 XChangeProperty(gdk_x11_get_default_xdisplay (), myown_window, a_NET_WM_DESKTOP, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&desk, 1); #endif gtk_main (); #ifdef X11 if (!options.read_stdin) XFree (wins); #endif return 0; }
MedSLTPatWindow::MedSLTPatWindow(MedSLTPatWindowObserver& observer) : m_observer(observer), m_list_index(0), m_list_items(0), m_is_fullscreen(FALSE), m_back_translation(""), m_ui_state(UI_STATE_DISCONNECTED) { ACE_TRACE("[MedSLTPatWindow::MedSLTPatWindow()]"); GtkBox* hbox; GtkBox* coverbox; GtkBox* textbox; GtkBox* buthbox; GtkWidget* menu; GtkWidget* appimage; GtkWidget* scroll1; GtkWidget* scroll2; GtkWidget* scroll3; PangoFontDescription* font1; PangoFontDescription* font2; GtkStyle* style; GtkAccelGroup* accel = gtk_accel_group_new(); // Window #ifdef _MAEMO m_window = GTK_WINDOW(hildon_window_new()); #else m_window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); gtk_window_set_default_size(m_window, 450, -1); #endif gtk_window_add_accel_group(m_window, accel); gtk_window_set_icon_from_file(m_window, app_icon, NULL); gtk_container_set_border_width(GTK_CONTAINER(m_window), 5); // Boxes coverbox = GTK_BOX(gtk_vbox_new(False, 5)); hbox = GTK_BOX(gtk_hbox_new(False, 5)); textbox = GTK_BOX(gtk_vbox_new(False, 5)); buthbox = GTK_BOX(gtk_vbox_new(False, 5)); // Image appimage = gtk_image_new_from_file(app_icon_big); // Fonts font1 = pango_font_description_from_string("Monospace Bold 20"); font2 = pango_font_description_from_string("Monospace Bold 16"); // Styles style = gtk_style_new(); style->font_desc = font1; gdk_color_parse ("red", &(style->fg[GTK_STATE_NORMAL])); // Lists m_list = gtk_clist_new(1); gtk_widget_set_size_request(GTK_WIDGET(m_list), 550, 130); gtk_widget_modify_font(m_list, font1); /*gchar* text[3][1] = { {"où avez vous mal?"}, {"avez vous mal sous le devant de la tête?"}, {"la douleur survient elle le matin?"}}; */ gchar* text[3][1] = { {"sí mucho"}, {"no sé"}, {"la cabeza"}}; gtk_clist_append((GtkCList*)m_list, text[0]); gtk_clist_append((GtkCList*)m_list, text[1]); gtk_clist_append((GtkCList*)m_list, text[2]); m_list_items = 3; gtk_clist_select_row((GtkCList*)m_list, 0, 0); // Text Boxes m_txtbox1 = gtk_text_view_new(); gtk_widget_modify_font(m_txtbox1, font1); gtk_widget_set_size_request(GTK_WIDGET(m_txtbox1), 550, 50); gtk_text_view_set_editable(GTK_TEXT_VIEW(m_txtbox1), false); gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(m_txtbox1), GTK_WRAP_WORD_CHAR); gtk_widget_set_style (m_txtbox1, style); m_txtbox2 = gtk_text_view_new(); gtk_widget_modify_font(m_txtbox2, font1); gtk_widget_set_size_request(GTK_WIDGET(m_txtbox2), 550, 50); gtk_text_view_set_editable(GTK_TEXT_VIEW(m_txtbox2), false); gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(m_txtbox2), GTK_WRAP_WORD_CHAR); // Scroll bars scroll1 = gtk_scrolled_window_new(NULL, NULL); scroll2 = gtk_scrolled_window_new(NULL, NULL); scroll3 = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll1), GTK_POLICY_ALWAYS, GTK_POLICY_ALWAYS); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll2), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll3), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scroll1), GTK_SHADOW_IN); gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scroll2), GTK_SHADOW_IN); gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scroll3), GTK_SHADOW_IN); gtk_container_add(GTK_CONTAINER(scroll1), GTK_WIDGET(m_list)); gtk_container_add(GTK_CONTAINER(scroll2), GTK_WIDGET(m_txtbox1)); gtk_container_add(GTK_CONTAINER(scroll3), GTK_WIDGET(m_txtbox2)); // Text labels m_understood = gtk_label_new("Understood"); m_question = gtk_label_new("Question"); m_translation = gtk_label_new("Translation"); gtk_widget_modify_font(m_understood, font2); gtk_widget_modify_font(m_question, font2); gtk_widget_modify_font(m_translation, font2); gtk_label_set_justify(GTK_LABEL(m_understood), GTK_JUSTIFY_LEFT); gtk_label_set_justify(GTK_LABEL(m_question), GTK_JUSTIFY_LEFT); gtk_label_set_justify(GTK_LABEL(m_translation), GTK_JUSTIFY_LEFT); gtk_label_set_ellipsize(GTK_LABEL(m_understood), PANGO_ELLIPSIZE_END); gtk_label_set_ellipsize(GTK_LABEL(m_question), PANGO_ELLIPSIZE_END); gtk_label_set_ellipsize(GTK_LABEL(m_translation), PANGO_ELLIPSIZE_END); // Buttons m_rec = gtk_button_new(); m_speech = gtk_button_new(); m_abort = gtk_button_new(); m_up = gtk_button_new(); m_select = gtk_button_new(); m_down = gtk_button_new(); gtk_button_set_image(GTK_BUTTON(m_rec), gtk_image_new_from_file(record_icon)); gtk_button_set_image(GTK_BUTTON(m_speech), gtk_image_new_from_file(speech_icon)); gtk_button_set_image(GTK_BUTTON(m_abort), gtk_image_new_from_file(stop_icon)); gtk_button_set_image(GTK_BUTTON(m_up), gtk_image_new_from_file(up_icon)); gtk_button_set_image(GTK_BUTTON(m_select), gtk_image_new_from_file(select_icon)); gtk_button_set_image(GTK_BUTTON(m_down), gtk_image_new_from_file(down_icon)); // Menu // Recheck: Is it destroyed somewhere menu = CreateMenu(accel); // Progress bar m_progressbar = gtk_progress_bar_new(); gtk_progress_set_text_alignment(GTK_PROGRESS(m_progressbar), 0.5, 0.5); gtk_widget_set_size_request(GTK_WIDGET(m_progressbar), 150, 50); //gtk_container_add(GTK_CONTAINER(m_window), GTK_WIDGET(vbox)); gtk_box_pack_start(textbox, m_understood, TRUE, TRUE, 0); gtk_box_pack_start(textbox, scroll1, TRUE, TRUE, 0); gtk_box_pack_start(textbox, m_question, TRUE, TRUE, 0); gtk_box_pack_start(textbox, scroll2, TRUE, TRUE, 0); gtk_box_pack_start(textbox, m_translation, TRUE, TRUE, 0); gtk_box_pack_start(textbox, scroll3, TRUE, TRUE, 0); //gtk_box_pack_start(buthbox, appimage, TRUE, TRUE, 0); gtk_box_pack_start(buthbox, m_rec, TRUE, TRUE, 0); gtk_box_pack_start(buthbox, m_speech, TRUE, TRUE, 0); gtk_box_pack_start(buthbox, m_abort, TRUE, TRUE, 0); gtk_box_pack_start(buthbox, m_up, TRUE, TRUE, 0); gtk_box_pack_start(buthbox, m_select, TRUE, TRUE, 0); gtk_box_pack_start(buthbox, m_down, TRUE, TRUE, 0); gtk_box_pack_start(hbox, GTK_WIDGET(textbox), TRUE, TRUE, 0); gtk_box_pack_start(hbox, GTK_WIDGET(buthbox), TRUE, TRUE, 0); gtk_box_pack_start(coverbox, GTK_WIDGET(hbox), TRUE, TRUE, 0); gtk_box_pack_start(coverbox, m_progressbar, TRUE, TRUE, 0); gtk_container_add(GTK_CONTAINER(m_window), GTK_WIDGET(coverbox)); #ifdef _MAEMO hildon_window_set_menu(HILDON_WINDOW(m_window), GTK_MENU(menu)); #else gtk_box_pack_start(vbox, menu, FALSE, FALSE, 0); #endif // Signals g_signal_connect(G_OBJECT(m_rec), "clicked", G_CALLBACK(RecognizeClicked), this); g_signal_connect(G_OBJECT(m_speech), "clicked", G_CALLBACK(AbortClicked), this); g_signal_connect(G_OBJECT(m_abort), "clicked", G_CALLBACK(AbortClicked), this); g_signal_connect(G_OBJECT(m_up), "clicked", G_CALLBACK(UpClicked), this); g_signal_connect(G_OBJECT(m_select), "clicked", G_CALLBACK(SelectClicked), this); g_signal_connect(G_OBJECT(m_down), "clicked", G_CALLBACK(DownClicked), this); g_signal_connect(G_OBJECT(m_list), "select_row", G_CALLBACK(ListRowSelected), this); g_signal_connect(G_OBJECT(m_window), "destroy", G_CALLBACK(CloseApp), this); g_signal_connect(G_OBJECT(m_window), "delete_event", G_CALLBACK(CloseApp), this); // Shortcuts #ifndef _MAEMO gtk_widget_add_accelerator(m_rec, "clicked", accel, GDK_space, 0, 0); gtk_widget_add_accelerator(m_speech, "clicked", accel, GDK_space, 0, 0); gtk_widget_add_accelerator(m_abort, "clicked", accel, GDK_space, 0, 0); gtk_widget_add_accelerator(m_next, "clicked", accel, GDK_Right, GDK_CONTROL_MASK, 0); #endif // Initial state SetUiState(UI_STATE_DISCONNECTED); return; }
#include <Gtk/Gtk/Style.h> TYPE(T, Gtk$GObject$Object$T); GLOBAL_FUNCTION(New, 0) { GtkWidget *Handle = gtk_style_new(); Result->Val = Gtk$GObject$Object$new(Handle, T); return SUCCESS; };
GtkWidget * create_term_menu(ZvtTerm *term, gchar *command) { GtkWidget *menu_bar; GtkWidget *menu; GtkWidget *menu_item; GtkWidget *vide_menu; GtkWidget *tools_menu; GtkWidget *term_label; GdkColor color = TAB_COLOR; GtkStyle *defstyle; GtkStyle *style = gtk_style_new(); menu_bar = gtk_menu_bar_new(); defstyle = gtk_widget_get_default_style(); style = gtk_style_copy(defstyle); style->fg[0] = color; menu = gtk_menu_new(); gtk_signal_connect(GTK_OBJECT(menu), "key_press_event", GTK_SIGNAL_FUNC(menu_key_cb), NULL); gtk_object_set_data(GTK_OBJECT(term), "menu_bar", menu_bar); /* The terminal is running vi */ if(GPOINTER_TO_INT(gtk_object_get_user_data(GTK_OBJECT(term)))) { add_menu_item(menu, "Open File in Buffer", create_fileselector, GUINT_TO_POINTER(0)); if(strcmp(cfg.vi_clone, "vi")) add_menu_item (menu, "Split Buffer & Open File", create_fileselector, GUINT_TO_POINTER(1)); if(!strcmp(cfg.vi_clone, "vim")) add_menu_item (menu, "VSplit Buffer & Open File", create_fileselector, GUINT_TO_POINTER(2)); add_menu_separator (menu); } add_menu_item(menu, "Open File in New Term", create_fileselector, GUINT_TO_POINTER(3)); add_menu_separator (menu); add_menu_item(menu, "New Shell", split_zterm, NULL); add_menu_separator(menu); add_menu_item(menu, "List Pages", create_page_menu, NULL); add_menu_separator(menu); add_menu_item(menu, "Detach Term", detach_term, term); add_menu_separator(menu); add_menu_item (menu, "Cancel", NULL, NULL); vide_menu = add_submenu (menu_bar, "_Vide", menu); gtk_object_set_data(GTK_OBJECT(term), "vide_menu", vide_menu); menu = gtk_menu_new(); gtk_signal_connect(GTK_OBJECT(menu), "key_press_event", GTK_SIGNAL_FUNC(menu_key_cb), NULL); add_menu_item(menu, "Look up word", lookup_word, term); add_menu_separator(menu); /* add_menu_item(menu, "Compare file to..", compare_file, term); add_menu_separator(menu); */ /* I don't know how to visually select text in nvi and vile if((!strcmp("vim", cfg.vi_clone) | (!strcmp("elvis", cfg.vi_clone)))) { add_menu_item(menu, "Copy", copy_text, term); add_menu_separator(menu); add_menu_item(menu, "Paste", paste_text, term); add_menu_separator(menu); } */ add_menu_item(menu, "Cancel", NULL, NULL); tools_menu = add_submenu(menu_bar, "_Tools", menu); gtk_object_set_data(GTK_OBJECT(term), "tools_menu", tools_menu); /* label for filename on menubar */ menu = gtk_menu_new(); menu_item = gtk_menu_item_new(); term_label = gtk_widget_new(GTK_TYPE_LABEL, "GtkWidget::visible", TRUE, "GtkWidget::parent", menu_item, "GtkMisc::xalign", 0, 0, NULL); gtk_label_set_text(GTK_LABEL(term_label), command); gtk_widget_set_style(GTK_WIDGET(term_label), style); gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), menu); gtk_menu_bar_append(GTK_MENU_BAR(menu_bar), menu_item); gtk_menu_item_right_justify(GTK_MENU_ITEM(menu_item)); gtk_widget_show(menu_item); gtk_object_set_data(GTK_OBJECT(term), "term_label", term_label); return menu_bar; }
static VALUE style_initialize(VALUE self) { G_INITIALIZE(self, gtk_style_new()); return Qnil; }
int main(int argc, char *argv[]) { GtkWidget *box, *button, *poz, *reg_b, *frame; GtkStyle *style; GdkPixmap *bg; char buffer[buffsize]; if (WSAStartup(MAKEWORD(2, 0), &wsaData) != 0) { fprintf(stderr, "WSAStartup() failed"); exit(1); } if ((sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) puts("socket() failed"); memset(&server, 0, sizeof(server)); /* Zero out structure */ server.sin_family = AF_INET; /* Internet address family */ server.sin_addr.s_addr = inet_addr("127.0.0.1"); /* Server IP address */ server.sin_port = htons(21); /* Server port */ if (connect(sock, (struct sockaddr *) &server, sizeof(server)) < 0) /* Establish the connection to the server */ puts("connect() failed"); gtk_init(&argc, &argv); //start GTK+ pixbuf = gdk_pixbuf_new_from_file_utf8("bgm.jpg", error); //read background gdk_pixbuf_render_pixmap_and_mask(pixbuf, &bg, NULL, 0); style = gtk_style_new(); style->bg_pixmap[0] = bg; window = gtk_window_new(GTK_WINDOW_TOPLEVEL); //create window //gtk_window_set_default_size(GTK_WINDOW(window), 1280, 720); pixbuf = gdk_pixbuf_new_from_file_utf8("logo.gif", error); //read logo gtk_window_set_icon(GTK_WINDOW (window), pixbuf); //set logo gtk_container_set_border_width(GTK_CONTAINER (window), 10); //create close window event g_signal_connect(window, "delete-event", G_CALLBACK (delete_event), NULL); gtk_widget_set_style(GTK_WIDGET(window), GTK_STYLE(style)); //set background box = gtk_vbox_new(FALSE, 0); //the mess of positioning poz = gtk_hbox_new(FALSE, 0); logbox = gtk_vbox_new(FALSE, 0); gamebox = gtk_vbox_new(FALSE, 0); //positioning ends here //Setting up used Widgets -> buttons, input fields, ... //image = gtk_image_new_from_file_utf8("maemo.png"); pixbuf = gdk_pixbuf_new_from_file_at_scale_utf8("pic/0.jpg", 500, 500, TRUE, //read shown image error); image = gtk_image_new_from_pixbuf(pixbuf); //set image frame = gtk_frame_new(NULL); gtk_frame_set_shadow_type((GtkFrame *) frame, GTK_SHADOW_ETCHED_IN); gtk_container_add(GTK_CONTAINER (frame), image); gtk_container_add(GTK_CONTAINER (poz), frame); gtk_widget_show(frame); gtk_box_pack_start(GTK_BOX (poz), box, FALSE, FALSE, 10); //a bit of positioning gtk_box_pack_start(GTK_BOX (box), logbox, FALSE, FALSE, 10); gtk_box_pack_start(GTK_BOX (box), gamebox, FALSE, FALSE, 10); //end logname = gtk_entry_new(); gtk_box_pack_start(GTK_BOX (logbox), logname, FALSE, FALSE, 10); gtk_widget_show(logname); pass = gtk_entry_new(); gtk_box_pack_start(GTK_BOX (logbox), pass, FALSE, FALSE, 10); gtk_widget_show(pass); button = gtk_button_new_with_label("login"); g_signal_connect(button, "clicked", G_CALLBACK (login), (gpointer) NULL); gtk_box_pack_start(GTK_BOX (logbox), button, FALSE, FALSE, 10); gtk_widget_show(button); reg_b = gtk_button_new_with_label("Register"); g_signal_connect(reg_b, "clicked", G_CALLBACK (reg), (gpointer) "NULL"); gtk_box_pack_start(GTK_BOX (logbox), reg_b, FALSE, FALSE, 10); gtk_widget_show(reg_b); cbutton = gtk_button_new_with_label(buffer); g_signal_connect(cbutton, "clicked", G_CALLBACK (lan), (gpointer) buffer); gtk_box_pack_start(GTK_BOX (gamebox), cbutton, FALSE, FALSE, 10); button = gtk_button_new_with_label("picture"); g_signal_connect(button, "clicked", G_CALLBACK (set_image), "pic"); gtk_box_pack_start(GTK_BOX (gamebox), button, FALSE, FALSE, 10); stats = make_stats(); gtk_box_pack_start(GTK_BOX (gamebox), stats, FALSE, FALSE, 10); status = gtk_toggle_button_new_with_label("connected"); gtk_toggle_button_set_active((GtkToggleButton *) status, TRUE); g_signal_connect(status, "toggled", G_CALLBACK (clcon), (gpointer) NULL); gtk_box_pack_start(GTK_BOX (box), status, FALSE, FALSE, 10); gtk_container_add(GTK_CONTAINER (window), poz); //showing the parts of the window gtk_widget_show(status); gtk_widget_show(image); gtk_widget_show(logbox); gtk_widget_show(poz); gtk_widget_show(box); gtk_widget_show(window); gtk_main(); return EXIT_SUCCESS; }
static gboolean gtk_dial_expose( GtkWidget *widget, GdkEventExpose *event ) { GtkDial *dial; GdkPoint points[6]; gdouble s,c; gdouble theta, last, increment; GtkStyle *blankstyle; gint xc, yc; gint upper, lower; gint tick_length; gint i, inc; g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (GTK_IS_DIAL (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE); if (event->count > 0) return FALSE; dial = GTK_DIAL (widget); /* gdk_window_clear_area (widget->window, 0, 0, widget->allocation.width, widget->allocation.height); */ xc = widget->allocation.width / 2; yc = widget->allocation.height / 2; upper = (int) dial->adjustment->upper; lower = (int) dial->adjustment->lower; /* Erase old pointer */ s = sin (dial->last_angle); c = cos (dial->last_angle); dial->last_angle = dial->angle; points[0].x = (int) ( xc + s*dial->pointer_width/2 ); points[0].y = (int) ( yc + c*dial->pointer_width/2 ); points[1].x = (int) ( xc + c*dial->radius ); points[1].y = (int) ( yc - s*dial->radius ); points[2].x = (int) ( xc - s*dial->pointer_width/2 ); points[2].y = (int) ( yc - c*dial->pointer_width/2 ); points[3].x = (int) ( xc - c*dial->radius/10 ); points[3].y = (int) ( yc + s*dial->radius/10 ); points[4].x = (int) ( points[0].x ); points[4].y = (int) ( points[0].y ); blankstyle = gtk_style_new (); blankstyle->bg_gc[GTK_STATE_NORMAL] = widget->style->bg_gc[GTK_STATE_NORMAL]; blankstyle->dark_gc[GTK_STATE_NORMAL] = widget->style->bg_gc[GTK_STATE_NORMAL]; blankstyle->light_gc[GTK_STATE_NORMAL] = widget->style->bg_gc[GTK_STATE_NORMAL]; blankstyle->black_gc = widget->style->bg_gc[GTK_STATE_NORMAL]; gtk_paint_polygon (blankstyle, widget->window, GTK_STATE_NORMAL, GTK_SHADOW_OUT, NULL, widget, NULL, points, 5, FALSE); g_object_unref (blankstyle); /* Draw ticks */ if ((upper - lower) == 0) return FALSE; increment = ( (100*M_PI) / (dial->radius*dial->radius) ); inc = (int) ( (upper - lower) ); while (inc < 100) inc *= 10; while (inc >= 1000) inc /= 10; last = (int) ( -1 ); for (i = (int) ( 0 ); i <= inc; i++) { theta = (int) ( ((gfloat)i*M_PI / (18*inc/24.) - M_PI/6.) ); if ((theta - last) < (increment)) continue; last = (int) ( theta ); s = (int) ( sin (theta) ); c = (int) ( cos (theta) ); tick_length = (int) ( (i%(inc/10) == 0) ? dial->pointer_width : dial->pointer_width / 2 ); gdk_draw_line( widget->window, widget->style->fg_gc[widget->state], (int) (xc + c*(dial->radius - tick_length)), (int) (yc - s*(dial->radius - tick_length)), (int) (xc + c*dial->radius), (int) (yc - s*dial->radius) ); } /* Draw pointer */ s = ( sin (dial->angle) ); c = ( cos (dial->angle) ); dial->last_angle = ( dial->angle ); points[0].x = (int) ( xc + s*dial->pointer_width/2 ); points[0].y = (int) ( yc + c*dial->pointer_width/2 ); points[1].x = (int) ( xc + c*dial->radius ); points[1].y = (int) ( yc - s*dial->radius ); points[2].x = (int) ( xc - s*dial->pointer_width/2 ); points[2].y = (int) ( yc - c*dial->pointer_width/2 ); points[3].x = (int) ( xc - c*dial->radius/10 ); points[3].y = (int) ( yc + s*dial->radius/10 ); points[4].x = (int) ( points[0].x ); points[4].y = (int) ( points[0].y ); gtk_paint_polygon ( widget->style, widget->window, GTK_STATE_NORMAL, GTK_SHADOW_OUT, NULL, widget, NULL, points, 5, TRUE ); return FALSE; }
void menu_about (GtkWidget * wid, gpointer sess) { GtkWidget *vbox, *label, *hbox; GtkStyle *about_style; GtkStyle *head_style; char buf[512]; if (about) { gdk_window_show (about->window); return; } head_style = gtk_style_new (); #ifndef WIN32 gdk_font_unref (head_style->font); head_style->font = gdk_font_load ("-*-times-bold-i-*-*-*-240-*"); if (!head_style->font) head_style->font = gdk_font_load ("fixed"); #endif head_style->fg[GTK_STATE_NORMAL] = colors[2]; about_style = gtk_style_new (); gdk_font_unref (about_style->font); about_style->font = gdk_font_load ("fixed"); about = gtk_window_new (GTK_WINDOW_DIALOG); gtk_window_position (GTK_WINDOW (about), GTK_WIN_POS_CENTER); gtk_window_set_title (GTK_WINDOW (about), _("About X-Chat")); gtk_container_set_border_width (GTK_CONTAINER (about), 6); gtk_signal_connect (GTK_OBJECT (about), "destroy", GTK_SIGNAL_FUNC (about_close), 0); gtk_widget_realize (about); vbox = gtk_vbox_new (0, 2); gtk_container_add (GTK_CONTAINER (about), vbox); /*gtk_widget_show (vbox);*/ label = gtk_entry_new (); gtk_entry_set_editable (GTK_ENTRY (label), FALSE); gtk_entry_set_text (GTK_ENTRY (label), "X-Chat " VERSION); gtk_widget_set_style (label, head_style); gtk_style_unref (head_style); gtk_container_add (GTK_CONTAINER (vbox), label); snprintf (buf, sizeof (buf), _("(C) 1998-2001 Peter Zelezny <*****@*****.**>\n\n" "An IRC Client for UNIX.\n\n" "This binary was compiled on "__DATE__"\n" "Using GTK %d.%d.%d X %d\n" "Running on %s\n"), gtk_major_version, gtk_minor_version, gtk_micro_version, #ifdef USE_XLIB VendorRelease (GDK_DISPLAY ()), get_cpu_str()); #else 666, get_cpu_str()); #endif label = gtk_label_new (buf); gtk_container_add (GTK_CONTAINER (vbox), label); gtk_widget_set_style (label, about_style); gtk_style_unref (about_style); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); wid = gtk_hseparator_new (); gtk_container_add (GTK_CONTAINER (vbox), wid); hbox = gtk_hbox_new (0, 2); gtk_container_add (GTK_CONTAINER (vbox), hbox); wid = gtk_button_new_with_label (" Continue "); gtk_container_set_border_width (GTK_CONTAINER (hbox), 2); GTK_WIDGET_SET_FLAGS (GTK_WIDGET (wid), GTK_CAN_DEFAULT); gtk_box_pack_end (GTK_BOX (hbox), wid, 0, 0, 0); gtk_widget_grab_default (wid); gtk_signal_connect (GTK_OBJECT (wid), "clicked", GTK_SIGNAL_FUNC (gtkutil_destroy), about); gtk_widget_show_all (about); }