static void menubar_help_cb(GtkWidget * widget, gpointer data) { GtkWidget *dialog; GtkWidget *button; (void)widget; (void)data; dialog = gtk_message_dialog_new(GTK_WINDOW(app), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE, _("A comprehensive PDF user manual and \n" "video tutorials are available from the \n" "Gpredict website:")); button = gtk_link_button_new("http://gpredict.oz9aec.net/documents.php"); gtk_widget_show(button); gtk_box_pack_start(GTK_BOX (gtk_dialog_get_content_area(GTK_DIALOG(dialog))), button, FALSE, FALSE, 0); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); }
/* ,---config_box---------------------. | | |,-permission_box----------------. | || ,-buttons_box--. | | || |button | perm_status | | || |revoke_button | | | || `--------------' | | |`-------------------------------' | | | |,-details_box------------------. | ||details_label_first | | ||url_button | | ||details_label_second | | |`------------------------------' | | | |,-additional_details_box--------. | ||_______________________________| | |__________________________________| */ static void *config_status_checker () { GtkWidget *config_box; GtkWidget *permission_box; GtkWidget *buttons_box; GtkWidget *details_box; GtkWidget *additional_details_box; config_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 15); permission_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); buttons_box = gtk_button_box_new(GTK_ORIENTATION_VERTICAL); details_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); additional_details_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 7); button = gtk_button_new_with_mnemonic(_("C_heck Permission")); revoke_button = gtk_button_new_with_mnemonic(_("_Revoke Permission")); gtk_widget_set_sensitive(revoke_button, FALSE); permission_status_icon = gtk_image_new(); permission_status_label = gtk_label_new(""); details_label_first = gtk_label_new (""); url_button = gtk_link_button_new(""); details_label_second = gtk_label_new(""); gtk_widget_set_halign(details_label_first, GTK_ALIGN_CENTER); gtk_widget_set_halign(url_button, GTK_ALIGN_CENTER); gtk_widget_set_halign(details_label_second, GTK_ALIGN_CENTER); // gtk_label_set_use_markup(GTK_LABEL(details_label), TRUE); additional_details_icon = gtk_image_new(); additional_details_label = gtk_label_new(""); g_signal_connect (button, "clicked", G_CALLBACK (permission_checker), NULL); g_signal_connect (revoke_button, "clicked", G_CALLBACK (revoke_permissions), NULL); gtk_box_pack_start(GTK_BOX(permission_box), buttons_box, FALSE, FALSE, 20); gtk_box_pack_start(GTK_BOX(permission_box), permission_status_icon, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(permission_box), permission_status_label, FALSE, FALSE, 5); gtk_box_pack_start(GTK_BOX(buttons_box), button, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(buttons_box), revoke_button, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(details_box), details_label_first, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(details_box), url_button, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(details_box), details_label_second, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(additional_details_box), additional_details_icon, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(additional_details_box), additional_details_label, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(config_box), permission_box, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(config_box), details_box, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(config_box), additional_details_box, FALSE, FALSE, 0); return config_box; }
bool wxHyperlinkCtrl::Create(wxWindow *parent, wxWindowID id, const wxString& label, const wxString& url, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { if ( UseNative() ) { // do validation checks: CheckParams(label, url, style); if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) { wxFAIL_MSG( wxT("wxHyperlinkCtrl creation failed") ); return false; } m_widget = gtk_link_button_new("asdfsaf asdfdsaf asdfdsa"); g_object_ref(m_widget); gtk_widget_show(m_widget); // alignment float x_alignment = 0.5; if (HasFlag(wxHL_ALIGN_LEFT)) x_alignment = 0.0; else if (HasFlag(wxHL_ALIGN_RIGHT)) x_alignment = 1.0; gtk_button_set_alignment(GTK_BUTTON(m_widget), x_alignment, 0.5); // set to non empty strings both the url and the label SetURL(url.empty() ? label : url); SetLabel(label.empty() ? url : label); // our signal handlers: g_signal_connect_after (m_widget, "clicked", G_CALLBACK (gtk_hyperlink_clicked_callback), this); m_parent->DoAddChild( this ); PostCreation(size); SetInitialSize(size); // wxWindowGTK will connect to the enter_notify and leave_notify GTK+ signals // thus overriding GTK+'s internal signal handlers which set the cursor of // the widget - thus we need to manually set it here: SetCursor(wxCursor(wxCURSOR_HAND)); } else return wxGenericHyperlinkCtrl::Create(parent, id, label, url, pos, size, style, name); return true; }
/* {{{ append_sprite_uris(…) - append a list of URIs to a sprite */ static Sprite *append_sprite_uris(Sprite *s, gchar **uris) { debug(">>> append_sprite_uris()"); GtkWidget *w; for (; uris[0] != NULL; uris += 1) { w = gtk_link_button_new(*uris); if (w == NULL) { warn("append_sprite_uris(): gtk_link_button_new()"); } else { append_sprite_widget(s, w); } } debug("<<< append_sprite_uris()"); return s; }
static VALUE rg_initialize(int argc, VALUE *argv, VALUE self) { VALUE uri, label; GtkWidget *widget = NULL; rb_scan_args(argc, argv, "11", &uri, &label); if (NIL_P(label)){ widget = gtk_link_button_new(RVAL2CSTR(uri)); } else { widget = gtk_link_button_new_with_label(RVAL2CSTR(uri), RVAL2CSTR(label)); } RBGTK_INITIALIZE(self, widget); return Qnil; }
AboutDialog::AboutDialog(GladeSearchpath * gladeSearchPath) : GladeGui(gladeSearchPath, "about.glade", "aboutDialog") { XOJ_INIT_TYPE(AboutDialog); GtkLabel * labelTitle = GTK_LABEL(get("labelTitle")); gtk_label_set_markup(labelTitle, "<span size=\"xx-large\" weight=\"bold\">Xournal++ " VERSION "</span>\n<i>The next generation</i>"); GtkWidget * w = get("vbox1"); GtkWidget * linkButton = gtk_link_button_new("http://xournal.sourceforge.net/"); gtk_widget_show(linkButton); gtk_box_pack_start_defaults(GTK_BOX(w), linkButton); String authors = ""; // Authors of the application AUTOHOR("Denis Auroux, 2006 - 2010"); AUTOHOR("Andreas Butti, 2010 - 2011"); w = get("lbAuthors"); gtk_label_set_text(GTK_LABEL(w), authors.c_str()); }
wxColour wxSystemSettingsNative::GetColour(wxSystemColour index) { GdkRGBA gdkRGBA = { 0, 0, 0, 1 }; switch (index) { case wxSYS_COLOUR_3DLIGHT: case wxSYS_COLOUR_ACTIVEBORDER: case wxSYS_COLOUR_BTNFACE: case wxSYS_COLOUR_DESKTOP: case wxSYS_COLOUR_INACTIVEBORDER: case wxSYS_COLOUR_INACTIVECAPTION: case wxSYS_COLOUR_SCROLLBAR: case wxSYS_COLOUR_WINDOWFRAME: bg(ButtonWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA); break; case wxSYS_COLOUR_BTNHIGHLIGHT: case wxSYS_COLOUR_HIGHLIGHT: bg(ButtonWidget(), GTK_STATE_FLAG_SELECTED, gdkRGBA); break; case wxSYS_COLOUR_BTNSHADOW: border(ButtonWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA); break; case wxSYS_COLOUR_BTNTEXT: case wxSYS_COLOUR_WINDOWTEXT: fg(ButtonWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA); break; case wxSYS_COLOUR_GRAYTEXT: case wxSYS_COLOUR_INACTIVECAPTIONTEXT: fg(ButtonWidget(), GTK_STATE_FLAG_INSENSITIVE, gdkRGBA); break; case wxSYS_COLOUR_HIGHLIGHTTEXT: fg(ButtonWidget(), GTK_STATE_FLAG_SELECTED, gdkRGBA); break; case wxSYS_COLOUR_HOTLIGHT: { static GtkWidget* s_widget; if (s_widget == NULL) { s_widget = gtk_link_button_new(""); gtk_container_add(ContainerWidget(), s_widget); } fg(s_widget, GTK_STATE_FLAG_NORMAL, gdkRGBA); } break; case wxSYS_COLOUR_INFOBK: bg(ToolTipWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA); break; case wxSYS_COLOUR_INFOTEXT: fg(ToolTipWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA); break; case wxSYS_COLOUR_LISTBOX: bg(ListWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA); break; case wxSYS_COLOUR_LISTBOXHIGHLIGHTTEXT: fg(ListWidget(), GTK_STATE_FLAG_SELECTED, gdkRGBA); break; case wxSYS_COLOUR_LISTBOXTEXT: fg(ListWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA); break; case wxSYS_COLOUR_MENU: bg(MenuItemWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA); break; case wxSYS_COLOUR_MENUBAR: bg(MenuBarWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA); break; case wxSYS_COLOUR_ACTIVECAPTION: case wxSYS_COLOUR_MENUHILIGHT: bg(MenuItemWidget(), GTK_STATE_FLAG_PRELIGHT, gdkRGBA); break; case wxSYS_COLOUR_MENUTEXT: fg(MenuItemWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA); break; case wxSYS_COLOUR_APPWORKSPACE: case wxSYS_COLOUR_WINDOW: { GtkWidget* widget = TextCtrlWidget(); GtkStyleContext* sc = gtk_widget_get_style_context(widget); gtk_style_context_save(sc); gtk_style_context_add_class(sc, GTK_STYLE_CLASS_VIEW); bg(widget, GTK_STATE_FLAG_NORMAL, gdkRGBA); gtk_style_context_restore(sc); } break; case wxSYS_COLOUR_CAPTIONTEXT: { GdkRGBA c = { 1, 1, 1, 1 }; gdkRGBA = c; } break; default: wxFAIL_MSG("unknown system colour index"); // fallthrough case wxSYS_COLOUR_3DDKSHADOW: case wxSYS_COLOUR_GRADIENTACTIVECAPTION: case wxSYS_COLOUR_GRADIENTINACTIVECAPTION: // black break; } return wxColour(gdkRGBA); }
/****f* widget/gnoclLinkButtonCmd * AUTHOR * PGB * SOURCE */ int gnoclLinkButtonCmd ( ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[] ) { int ret; GtkWidget *widget; int k, a, b; GnoclOption *pop; char *str_label, *str_uri ; /* determine which type of linkButton to create... */ /* * Do some pre-checking on the options set. * The gtk library has two forms of linkbutton, on with a label or one that simply shows the uri * these values are set at initialisation and so the argument line needs to be parsed so * that a decision can be made as to which type of widget to create. * */ /* * Parse all Options * Picking out individual options from the active script command line. */ for ( k = 1; k < objc; k += 2 ) { int idx; if ( gnoclGetIndexFromObjStruct ( interp, objv[k], ( char ** ) &linkButtonOptions[0].optName, sizeof ( GnoclOption ), "option", TCL_EXACT, &idx ) != TCL_OK ) { return -1; } /* originally, commented out */ /* printf( "parsing %s -> %s\n", Tcl_GetString( objv[k] ), linkButtonOptions[idx].optName); */ if ( strcmp ( Tcl_GetString ( objv[k] ), "-text" ) == 0 ) { str_label = Tcl_GetString ( objv[k+1] ); a = 1; } if ( strcmp ( Tcl_GetString ( objv[k] ), "-uri" ) == 0 ) { str_uri = Tcl_GetString ( objv[k+1] ); b = 1; } } /* decide what to do based on above values in step 2*/ /* STEP 1) -check validity of switches */ if ( gnoclParseOptions ( interp, objc, objv, linkButtonOptions ) != TCL_OK ) { gnoclClearOptions ( linkButtonOptions ); return TCL_ERROR; } /* STEP 2) -create widget, configure it, then clear memory */ /* * a== 1 and b == 1, then create a button with a label. * if a!= 1 and b == 1, then create a button with the URI as label * if b != 1, then this is an error. -uri is a mandatory option. */ if ( a == 1 && b == 1 ) { //printf ("label %s and URI %s\n", str_label, str_uri ); widget = GTK_WIDGET ( gtk_link_button_new_with_label ( str_uri, str_label ) ); } else if ( b == 1 ) { //printf ("URI %s\n", str_uri ); widget = gtk_link_button_new ( str_uri ); } else { //printf ("error\n" ); } a = 0; b = 0; gtk_widget_show ( GTK_WIDGET ( widget ) ); ret = gnoclSetOptions ( interp, linkButtonOptions, G_OBJECT ( widget ), -1 ); if ( ret == TCL_OK ) { ret = configure ( interp, G_OBJECT ( widget ), linkButtonOptions ); } gnoclClearOptions ( linkButtonOptions ); /* STEP 3) -show the widget */ if ( ret != TCL_OK ) { gtk_widget_destroy ( GTK_WIDGET ( widget ) ); return TCL_ERROR; } /* STEP 4) -everything has worked, register the widget with the Tcl interpretor. */ return gnoclRegisterWidget ( interp, GTK_WIDGET ( widget ), linkButtonFunc ); }
void show_about_box(GtkWidget *widget) { const char *license = { "Copyright \xc2\xa9 2009-2015, Albertas Vyšniauskas\n" "\n" "All rights reserved.\n" "\n" "Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n" "\n" " * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n" " * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n" " * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.\n" "\n" "THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n" }; const char *expat_license = { "Copyright \xc2\xa9 1998, 1999, 2000 Thai Open Source Software Center Ltd and Clark Cooper\n" "Copyright \xc2\xa9 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.\n" "\n" "Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n" "\n" "The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n" "\n" "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n" }; const char *lua_license = { "Copyright \xc2\xa9 1994-2008 Lua.org, PUC-Rio.\n" "\n" "Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n" "\n" "The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n" "\n" "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n" }; const char *program_authors = { "Albertas Vyšniauskas <*****@*****.**>\n" /* Add yourself here if you helped Gpick project in any way (patch, translation, etc). * Everything is optional, if you do not want, you do not have to disclose your e-mail * address, real name or any other information. * Please keep this list sorted alphabetically. */ }; GtkWidget* dialog = gtk_dialog_new_with_buttons(_("About Gpick"), GTK_WINDOW(gtk_widget_get_toplevel(widget)), GtkDialogFlags(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), GTK_STOCK_CLOSE, GTK_RESPONSE_CANCEL, NULL); gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CANCEL); GtkWidget *vbox = gtk_vbox_new(false, 5); GtkWidget *align_box = gtk_hbox_new(false, 5); gtk_box_pack_start(GTK_BOX(vbox), align_box, false, false, 0); gtk_box_pack_start(GTK_BOX(align_box), gtk_vbox_new(false, 0), true, true, 0); gtk_box_pack_end(GTK_BOX(align_box), gtk_vbox_new(false, 0), true, true, 0); GtkWidget *hbox = gtk_hbox_new(false, 5); gtk_box_pack_start(GTK_BOX(align_box), hbox, false, false, 0); GtkWidget *image = gtk_image_new(); gtk_image_set_from_icon_name(GTK_IMAGE(image), "gpick", GTK_ICON_SIZE_DIALOG); gtk_box_pack_start(GTK_BOX(hbox), image, false, false, 0); GtkWidget *vbox2 = gtk_vbox_new(false, 0); gtk_box_pack_start(GTK_BOX(hbox), vbox2, false, false, 0); gchar *tmp_string = g_markup_printf_escaped("<span size=\"xx-large\" weight=\"bold\">%s %s</span>", program_name, gpick_build_version); GtkWidget *name = gtk_label_new(0); gtk_label_set_selectable(GTK_LABEL(name), true); gtk_label_set_justify(GTK_LABEL(name), GTK_JUSTIFY_CENTER); gtk_label_set_markup(GTK_LABEL(name), tmp_string); gtk_box_pack_start(GTK_BOX(vbox2), name, false, false, 0); g_free(tmp_string); GtkWidget *comments = gtk_label_new(_("Advanced color picker")); gtk_label_set_selectable(GTK_LABEL(comments), true); gtk_label_set_justify(GTK_LABEL(comments), GTK_JUSTIFY_CENTER); gtk_box_pack_start(GTK_BOX(vbox2), comments, false, false, 0); tmp_string = g_markup_printf_escaped ("<span size=\"small\">%s</span>", _("Copyrights © 2009-2015, Albertas Vyšniauskas and Gpick development team")); GtkWidget *copyright = gtk_label_new(0); gtk_label_set_selectable(GTK_LABEL(copyright), true); gtk_label_set_justify(GTK_LABEL(copyright), GTK_JUSTIFY_CENTER); gtk_label_set_line_wrap(GTK_LABEL(copyright), true); gtk_label_set_markup(GTK_LABEL(copyright), tmp_string); gtk_box_pack_start(GTK_BOX(vbox2), copyright, false, false, 0); g_free(tmp_string); GtkWidget *website = gtk_link_button_new("http://www.gpick.org/"); gtk_box_pack_start(GTK_BOX(vbox2), website, false, false, 0); GtkWidget *notebook = gtk_notebook_new(); gtk_notebook_set_scrollable(GTK_NOTEBOOK(notebook), true); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), new_page(license), gtk_label_new(_("License"))); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), new_page(program_authors), gtk_label_new(_("Credits"))); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), new_page(expat_license), gtk_label_new(_("Expat License"))); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), new_page(lua_license), gtk_label_new(_("Lua License"))); gtk_box_pack_start(GTK_BOX(vbox), notebook, true, true, 0); gtk_widget_show_all(vbox); gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), vbox, true, true, 5); gtk_window_set_default_size(GTK_WINDOW(dialog), 400, 300); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); return; }
void nsLookAndFeel::InitLookAndFeel() { GtkStyle *style; // tooltip foreground and background style = gtk_rc_get_style_by_paths(gtk_settings_get_default(), "gtk-tooltips", "GtkWindow", GTK_TYPE_WINDOW); if (style) { sInfoBackground = GDK_COLOR_TO_NS_RGB(style->bg[GTK_STATE_NORMAL]); sInfoText = GDK_COLOR_TO_NS_RGB(style->fg[GTK_STATE_NORMAL]); } // menu foreground & menu background GtkWidget *accel_label = gtk_accel_label_new("M"); GtkWidget *menuitem = gtk_menu_item_new(); GtkWidget *menu = gtk_menu_new(); g_object_ref_sink(menu); gtk_container_add(GTK_CONTAINER(menuitem), accel_label); gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); gtk_widget_set_style(accel_label, NULL); gtk_widget_set_style(menu, NULL); gtk_widget_realize(menu); gtk_widget_realize(accel_label); style = gtk_widget_get_style(accel_label); if (style) { sMenuText = GDK_COLOR_TO_NS_RGB(style->fg[GTK_STATE_NORMAL]); } style = gtk_widget_get_style(menu); if (style) { sMenuBackground = GDK_COLOR_TO_NS_RGB(style->bg[GTK_STATE_NORMAL]); } style = gtk_widget_get_style(menuitem); if (style) { sMenuHover = GDK_COLOR_TO_NS_RGB(style->bg[GTK_STATE_PRELIGHT]); sMenuHoverText = GDK_COLOR_TO_NS_RGB(style->fg[GTK_STATE_PRELIGHT]); } g_object_unref(menu); // button styles GtkWidget *parent = gtk_fixed_new(); GtkWidget *button = gtk_button_new(); GtkWidget *label = gtk_label_new("M"); GtkWidget *combobox = gtk_combo_box_new(); GtkWidget *comboboxLabel = gtk_label_new("M"); GtkWidget *window = gtk_window_new(GTK_WINDOW_POPUP); GtkWidget *treeView = gtk_tree_view_new(); GtkWidget *linkButton = gtk_link_button_new("http://example.com/"); GtkWidget *menuBar = gtk_menu_bar_new(); GtkWidget *entry = gtk_entry_new(); gtk_container_add(GTK_CONTAINER(button), label); gtk_container_add(GTK_CONTAINER(combobox), comboboxLabel); gtk_container_add(GTK_CONTAINER(parent), button); gtk_container_add(GTK_CONTAINER(parent), treeView); gtk_container_add(GTK_CONTAINER(parent), linkButton); gtk_container_add(GTK_CONTAINER(parent), combobox); gtk_container_add(GTK_CONTAINER(parent), menuBar); gtk_container_add(GTK_CONTAINER(window), parent); gtk_container_add(GTK_CONTAINER(parent), entry); gtk_widget_set_style(button, NULL); gtk_widget_set_style(label, NULL); gtk_widget_set_style(treeView, NULL); gtk_widget_set_style(linkButton, NULL); gtk_widget_set_style(combobox, NULL); gtk_widget_set_style(comboboxLabel, NULL); gtk_widget_set_style(menuBar, NULL); gtk_widget_set_style(entry, NULL); gtk_widget_realize(button); gtk_widget_realize(label); gtk_widget_realize(treeView); gtk_widget_realize(linkButton); gtk_widget_realize(combobox); gtk_widget_realize(comboboxLabel); gtk_widget_realize(menuBar); gtk_widget_realize(entry); style = gtk_widget_get_style(label); if (style) { sButtonText = GDK_COLOR_TO_NS_RGB(style->fg[GTK_STATE_NORMAL]); } style = gtk_widget_get_style(comboboxLabel); if (style) { sComboBoxText = GDK_COLOR_TO_NS_RGB(style->fg[GTK_STATE_NORMAL]); } style = gtk_widget_get_style(combobox); if (style) { sComboBoxBackground = GDK_COLOR_TO_NS_RGB(style->bg[GTK_STATE_NORMAL]); } style = gtk_widget_get_style(menuBar); if (style) { sMenuBarText = GDK_COLOR_TO_NS_RGB(style->fg[GTK_STATE_NORMAL]); sMenuBarHoverText = GDK_COLOR_TO_NS_RGB(style->fg[GTK_STATE_SELECTED]); } // Some themes have a unified menu bar, and support window dragging on it gboolean supports_menubar_drag = FALSE; GParamSpec *param_spec = gtk_widget_class_find_style_property(GTK_WIDGET_GET_CLASS(menuBar), "window-dragging"); if (param_spec) { if (g_type_is_a(G_PARAM_SPEC_VALUE_TYPE(param_spec), G_TYPE_BOOLEAN)) { gtk_widget_style_get(menuBar, "window-dragging", &supports_menubar_drag, NULL); } } sMenuSupportsDrag = supports_menubar_drag; // GTK's guide to fancy odd row background colors: // 1) Check if a theme explicitly defines an odd row color // 2) If not, check if it defines an even row color, and darken it // slightly by a hardcoded value (gtkstyle.c) // 3) If neither are defined, take the base background color and // darken that by a hardcoded value GdkColor colorValue; GdkColor *colorValuePtr = NULL; gtk_widget_style_get(treeView, "odd-row-color", &colorValuePtr, NULL); if (colorValuePtr) { colorValue = *colorValuePtr; } else { gtk_widget_style_get(treeView, "even-row-color", &colorValuePtr, NULL); if (colorValuePtr) darken_gdk_color(colorValuePtr, &colorValue); else darken_gdk_color(&treeView->style->base[GTK_STATE_NORMAL], &colorValue); } sOddCellBackground = GDK_COLOR_TO_NS_RGB(colorValue); if (colorValuePtr) gdk_color_free(colorValuePtr); style = gtk_widget_get_style(button); if (style) { sButtonBackground = GDK_COLOR_TO_NS_RGB(style->bg[GTK_STATE_NORMAL]); sButtonOuterLightBorder = GDK_COLOR_TO_NS_RGB(style->light[GTK_STATE_NORMAL]); sButtonInnerDarkBorder = GDK_COLOR_TO_NS_RGB(style->dark[GTK_STATE_NORMAL]); } colorValuePtr = NULL; gtk_widget_style_get(linkButton, "link-color", &colorValuePtr, NULL); if (colorValuePtr) { colorValue = *colorValuePtr; // we can't pass deref pointers to GDK_COLOR_TO_NS_RGB sNativeHyperLinkText = GDK_COLOR_TO_NS_RGB(colorValue); gdk_color_free(colorValuePtr); } else { sNativeHyperLinkText = NS_RGB(0x00,0x00,0xEE); } // invisible character styles guint value; g_object_get (entry, "invisible-char", &value, NULL); sInvisibleCharacter = PRUnichar(value); // caret styles gtk_widget_style_get(entry, "cursor-aspect-ratio", &sCaretRatio, NULL); gtk_widget_destroy(window); }