当前位置: 首页>>代码示例>>C++>>正文


C++ GTK_STYLE_PROVIDER函数代码示例

本文整理汇总了C++中GTK_STYLE_PROVIDER函数的典型用法代码示例。如果您正苦于以下问题:C++ GTK_STYLE_PROVIDER函数的具体用法?C++ GTK_STYLE_PROVIDER怎么用?C++ GTK_STYLE_PROVIDER使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GTK_STYLE_PROVIDER函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: cc_set_css

void cc_set_css(GtkWidget*w,gchar*file)
{
    GFile *cssfile=g_file_new_for_path(file);
GtkCssProvider*provider=gtk_css_provider_new();
GtkStyleContext*context=gtk_widget_get_style_context(w);
gtk_style_context_add_provider(context,GTK_STYLE_PROVIDER(provider),GTK_STYLE_PROVIDER_PRIORITY_USER);
gtk_css_provider_load_from_file(GTK_CSS_PROVIDER(provider),cssfile,NULL);
g_object_unref(provider);

}
开发者ID:zoeritic,项目名称:cclient,代码行数:10,代码来源:cc-style.c

示例2: tile_surface

static cairo_surface_t *
tile_surface (cairo_surface_t *surface,
              int              width,
              int              height)
{
	cairo_surface_t *copy;
	cairo_t *cr;

	if (surface == NULL)
	{
		copy = gdk_window_create_similar_surface (gdk_get_default_root_window (),
		                                          CAIRO_CONTENT_COLOR,
		                                          width, height);
	}
	else
	{
		copy = cairo_surface_create_similar (surface,
		                                     cairo_surface_get_content (surface),
		                                     width, height);
	}

	cr = cairo_create (copy);

	if (surface != NULL)
	{
		cairo_pattern_t *pattern;
		cairo_set_source_surface (cr, surface, 0.0, 0.0);
		pattern = cairo_get_source (cr);
		cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
	}
	else
	{
		GtkStyleContext *context;
		GdkRGBA bg;
		context = gtk_style_context_new ();
		gtk_style_context_add_provider (context,
										GTK_STYLE_PROVIDER (gtk_css_provider_get_default ()),
										GTK_STYLE_PROVIDER_PRIORITY_THEME);
		gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, &bg);
		gdk_cairo_set_source_rgba(cr, &bg);
		g_object_unref (G_OBJECT (context));
	}

	cairo_paint (cr);

	if (cairo_status (cr) != CAIRO_STATUS_SUCCESS)
	{
		cairo_surface_destroy (copy);
		copy = NULL;
	}

	cairo_destroy(cr);

	return copy;
}
开发者ID:mate-desktop,项目名称:mate-desktop,代码行数:55,代码来源:mate-bg-crossfade.c

示例3: gs_feature_tile_init

static void
gs_feature_tile_init (GsFeatureTile *tile)
{
	gtk_widget_set_has_window (GTK_WIDGET (tile), FALSE);
	gtk_widget_init_template (GTK_WIDGET (tile));

	tile->provider = gtk_css_provider_new ();
	gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
						   GTK_STYLE_PROVIDER (tile->provider),
						   GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
}
开发者ID:JamesLinus,项目名称:gnome-software,代码行数:11,代码来源:gs-feature-tile.c

示例4: side_modify_css

void side_modify_css(char *str)
{
  GdkDisplay *display;
  GdkScreen *screen;
  display = gdk_display_get_default ();
  screen = gdk_display_get_default_screen (display);
  GtkCssProvider *provider;
  provider = gtk_css_provider_new ();
  gtk_style_context_add_provider_for_screen (screen, GTK_STYLE_PROVIDER (provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
  gtk_css_provider_load_from_data(provider, str, -1, NULL);
  g_object_unref (provider);
}
开发者ID:gitter-badger,项目名称:desktop-2,代码行数:12,代码来源:widgets.c

示例5: gnc_add_css_file

void
gnc_add_css_file (void)
{
    GtkCssProvider *provider_user, *provider_app, *provider_fallback;
    GdkDisplay *display;
    GdkScreen *screen;
    const gchar *var;
    GError *error = 0;

    provider_user = gtk_css_provider_new ();
    provider_app = gtk_css_provider_new ();
    provider_fallback = gtk_css_provider_new ();
    display = gdk_display_get_default ();
    screen = gdk_display_get_default_screen (display);

    gtk_style_context_add_provider_for_screen (screen, GTK_STYLE_PROVIDER (provider_fallback), GTK_STYLE_PROVIDER_PRIORITY_FALLBACK);
    gtk_style_context_add_provider_for_screen (screen, GTK_STYLE_PROVIDER (provider_app), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
    gtk_style_context_add_provider_for_screen (screen, GTK_STYLE_PROVIDER (provider_user), GTK_STYLE_PROVIDER_PRIORITY_USER);

#if GTK_CHECK_VERSION(3,20,0)
    gtk_css_provider_load_from_resource (provider_app, "/org/gnucash/gnucash-320.css");
#else
    gtk_css_provider_load_from_resource (provider_app, "/org/gnucash/gnucash-310.css");
#endif
    gtk_css_provider_load_from_resource (provider_fallback,  "/org/gnucash/gnucash-fallback-310.css");

    var = g_get_home_dir ();
    if (var)
    {
        gchar *str;
        str = g_build_filename (var, ".gtk-3.0-gnucash.css", (char *)NULL);
        gtk_css_provider_load_from_path (provider_user, str, &error);
        g_free (str);
    }
    g_object_unref (provider_user);
    g_object_unref (provider_app);
    g_object_unref (provider_fallback);
}
开发者ID:jralls,项目名称:gnucash,代码行数:38,代码来源:gnc-gnome-utils.c

示例6: set_button_style

static void
set_button_style(GtkWidget *button, gint type)
{
#if GTK_CHECK_VERSION(2, 90, 0)
    GtkStyleContext *context = gtk_widget_get_style_context(button);
    GtkCssProvider *provider = gtk_css_provider_new();
    switch (type) {
    case TYPE_ICON:
        gtk_css_provider_load_from_data(provider,
                                        "#uim-systray-button {\n"
                                        " -GtkWidget-focus-line-width: 0;\n"
                                        " -GtkWidget-focus-padding: 0;\n"
                                        " padding-top: 0;\n"
                                        " padding-bottom: 0;\n"
                                        " padding-left: 2px;\n"
                                        " padding-right: 2px;\n"
                                        "}\n", -1, NULL);
        break;
    case TYPE_STANDALONE:
        gtk_css_provider_load_from_data(provider,
                                        "#uim-toolbar-button {\n"
                                        " padding-left: 5px;\n"
                                        " padding-right: 5px;\n"
                                        "}\n", -1, NULL);
        break;
    case TYPE_APPLET:
        gtk_css_provider_load_from_data(provider,
                                        "#uim-applet-button {\n"
                                        " padding-left: 2px;\n"
                                        " padding-right: 2px;\n"
                                        "}\n", -1, NULL);
        break;
    }
    gtk_style_context_add_provider(context,
                                   GTK_STYLE_PROVIDER(provider),
                                   GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
    g_object_unref(provider);
#endif
    switch (type) {
    case TYPE_ICON:
        gtk_widget_set_name(button, "uim-systray-button");
        break;
    case TYPE_STANDALONE:
        gtk_widget_set_name(button, "uim-toolbar-button");
        break;
    case TYPE_APPLET:
        gtk_widget_set_name(button, "uim-applet-button");
        break;
    }
}
开发者ID:na4zagin3,项目名称:uim,代码行数:50,代码来源:common-gtk.c

示例7: gtk_css_provider_get_default

void Editor::setStyle()
    {
    GtkCssProvider *provider = gtk_css_provider_get_default();
    GdkDisplay *display = gdk_display_get_default();
    GdkScreen *screen = gdk_display_get_default_screen(display);

    OovString path = Project::getBinDirectory();
    path += "OovEdit.css";
    GError *err = 0;
    gtk_css_provider_load_from_path(provider, path.getStr(), &err);
    gtk_style_context_add_provider_for_screen (screen,
        GTK_STYLE_PROVIDER(provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
    g_object_unref(provider);
    }
开发者ID:animatedb,项目名称:oovaide,代码行数:14,代码来源:oovEdit.cpp

示例8: gtk_paned_new

GtkWidget *gtk_paned_new_with_handle(GtkOrientation orientation)
{
	GtkWidget *pnd = gtk_paned_new(orientation);
	GtkStyleContext *context = gtk_widget_get_style_context(pnd);
	GtkCssProvider  *cssprv =  gtk_css_provider_new();
	GdkRGBA clrSel = {0.,0.,0.,0.};
	char css[2048];
	
	gtk_style_context_lookup_color(context, "bg_color", &clrSel);
	if (orientation == GTK_ORIENTATION_HORIZONTAL)
	{
		sprintf(css, "* {\n -GtkPaned-handle-size: 3; \n } \n .pane-separator.horizontal {\n background-image: -gtk-gradient (linear, left top, left bottom, from (%s), color-stop (0.5, shade (%s, 0.95)), to (%s)); \n -unico-centroid-texture: url(\"%s\");\n }\n", gdk_rgba_to_string(&clrSel), gdk_rgba_to_string(&clrSel), gdk_rgba_to_string(&clrSel), imgOrzHnd);
	}
	else
	{
		sprintf(css, "* {\n -GtkPaned-handle-size: 3; \n } \n \n .pane-separator.vertical {\n background-image: -gtk-gradient (linear, left top, right top, from (%s), color-stop (0.5, shade (%s, 0.95)), to (%s)); \n -unico-centroid-texture: url(\"%s\");\n }\n", gdk_rgba_to_string(&clrSel), gdk_rgba_to_string(&clrSel), gdk_rgba_to_string(&clrSel), imgVrtHnd);
	}
	gtk_style_context_remove_provider(context, GTK_STYLE_PROVIDER (cssprv));
	gtk_style_context_add_provider(context, GTK_STYLE_PROVIDER (cssprv), GTK_STYLE_PROVIDER_PRIORITY_USER);
	gtk_css_provider_load_from_data(cssprv, css, -1, NULL);
	g_object_unref(cssprv);
	return pnd;
}
开发者ID:OpenSkyProject,项目名称:OpenSkyImager,代码行数:23,代码来源:gtkTools.c

示例9: add_css_provider

static void
add_css_provider (GApplication *application,
                  gboolean theme)
{
  gs_unref_object GtkCssProvider *provider;

  provider = gtk_css_provider_new ();
  if (!load_css_from_resource (application, provider, theme))
    return;

  gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
                                             GTK_STYLE_PROVIDER (provider),
                                             GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
}
开发者ID:pledges,项目名称:gnome-terminal,代码行数:14,代码来源:terminal-app.c

示例10: theme_init

void theme_init(){
    char *theme_file;

    theme_file = get_theme_file("default.css");
    if (!theme_file){
        return;
    }

    provider = GTK_STYLE_PROVIDER(gtk_css_provider_new());
    gtk_css_provider_load_from_path(
            GTK_CSS_PROVIDER(provider), theme_file, NULL);

    g_free(theme_file);
}
开发者ID:LastAvenger,项目名称:srain,代码行数:14,代码来源:theme.c

示例11: button_clicked_cb

static void
button_clicked_cb (GtkButton *b,
                   gpointer user_data)
{
  PackData *d = user_data;
  GtkCssProvider *provider;
  GtkStyleContext *style;
  GError *error = NULL;
  gchar *data, *bg_str, *grad1, *grad2;
  const gchar data_format[] = "GtkNumerableIcon { background-color: %s; color: #000000;"
    "background-image: -gtk-gradient (linear, 0 0, 1 1, from(%s), to(%s));"
    "font: Monospace 12;"
    /* "background-image: url('apple-red.png');" */
    "}";

  bg_str = g_strdup_printf ("rgb(%d,%d,%d)", g_random_int_range (0, 255), g_random_int_range (0, 255), g_random_int_range (0, 255));
  grad1 = g_strdup_printf ("rgb(%d,%d,%d)", g_random_int_range (0, 255), g_random_int_range (0, 255), g_random_int_range (0, 255));
  grad2 = g_strdup_printf ("rgb(%d,%d,%d)", g_random_int_range (0, 255), g_random_int_range (0, 255), g_random_int_range (0, 255));

  data = g_strdup_printf (data_format, bg_str, grad1, grad2);

  provider = gtk_css_provider_new ();
  gtk_css_provider_load_from_data (provider, data, -1, &error);

  g_assert (error == NULL);

  style = gtk_widget_get_style_context (d->image);
  gtk_style_context_add_provider (style, GTK_STYLE_PROVIDER (provider),
                                  GTK_STYLE_PROVIDER_PRIORITY_USER);

  if (d->odd) {
    gtk_numerable_icon_set_background_icon_name (GTK_NUMERABLE_ICON (d->numerable), NULL);
    gtk_numerable_icon_set_count (GTK_NUMERABLE_ICON (d->numerable), g_random_int_range (-99, 99));
  } else {
    gtk_numerable_icon_set_background_icon_name (GTK_NUMERABLE_ICON (d->numerable),
                                                 "emblem-favorite");
    gtk_numerable_icon_set_label (GTK_NUMERABLE_ICON (d->numerable), "IVX");
  }
  
  gtk_image_set_from_gicon (GTK_IMAGE (d->image), d->numerable, d->size);

  d->odd = !d->odd;

  g_free (data);
  g_free (bg_str);
  g_free (grad1);
  g_free (grad2);
  
  g_object_unref (provider);
}
开发者ID:3v1n0,项目名称:gtk,代码行数:50,代码来源:testnumerableicon.c

示例12: test_init_of_theme

static void
test_init_of_theme (void)
{
  GtkStyleContext *context;
  GtkCssProvider *provider;
  GtkWidgetPath *path;
  GdkRGBA before, after;
  char *css;

  /* Test that a style context actually uses the theme loaded for the 
   * screen it is using. If no screen is set, it's the default one.
   */
  context = gtk_style_context_new ();
  path = gtk_widget_path_new ();

  /* Set a path that will have a color set.
   * (This could actually fail if style classes change, so if this test
   *  fails, make sure to have this path represent something sane.)
   */
  gtk_widget_path_append_type (path, GTK_TYPE_WINDOW);
  gtk_widget_path_iter_add_class (path, -1, GTK_STYLE_CLASS_BACKGROUND);
  gtk_style_context_set_path (context, path);
  gtk_widget_path_free (path);

  /* Get the color. This should be initialized by the theme and not be
   * the default. */
  gtk_style_context_get_color (context, gtk_style_context_get_state (context), &before);

  /* Add a style that sets a different color for this widget.
   * This style has a higher priority than fallback, but a lower 
   * priority than the theme. */
  css = g_strdup_printf (".background { color: %s; }",
                         before.alpha < 0.5 ? "black" : "transparent");
  provider = gtk_css_provider_new ();
  gtk_css_provider_load_from_data (provider, css, -1, NULL);
  gtk_style_context_add_provider (context,
                                  GTK_STYLE_PROVIDER (provider),
                                  GTK_STYLE_PROVIDER_PRIORITY_FALLBACK + 1);
  g_object_unref (provider);

  /* Get the color again. */
  gtk_style_context_get_color (context, gtk_style_context_get_state (context), &after);

  /* Because the style we added does not influence the color,
   * the before and after colors should be identical. */
  g_assert (gdk_rgba_equal (&before, &after));

  g_object_unref (context);
}
开发者ID:ConfusedReality,项目名称:pkg_toolkit_gtk3,代码行数:49,代码来源:firefox-stylecontext.c

示例13: main

int
main(int argc, char* argv[]) {
	GtkWidget *win;
	GtkCssProvider *cssprovider;
	GdkScreen *screen;
	GError *error;

	/* Disable global menus */
	g_unsetenv ("UBUNTU_MENUPROXY");
	gtk_init(&argc, &argv);
	ido_init ();
	screen = gdk_screen_get_default();
	win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_window_set_default_size (GTK_WINDOW (win), -1, 28);
	g_signal_connect(win, "realize", G_CALLBACK(on_realize), NULL);
	g_signal_connect(screen, "monitors-changed", G_CALLBACK(on_screen_change), win);
	g_signal_connect(screen, "size-changed", G_CALLBACK(on_screen_change), win);

	cssprovider = gtk_css_provider_new ();
	gtk_css_provider_load_from_data(cssprovider,
			"GtkMenuBar {\n"
			"    -GtkMenuBar-internal-padding: 0;\n"
			"    -GtkMenuBar-shadow-type: none;\n"
			"}\n"
			"GtkWidget {\n"
			"    -GtkWidget-focus-line-width: 0;\n"
			"    -GtkWidget-focus-padding: 0;\n"
			"}\n", -1, NULL);

	gtk_style_context_add_provider_for_screen(screen,
		GTK_STYLE_PROVIDER (cssprovider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);

	GtkWidget* menubar = gtk_menu_bar_new();

	load_indicator_files (INDICATOR_DIR, menubar);
	IndicatorObject * io = indicator_object_new_from_file("/usr/lib/indicators3/7/libapplication.so");
	load_indicator(io, menubar);

	GtkWidget* hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3);
	gtk_container_add(GTK_CONTAINER(win), hbox);
	gtk_box_pack_end(GTK_BOX(hbox), menubar, FALSE, FALSE, 0);
	g_signal_connect_after(menubar, "draw", G_CALLBACK(on_draw), NULL);
	g_signal_connect(win, "draw", G_CALLBACK(on_draw), NULL);
	gtk_widget_show_all(win);
	gdk_window_process_updates(gtk_widget_get_window(win), TRUE);
	gtk_widget_set_app_paintable(win, TRUE);
	gtk_main();
	return 0;
}
开发者ID:linuxmint,项目名称:ubiquity,代码行数:49,代码来源:panel.c

示例14: irc_application_activate

static void
irc_application_activate (GApplication *self)
{
  	IrcApplicationPrivate *priv = irc_application_get_instance_private (IRC_APPLICATION(self));

	if (priv->main_window == NULL)
	{
		priv->main_window = GTK_WINDOW(irc_window_new (self));
		gtk_style_context_add_provider_for_screen (gtk_window_get_screen (priv->main_window),
											 GTK_STYLE_PROVIDER(priv->css_provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
		irc_application_load_plugins (IRC_APPLICATION(self)); // In-case plugins modify UI
	}

	gtk_window_present (priv->main_window);
}
开发者ID:TingPing,项目名称:irc-client,代码行数:15,代码来源:irc-application.c

示例15: gui_update_font

/**************************************************************************
  Updates a gui font style.
**************************************************************************/
void gui_update_font(const char *font_name, const char *font_value)
{
  char *str;
  GtkCssProvider *provider;

  str = g_strdup_printf("#Freeciv #%s { font: %s;}", font_name, font_value);

  provider = gtk_css_provider_new();
  gtk_css_provider_load_from_data(GTK_CSS_PROVIDER(provider),
    str, -1, NULL);
  gtk_style_context_add_provider_for_screen(
    gtk_widget_get_screen(toplevel), GTK_STYLE_PROVIDER(provider),
    GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
  g_free(str);
}
开发者ID:longturn,项目名称:freeciv-S2_5,代码行数:18,代码来源:gui_stuff.c


注:本文中的GTK_STYLE_PROVIDER函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。