Пример #1
0
static void
reset_theme_css(GtTwitchChatView* self)
{
    GtTwitchChatViewPrivate* priv = gt_twitch_chat_view_get_instance_private(self);
    gchar css[200];

    g_sprintf(css, priv->dark_theme ? CHAT_DARK_THEME_CSS : CHAT_LIGHT_THEME_CSS,
              priv->opacity);

    if (priv->dark_theme)
    {
        REMOVE_STYLE_CLASS(priv->chat_view, CHAT_LIGHT_THEME_CSS_CLASS);
        REMOVE_STYLE_CLASS(priv->chat_entry, CHAT_LIGHT_THEME_CSS_CLASS);
        ADD_STYLE_CLASS(priv->chat_view, CHAT_DARK_THEME_CSS_CLASS);
        ADD_STYLE_CLASS(priv->chat_entry, CHAT_DARK_THEME_CSS_CLASS);
    }
    else
    {
        REMOVE_STYLE_CLASS(priv->chat_view, CHAT_DARK_THEME_CSS_CLASS);
        REMOVE_STYLE_CLASS(priv->chat_entry, CHAT_DARK_THEME_CSS_CLASS);
        ADD_STYLE_CLASS(priv->chat_view, CHAT_LIGHT_THEME_CSS_CLASS);
        ADD_STYLE_CLASS(priv->chat_entry, CHAT_LIGHT_THEME_CSS_CLASS);
    }

    gtk_css_provider_load_from_data(priv->chat_css_provider, css, -1, NULL); //TODO Error handling
    gtk_widget_reset_style(GTK_WIDGET(self));
    gtk_widget_reset_style(priv->chat_view);
}
Пример #2
0
static void
gd_main_toolbar_clear (GdMainToolbar *self)
{
  GtkStyleContext *context;

  /* reset labels */
  gtk_label_set_text (GTK_LABEL (self->priv->title_label), "");
  gtk_label_set_text (GTK_LABEL (self->priv->detail_label), "");

  /* clear all on the left, except the back button */
  gtk_widget_hide (self->priv->back);
  gtk_container_foreach (GTK_CONTAINER (self->priv->left_grid),
                         on_left_grid_clear, self);

  /* clear all on the right */
  gtk_container_foreach (GTK_CONTAINER (self->priv->right_grid), 
                         (GtkCallback) gtk_widget_destroy, self);

  context = gtk_widget_get_style_context (GTK_WIDGET (self));
  if (gtk_style_context_has_class (context, "documents-selection-mode"))
    {
      gtk_style_context_remove_class (context, "documents-selection-mode");
      gtk_widget_reset_style (GTK_WIDGET (self));
    }

  g_signal_emit (self, signals[CLEAR_REQUEST], 0);
}
void
panel_menu_bar_object_set_orientation (PanelMenuBarObject *menubar,
                                       PanelOrientation    orientation)
{
    GtkStyleContext *context;

    g_return_if_fail (PANEL_IS_MENU_BAR_OBJECT (menubar));

    if (menubar->priv->orientation == orientation)
        return;

    menubar->priv->orientation = orientation;

    context = gtk_widget_get_style_context (GTK_WIDGET (menubar));
    if (orientation & PANEL_HORIZONTAL_MASK) {
        gtk_style_context_add_class (context, GTK_STYLE_CLASS_HORIZONTAL);
        gtk_style_context_remove_class (context, GTK_STYLE_CLASS_VERTICAL);
    } else {
        gtk_style_context_add_class (context, GTK_STYLE_CLASS_VERTICAL);
        gtk_style_context_remove_class (context, GTK_STYLE_CLASS_HORIZONTAL);
    }
    gtk_widget_reset_style (GTK_WIDGET (menubar));

    panel_menu_bar_object_update_orientation (menubar);

    g_object_notify (G_OBJECT (menubar), "orientation");
}
static void
photos_preview_nav_buttons_update_favorite (PhotosPreviewNavButtons *self, gboolean favorite)
{
  PhotosPreviewNavButtonsPrivate *priv = self->priv;
  GtkStyleContext *context;
  gchar *favorite_label;

  g_signal_handlers_block_by_func (priv->favorite_button, photos_preview_nav_buttons_favorite_clicked, self);
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->favorite_button), favorite);
  g_signal_handlers_unblock_by_func (priv->favorite_button, photos_preview_nav_buttons_favorite_clicked, self);

  context = gtk_widget_get_style_context (priv->favorite_button);
  if (favorite)
    {
      favorite_label = g_strdup (_("Remove from favorites"));
      gtk_style_context_add_class (context, "documents-favorite");
    }
  else
    {
      favorite_label = g_strdup (_("Add to favorites"));
      gtk_style_context_remove_class (context, "documents-favorite");
    }

  gtk_widget_reset_style (priv->favorite_button);
  gtk_widget_set_tooltip_text (priv->favorite_button, favorite_label);
  g_free (favorite_label);
}
Пример #5
0
static void
gd_main_toolbar_populate_for_selection (GdMainToolbar *self)
{
  GtkWidget *w;

  gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (self)),
                               "documents-selection-mode");
  gtk_widget_reset_style (GTK_WIDGET (self));

  /* right section */
  w = get_text_button (_("Done"));
  gtk_container_add (GTK_CONTAINER (self->priv->right_grid), w);

  g_signal_connect (w, "clicked",
                    G_CALLBACK (on_selection_mode_done_button_clicked), self);

  gtk_widget_show_all (GTK_WIDGET (self));
}
Пример #6
0
static void applet_change_background(MatePanelApplet* applet, MatePanelAppletBackgroundType type, GdkColor* color, cairo_pattern_t *pattern, PagerData* pager)
{
        GtkStyleContext *new_context;
        gtk_widget_reset_style (GTK_WIDGET (pager->pager));
        new_context = gtk_style_context_new ();
        gtk_style_context_set_path (new_context, gtk_widget_get_path (GTK_WIDGET (pager->pager)));
        g_object_unref (new_context);

        wnck_pager_set_shadow_type (WNCK_PAGER (pager->pager),
                type == PANEL_NO_BACKGROUND ? GTK_SHADOW_NONE : GTK_SHADOW_IN);
#else
static void applet_change_background(MatePanelApplet* applet, MatePanelAppletBackgroundType type, GdkColor* color, GdkPixmap* pixmap, PagerData* pager)
{
        /* taken from the TrashApplet */
        GtkRcStyle *rc_style;
        GtkStyle *style;

        /* reset style */
        gtk_widget_set_style (GTK_WIDGET (pager->pager), NULL);
        rc_style = gtk_rc_style_new ();
        gtk_widget_modify_style (GTK_WIDGET (pager->pager), rc_style);
        g_object_unref (rc_style);

	switch (type)
	{
                case PANEL_COLOR_BACKGROUND:
                        gtk_widget_modify_bg (GTK_WIDGET (pager->pager), GTK_STATE_NORMAL, color);
                        break;

                case PANEL_PIXMAP_BACKGROUND:
                        style = gtk_style_copy (gtk_widget_get_style (GTK_WIDGET (pager->pager)));
                        if (style->bg_pixmap[GTK_STATE_NORMAL])
                                g_object_unref (style->bg_pixmap[GTK_STATE_NORMAL]);
                        style->bg_pixmap[GTK_STATE_NORMAL] = g_object_ref(pixmap);
                        gtk_widget_set_style (GTK_WIDGET (pager->pager), style);
                        g_object_unref (style);
                        break;

                case PANEL_NO_BACKGROUND:
                default:
                        break;
	}
#endif
}
Пример #7
0
static void
nemo_window_pane_set_active_style (NemoWindowPane *pane,
				       gboolean is_active)
{
	GtkStyleContext *style;
	gboolean has_inactive;

	style = gtk_widget_get_style_context (GTK_WIDGET (pane));
	has_inactive = gtk_style_context_has_class (style, "nemo-inactive-pane");

	if (has_inactive == !is_active) {
		return;
	}

	if (is_active) {
		gtk_style_context_remove_class (style, "nemo-inactive-pane");
	} else {
		gtk_style_context_add_class (style, "nemo-inactive-pane");
	}

	gtk_widget_reset_style (GTK_WIDGET (pane));
}
Пример #8
0
/* Applets cannot set their orientation, so API is not public. */
static void
panel_applet_set_orient (PanelApplet       *applet,
                         PanelAppletOrient  orient)
{
	GtkStyleContext *context;

	g_return_if_fail (PANEL_IS_APPLET (applet));

	if (applet->priv->orient == orient)
		return;

	applet->priv->orient = orient;

	context = gtk_widget_get_style_context (GTK_WIDGET (applet));
	switch (orient) {
	case PANEL_APPLET_ORIENT_UP:
	case PANEL_APPLET_ORIENT_DOWN:
		gtk_style_context_add_class (context, GTK_STYLE_CLASS_HORIZONTAL);
		gtk_style_context_remove_class (context, GTK_STYLE_CLASS_VERTICAL);
		break;
	case PANEL_APPLET_ORIENT_LEFT:
	case PANEL_APPLET_ORIENT_RIGHT:
		gtk_style_context_add_class (context, GTK_STYLE_CLASS_VERTICAL);
		gtk_style_context_remove_class (context, GTK_STYLE_CLASS_HORIZONTAL);
		break;
	default:
		g_assert_not_reached();
		break;
	}
	gtk_widget_reset_style (GTK_WIDGET (applet));

	g_signal_emit (G_OBJECT (applet),
		       panel_applet_signals [CHANGE_ORIENT],
		       0, orient);

	g_object_notify (G_OBJECT (applet), "orient");
}
Пример #9
0
static void
gw_settingswindow_init_styles (GwSettingsWindow *window)
{
    //Declarations
    GtkToolbar *toolbar;
    GtkStyleContext *context;
    GtkWidget *widget;


    //Vocabulary list pane
    widget = GTK_WIDGET (gw_window_get_object (GW_WINDOW (window), "dictionary_scrolledwindow"));
    context = gtk_widget_get_style_context (widget);
    gtk_style_context_set_junction_sides (context, GTK_JUNCTION_BOTTOM);
    gtk_widget_reset_style (widget);

    toolbar = GTK_TOOLBAR (gw_window_get_object (GW_WINDOW (window), "dictionary_toolbar"));
    widget = GTK_WIDGET (toolbar);
    context = gtk_widget_get_style_context (widget);
    gtk_style_context_add_class (context, "inline-toolbar");
    gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP);
    gtk_widget_reset_style (widget);

    {
      GtkIconTheme *theme;
      GtkToolItem *item;

      theme = gtk_icon_theme_get_default ();

      item = gtk_tool_button_new_from_stock (GTK_STOCK_ADD);
      if (gtk_icon_theme_has_icon (theme, "list-add-symbolic"))
      {
        gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item), "list-add-symbolic");
        gtk_tool_button_set_stock_id (GTK_TOOL_BUTTON (item), NULL);
      }
      gtk_toolbar_insert (toolbar, item, -1);
      gtk_actionable_set_detailed_action_name (GTK_ACTIONABLE (item), "win.add-dictionary");
      gtk_widget_show (GTK_WIDGET (item));
      
      item = gtk_tool_button_new_from_stock (GTK_STOCK_REMOVE);
      if (gtk_icon_theme_has_icon (theme, "list-remove-symbolic"))
      {
        gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item), "list-remove-symbolic");
        gtk_tool_button_set_stock_id (GTK_TOOL_BUTTON (item), NULL);
      }
      gtk_toolbar_insert (toolbar, item, -1);
      gtk_actionable_set_detailed_action_name (GTK_ACTIONABLE (item), "win.remove-dictionary");
      gtk_widget_show (GTK_WIDGET (item));
    }

    //Vocabulary listitem pane
    widget = GTK_WIDGET (gw_window_get_object (GW_WINDOW (window), "plugin_scrolledwindow"));
    context = gtk_widget_get_style_context (widget);
    gtk_style_context_set_junction_sides (context, GTK_JUNCTION_BOTTOM);
    gtk_widget_reset_style (widget);

    toolbar = GTK_TOOLBAR (gw_window_get_object (GW_WINDOW (window), "plugin_toolbar"));
    widget = GTK_WIDGET (toolbar);
    context = gtk_widget_get_style_context (widget);
    gtk_style_context_add_class (context, "inline-toolbar");
    gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP);
    gtk_widget_reset_style (widget);

    {
      GtkIconTheme *theme;
      GtkToolItem *item;

      theme = gtk_icon_theme_get_default ();

      item = gtk_tool_button_new_from_stock (GTK_STOCK_ADD);
      if (gtk_icon_theme_has_icon (theme, "list-add-symbolic"))
      {
        gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item), "list-add-symbolic");
        gtk_tool_button_set_stock_id (GTK_TOOL_BUTTON (item), NULL);
      }
      gtk_toolbar_insert (toolbar, item, -1);
      gtk_actionable_set_detailed_action_name (GTK_ACTIONABLE (item), "win.add-plugin");
      gtk_widget_show (GTK_WIDGET (item));
      
      item = gtk_tool_button_new_from_stock (GTK_STOCK_REMOVE);
      if (gtk_icon_theme_has_icon (theme, "list-remove-symbolic"))
      {
        gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item), "list-remove-symbolic");
        gtk_tool_button_set_stock_id (GTK_TOOL_BUTTON (item), NULL);
      }
      gtk_toolbar_insert (toolbar, item, -1);
      gtk_actionable_set_detailed_action_name (GTK_ACTIONABLE (item), "win.remove-plugin");
      gtk_widget_show (GTK_WIDGET (item));
    }
}
Пример #10
0
static void
photos_selection_toolbar_set_item_visibility (PhotosSelectionToolbar *self)
{
  PhotosSelectionToolbarPrivate *priv = self->priv;
  GList *apps = NULL;
  GList *l;
  GList *selection;
  GtkStyleContext *context;
  gboolean has_selection;
  gboolean show_collection;
  gboolean show_favorite;
  gboolean show_open;
  gboolean show_print;
  gboolean show_properties;
  gboolean show_trash;
  gchar *favorite_label;
  gchar *open_label;
  guint fav_count = 0;
  guint apps_length;
  guint sel_length;

  priv->inside_refresh = TRUE;

  selection = photos_selection_controller_get_selection (priv->sel_cntrlr);
  sel_length = g_list_length (selection);
  has_selection = sel_length > 0;

  show_collection = has_selection;
  show_favorite = has_selection;
  show_open = has_selection;
  show_print = has_selection;
  show_properties = has_selection;
  show_trash = has_selection;

  for (l = selection; l != NULL; l = g_list_next (l))
    {
      PhotosBaseItem *item;
      const gchar *default_app_name;
      const gchar *urn = (gchar *) l->data;

      item = PHOTOS_BASE_ITEM (photos_base_manager_get_object_by_id (priv->item_mngr, urn));

      if (photos_base_item_is_favorite (item))
        fav_count++;

      default_app_name = photos_base_item_get_default_app_name (item);
      if (default_app_name != NULL && g_list_find (apps, default_app_name) == NULL)
        apps = g_list_prepend (apps, (gpointer) g_strdup (default_app_name));

      show_trash = show_trash && photos_base_item_can_trash (item);
      show_print = show_print && !photos_base_item_is_collection (item);
    }

  show_favorite = show_favorite && ((fav_count == 0) || (fav_count == sel_length));

  apps_length = g_list_length (apps);
  show_open = (apps_length > 0);

  if (sel_length > 1)
    {
      show_print = FALSE;
      show_properties = FALSE;
    }

  if (apps_length == 1)
    /* Translators: this is the Open action in a context menu */
    open_label = g_strdup_printf (_("Open with %s"), (gchar *) apps->data);
  else
    /* Translators: this is the Open action in a context menu */
    open_label = g_strdup (_("Open"));

  gd_header_button_set_label (GD_HEADER_BUTTON (priv->toolbar_open), open_label);
  g_free (open_label);
  g_list_free_full (apps, g_free);

  context = gtk_widget_get_style_context (priv->toolbar_favorite);
  if (show_favorite && fav_count == sel_length)
    {
      favorite_label = g_strdup (_("Remove from favorites"));
      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->toolbar_favorite), TRUE);
      gtk_style_context_add_class (context, "documents-favorite");
    }
  else
    {
      favorite_label = g_strdup (_("Add to favorites"));
      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->toolbar_favorite), FALSE);
      gtk_style_context_remove_class (context, "documents-favorite");
    }

  gtk_widget_reset_style (priv->toolbar_favorite);
  gtk_widget_set_tooltip_text (priv->toolbar_favorite, favorite_label);
  g_free (favorite_label);

  gtk_widget_set_sensitive (priv->toolbar_collection, show_collection);
  gtk_widget_set_sensitive (priv->toolbar_print, show_print);
  gtk_widget_set_sensitive (priv->toolbar_properties, show_properties);
  gtk_widget_set_sensitive (priv->toolbar_trash, show_trash);
  gtk_widget_set_sensitive (priv->toolbar_open, show_open);
  gtk_widget_set_sensitive (priv->toolbar_favorite, show_favorite);

  priv->inside_refresh = FALSE;
}