static void
photos_properties_dialog_modified_updated (PhotosPropertiesDialog *self, gboolean is_edited)
{
  GtkStyleContext *context;

  if (is_edited)
    {
      gtk_label_set_text (GTK_LABEL (self->modified_data), _("Edited in Photos"));
      context = gtk_widget_get_style_context (self->modified_data);
      gtk_style_context_remove_class (context, "photos-fade-out");
      gtk_style_context_add_class (context, "photos-fade-in");
      gtk_widget_show (self->modified_data);

      context = gtk_widget_get_style_context (self->revert_button);
      gtk_style_context_remove_class (context, "photos-fade-out");
      gtk_style_context_add_class (context, "photos-fade-in");
      gtk_widget_show (self->revert_button);
    }
  else
    {
      gtk_label_set_text (GTK_LABEL (self->modified_data), _("Untouched"));
      context = gtk_widget_get_style_context (self->modified_data);
      gtk_style_context_remove_class (context, "photos-fade-out");
      gtk_style_context_add_class (context, "photos-fade-in");
      gtk_widget_show (self->modified_data);

      context = gtk_widget_get_style_context (self->revert_button);
      gtk_style_context_remove_class (context, "photos-fade-in");
      gtk_style_context_add_class (context, "photos-fade-out");
    }
}
Esempio n. 2
0
static gboolean
draw_cb_frame (GtkWidget *widget, cairo_t *cr)
{
  GtkStyleContext *context;

  context = gtk_widget_get_style_context (widget);

  gtk_style_context_save (context);

  gtk_style_context_add_class (context, "frame1");
  gtk_style_context_set_junction_sides (context, 0);
  gtk_render_frame (context, cr, 12, 12, 50, 50);
  gtk_style_context_remove_class (context, "frame1");

  gtk_style_context_add_class (context, "frame2");
  gtk_render_frame (context, cr, 74, 12, 50, 50);
  gtk_style_context_remove_class (context, "frame2");

  gtk_style_context_add_class (context, "frame3");
  gtk_style_context_set_junction_sides (context, GTK_JUNCTION_RIGHT);
  gtk_render_frame (context, cr, 12, 74, 56, 50);
  gtk_style_context_set_junction_sides (context, GTK_JUNCTION_LEFT);
  gtk_render_frame (context, cr, 68, 74, 56, 50);
  gtk_style_context_remove_class (context, "frame3");

  gtk_style_context_restore (context);

  return TRUE;
}
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");
}
Esempio n. 4
0
static void
photos_import_dialog_show_add_existing (PhotosImportDialog *self, gboolean show)
{
  GtkStyleContext *context;
  const gchar *class_name;
  const gchar *invert_class_name;

  class_name = show ? "photos-fade-in" : "photos-fade-out";
  invert_class_name = !show ? "photos-fade-in" : "photos-fade-out";

  gtk_widget_set_sensitive (self->create_new_button, show);
  gtk_widget_show (self->create_new_button);
  context = gtk_widget_get_style_context (self->create_new_button);
  gtk_style_context_remove_class (context, invert_class_name);
  gtk_style_context_add_class (context, class_name);

  gtk_widget_set_sensitive (self->add_existing_button, show);
  gtk_widget_show (self->add_existing_button);
  context = gtk_widget_get_style_context (self->add_existing_button);
  gtk_style_context_remove_class (context, invert_class_name);
  gtk_style_context_add_class (context, class_name);

  gtk_widget_set_sensitive (self->add_existing_label, show);
  gtk_widget_show (self->add_existing_label);
  context = gtk_widget_get_style_context (self->add_existing_label);
  gtk_style_context_remove_class (context, invert_class_name);
  gtk_style_context_add_class (context, class_name);

  gtk_widget_set_sensitive (self->add_existing_collection_name_button, show);
  gtk_widget_show (self->add_existing_collection_name_button);
  context = gtk_widget_get_style_context (self->add_existing_collection_name_button);
  gtk_style_context_remove_class (context, invert_class_name);
  gtk_style_context_add_class (context, class_name);
}
Esempio n. 5
0
void
pnl_tab_strip_set_edge (PnlTabStrip     *self,
                        GtkPositionType  edge)
{
  PnlTabStripPrivate *priv = pnl_tab_strip_get_instance_private (self);

  g_return_if_fail (PNL_IS_TAB_STRIP (self));
  g_return_if_fail (edge >= 0);
  g_return_if_fail (edge <= 3);

  if (priv->edge != edge)
    {
      GtkStyleContext *style_context;
      const gchar *class_name = NULL;

      priv->edge = edge;

      gtk_container_foreach (GTK_CONTAINER (self),
                             pnl_tab_strip_update_edge,
                             GINT_TO_POINTER (edge));

      style_context = gtk_widget_get_style_context (GTK_WIDGET (self));

      gtk_style_context_remove_class (style_context, "left-edge");
      gtk_style_context_remove_class (style_context, "top-edge");
      gtk_style_context_remove_class (style_context, "right-edge");
      gtk_style_context_remove_class (style_context, "bottom-edge");

      switch (edge)
        {
        case GTK_POS_LEFT:
          class_name = "left";
          break;

        case GTK_POS_RIGHT:
          class_name = "right";
          break;

        case GTK_POS_TOP:
          class_name = "top";
          break;

        case GTK_POS_BOTTOM:
          class_name = "bottom";
          break;

        default:
          g_assert_not_reached ();
        }

      gtk_style_context_add_class (style_context, class_name);

      g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_EDGE]);
    }
}
Esempio n. 6
0
static void
update_color (GcalEventWidget *self)
{
  GtkStyleContext *context;
  GdkRGBA *color;
  GQuark color_id;
  gchar *color_str;
  gchar *css_class;
  GDateTime *now;
  gint date_compare;

  context = gtk_widget_get_style_context (GTK_WIDGET (self));
  color = gcal_event_get_color (self->event);
  now = g_date_time_new_now_local ();
  date_compare = g_date_time_compare (self->dt_end, now);

  /* Fades out an event that's earlier than the current date */
  gtk_widget_set_opacity (GTK_WIDGET (self), date_compare < 0 ? 0.6 : 1.0);

  /* Remove the old style class */
  if (self->css_class)
    {
      gtk_style_context_remove_class (context, self->css_class);
      g_clear_pointer (&self->css_class, g_free);
    }

  color_str = gdk_rgba_to_string (color);
  color_id = g_quark_from_string (color_str);
  css_class = g_strdup_printf ("color-%d", color_id);

  gtk_style_context_add_class (context, css_class);

  if (INTENSITY (color) > 0.5)
    {
      gtk_style_context_remove_class (context, "color-dark");
      gtk_style_context_add_class (context, "color-light");
    }
  else
    {
      gtk_style_context_remove_class (context, "color-light");
      gtk_style_context_add_class (context, "color-dark");
    }

  /* Keep the current style around, so we can remove it later */
  self->css_class = css_class;

  g_clear_pointer (&now, g_date_time_unref);
  g_free (color_str);
}
Esempio n. 7
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);
}
Esempio n. 8
0
/*
 * create_page:
 * @child: the #CheeseWidget to pack into the container
 * @button: the #GtkButton for taking a photo
 *
 * Create the widgets for the #CheeseAvatarWidget and pack them into a
 * container.
 *
 * Returns: a #GtkBox containing the individual #CheeseAvatarWidget widgets
 */
static GtkWidget *
create_page (GtkWidget *child,
             GtkWidget *button)
{
    GtkWidget *vgrid, *bar;
    GtkStyleContext *context;

    vgrid = gtk_grid_new ();
    gtk_grid_attach (GTK_GRID (vgrid),
                     child, 0, 0, 1, 1);
    gtk_widget_set_hexpand (child, TRUE);
    gtk_widget_set_vexpand (child, TRUE);

    bar = gtk_header_bar_new ();
    context = gtk_widget_get_style_context (GTK_WIDGET (bar));
    gtk_style_context_remove_class (context, "header-bar");
    gtk_style_context_add_class (context, "inline-toolbar");
    gtk_style_context_add_class (context, "toolbar");
    gtk_style_context_add_class (context, GTK_STYLE_CLASS_HORIZONTAL);

    g_object_set (G_OBJECT (button), "margin-top", 6, "margin-bottom", 6, NULL);
    gtk_header_bar_set_custom_title (GTK_HEADER_BAR (bar), button);
    gtk_grid_attach (GTK_GRID (vgrid),
                     bar, 0, 1, 1, 1);

    return vgrid;
}
Esempio n. 9
0
static void
egg_state_unapply (EggStateMachine *self,
                   EggState        *state)
{
  GHashTableIter iter;
  gpointer key;
  gpointer value;
  gsize i;

  g_assert (EGG_IS_STATE_MACHINE (self));
  g_assert (state != NULL);

  g_hash_table_iter_init (&iter, state->bindings);
  while (g_hash_table_iter_next (&iter, &key, &value))
    egg_binding_group_set_source (value, NULL);

  g_hash_table_iter_init (&iter, state->signals);
  while (g_hash_table_iter_next (&iter, &key, &value))
    egg_signal_group_set_target (value, NULL);

  for (i = 0; i < state->styles->len; i++)
    {
      EggStateStyle *style;
      GtkStyleContext *style_context;

      style = g_ptr_array_index (state->styles, i);
      style_context = gtk_widget_get_style_context (GTK_WIDGET (style->widget));
      gtk_style_context_remove_class (style_context, style->name);
    }
}
Esempio n. 10
0
/**
 * @brief
 * @param ui The GstSwitchUI instance.
 * @param port The audio port number.
 * @memberof GstSwitchUI
 */
static void
gst_switch_ui_set_audio_port (GstSwitchUI * ui, gint port)
{
  GList *v = NULL;

  GST_SWITCH_UI_LOCK_AUDIO (ui);
  ui->audio_port = port;

  v = gtk_container_get_children (GTK_CONTAINER (ui->preview_box));
  for (; v; v = g_list_next (v)) {
    GtkWidget *frame = GTK_WIDGET (v->data);
    GtkStyleContext *style = gtk_widget_get_style_context (frame);
    gpointer data = g_object_get_data (G_OBJECT (frame), "audio-visual");
    if (data) {
      GstAudioVisual *visual = GST_AUDIO_VISUAL (data);
      if ((ui->audio_port == visual->port && !visual->active) ||
          ( /*ui->audio_port != visual->port && */ visual->active)) {
        gtk_style_context_remove_class (style, "active_audio_frame");
        visual = gst_switch_ui_renew_audio_visual (ui, frame, visual);
        if (visual->active) {
          gtk_style_context_add_class (style, "active_audio_frame");
          ui->audio = visual;
        }
      }
    }
  }
  GST_SWITCH_UI_UNLOCK_AUDIO (ui);
}
Esempio n. 11
0
/**
 * gtk_button_set_label:
 * @button: a #GtkButton
 * @label: a string
 *
 * Sets the text of the label of the button to @label.
 *
 * This will also clear any previously set labels.
 */
void
gtk_button_set_label (GtkButton   *button,
                      const gchar *label)
{
  GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
  GtkWidget *child;
  GtkStyleContext *context;

  g_return_if_fail (GTK_IS_BUTTON (button));

  context = gtk_widget_get_style_context (GTK_WIDGET (button));

  child = gtk_bin_get_child (GTK_BIN (button));

  if (priv->child_type != LABEL_CHILD || child == NULL)
    {
      if (child != NULL)
        gtk_container_remove (GTK_CONTAINER (button), child);

      child = gtk_label_new (NULL);
      if (priv->use_underline)
        {
          gtk_label_set_use_underline (GTK_LABEL (child), priv->use_underline);
          gtk_label_set_mnemonic_widget (GTK_LABEL (child), GTK_WIDGET (button));
        }
      gtk_widget_show (child);
      gtk_container_add (GTK_CONTAINER (button), child);
      gtk_style_context_remove_class (context, "image-button");
      gtk_style_context_add_class (context, "text-button");
    }

  gtk_label_set_label (GTK_LABEL (child), label);
  gtk_button_set_child_type (button, LABEL_CHILD);
  g_object_notify_by_pspec (G_OBJECT (button), props[PROP_LABEL]);
}
Esempio n. 12
0
void
egg_empty_state_set_icon_name (EggEmptyState *self,
                               const gchar   *icon_name)
{
  EggEmptyStatePrivate *priv = egg_empty_state_get_instance_private (self);

  g_return_if_fail (EGG_IS_EMPTY_STATE (self));

  if (g_strcmp0 (icon_name, egg_empty_state_get_icon_name (self)) != 0)
    {
      GtkStyleContext *context;

      g_object_set (priv->image,
                    "icon-name", icon_name,
                    NULL);

      context = gtk_widget_get_style_context (GTK_WIDGET (priv->image));

      if (icon_name != NULL && g_str_has_suffix (icon_name, "-symbolic"))
        gtk_style_context_add_class (context, "dim-label");
      else
        gtk_style_context_remove_class (context, "dim-label");

      g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_ICON_NAME]);
    }
}
Esempio n. 13
0
/**
 * gtk_button_set_icon_name:
 * @button: A #GtkButton
 * @icon_name: A icon name
 *
 * Adds a #GtkImage with the given icon name as a child. The icon will be
 * of size %GTK_ICON_SIZE_BUTTON. If @button already contains a child widget,
 * that child widget will be removed and replaced with the image.
 *
 * Since: 3.90
 */
void
gtk_button_set_icon_name (GtkButton  *button,
                          const char *icon_name)
{
  GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
  GtkWidget *child;
  GtkStyleContext *context;

  g_return_if_fail (GTK_IS_BUTTON (button));
  g_return_if_fail (icon_name != NULL);

  child = gtk_bin_get_child (GTK_BIN (button));
  context = gtk_widget_get_style_context (GTK_WIDGET (button));

  if (priv->child_type != ICON_CHILD || child == NULL)
    {
      if (child != NULL)
        gtk_container_remove (GTK_CONTAINER (button), child);

      child = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON);
      gtk_widget_show (child);
      gtk_container_add (GTK_CONTAINER (button), child);
      gtk_style_context_remove_class (context, "text-button");
      gtk_style_context_add_class (context, "image-button");
    }
  else
    {
      gtk_image_set_from_icon_name (GTK_IMAGE (child), icon_name, GTK_ICON_SIZE_BUTTON);
    }

  gtk_button_set_child_type (button, ICON_CHILD);
  g_object_notify_by_pspec (G_OBJECT (button), props[PROP_ICON_NAME]);
}
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);
}
static void
setup_search (GtkAppChooserDialog *self)
{
  gboolean use_header;

  g_object_get (self, "use-header-bar", &use_header, NULL);
  if (use_header)
    {
      GtkWidget *button;
      GtkWidget *image;
      GtkWidget *header;

      button = gtk_toggle_button_new ();
      gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
      image = gtk_image_new_from_icon_name ("edit-find-symbolic", GTK_ICON_SIZE_MENU);
      gtk_widget_show (image);
      gtk_container_add (GTK_CONTAINER (button), image);
      gtk_style_context_add_class (gtk_widget_get_style_context (button), "image-button");
      gtk_style_context_remove_class (gtk_widget_get_style_context (button), "text-button");
      gtk_widget_show (button);

      header = gtk_dialog_get_header_bar (GTK_DIALOG (self));
      gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);

      g_object_bind_property (button, "active",
                              self->priv->search_bar, "search-mode-enabled",
                              G_BINDING_BIDIRECTIONAL);
      g_object_bind_property (self->priv->search_entry, "sensitive",
                              button, "sensitive",
                              G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
    }
}
Esempio n. 16
0
JNIEXPORT void JNICALL
Java_org_gnome_gtk_GtkStyleContext_gtk_1style_1context_1remove_1class
(
	JNIEnv* env,
	jclass cls,
	jlong _self,
	jstring _className
)
{
	GtkStyleContext* self;
	const gchar* className;

	// convert parameter self
	self = (GtkStyleContext*) _self;

	// convert parameter className
	className = (const gchar*) bindings_java_getString(env, _className);
	if (className == NULL) {
		return; // Java Exception already thrown
	}

	// call function
	gtk_style_context_remove_class(self, className);

	// cleanup parameter self

	// cleanup parameter className
	bindings_java_releaseString(className);
}
Esempio n. 17
0
static void
gtk_level_bar_update_mode_style_classes (GtkLevelBar *self)
{
  GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET (self));

  if (self->priv->bar_mode == GTK_LEVEL_BAR_MODE_CONTINUOUS)
    {
      gtk_style_context_remove_class (context, STYLE_CLASS_INDICATOR_DISCRETE);
      gtk_style_context_add_class (context, STYLE_CLASS_INDICATOR_CONTINUOUS);
    }
  else if (self->priv->bar_mode == GTK_LEVEL_BAR_MODE_DISCRETE)
    {
      gtk_style_context_remove_class (context, STYLE_CLASS_INDICATOR_CONTINUOUS);
      gtk_style_context_add_class (context, STYLE_CLASS_INDICATOR_DISCRETE);
    }
}
static void
remove_operations_button_attention_style (NautilusToolbar *self)
{
        GtkStyleContext *style_context;

        style_context = gtk_widget_get_style_context (self->priv->operations_button);
        gtk_style_context_remove_class (style_context,
                                        "nautilus-operations-button-needs-attention");
}
Esempio n. 19
0
void
pragha_toolbar_set_style (PraghaToolbar *toolbar, gboolean gnome_style)
{
	GtkStyleContext *context;
	context = gtk_widget_get_style_context (GTK_WIDGET(toolbar));

	if (gnome_style) {
		gtk_style_context_remove_class (context, GTK_STYLE_CLASS_TOOLBAR);
		gtk_style_context_remove_class (context, GTK_STYLE_CLASS_PRIMARY_TOOLBAR);
		gtk_style_context_add_class (context, "header-bar");
	}
	else {
		gtk_style_context_remove_class (context, "header-bar");
		gtk_style_context_add_class (context, GTK_STYLE_CLASS_TOOLBAR);
		gtk_style_context_add_class (context, GTK_STYLE_CLASS_PRIMARY_TOOLBAR);
	}
	gtk_header_bar_set_show_close_button(GTK_HEADER_BAR(toolbar), gnome_style);
}
Esempio n. 20
0
static void
_gtk_menu_button_set_style_for_header_bar (GtkWidget *button)
{
	GtkStyleContext *context;

	gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
	context = gtk_widget_get_style_context (button);
	gtk_style_context_add_class (context, "image-button");
	gtk_style_context_remove_class (context, "text-button");
}
Esempio n. 21
0
static void
visible_cb (GtkWidget *menu, GParamSpec *pspec, GtkWidget *button)
{
  if (gtk_widget_get_visible (menu))
    gtk_style_context_add_class (gtk_widget_get_style_context (button),
                                 "active-menu");
  else
    gtk_style_context_remove_class (gtk_widget_get_style_context (button),
                                    "active-menu");
}
Esempio n. 22
0
static void
rebuild_child (GtkWidget   *self,
               const gchar *icon_name,
               const gchar *title)
{
  GtkStyleContext *context;
  GtkWidget *button_child;

  gtk_widget_set_valign (GTK_WIDGET (self), GTK_ALIGN_CENTER);

  button_child = gtk_bin_get_child (GTK_BIN (self));
  if (button_child != NULL)
    gtk_widget_destroy (button_child);

  button_child = NULL;
  context = gtk_widget_get_style_context (GTK_WIDGET (self));

  if (icon_name != NULL)
    {
      button_child = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
      if (title != NULL)
        gtk_widget_set_tooltip_text (GTK_WIDGET (self), title);

      gtk_style_context_remove_class (context, "text-button");
      gtk_style_context_add_class (context, "image-button");
    }
  else if (title != NULL)
    {
      button_child = gtk_label_new (title);

      gtk_widget_set_tooltip_text (GTK_WIDGET (self), NULL);

      gtk_style_context_remove_class (context, "image-button");
      gtk_style_context_add_class (context, "text-button");
    }

  if (button_child)
    {
      gtk_widget_show_all (button_child);
      gtk_container_add (GTK_CONTAINER (self), button_child);
    }
}
Esempio n. 23
0
void
gs_progress_button_set_show_progress (GsProgressButton *button, gboolean show_progress)
{
	GtkStyleContext *context;

	context = gtk_widget_get_style_context (GTK_WIDGET (button));
	if (show_progress)
		gtk_style_context_add_class (context, "install-progress");
	else
		gtk_style_context_remove_class (context, "install-progress");
}
Esempio n. 24
0
static gboolean
remove_operations_button_attention_style (NautilusToolbar *self)
{
        GtkStyleContext *style_context;

        style_context = gtk_widget_get_style_context (self->priv->operations_button);
        gtk_style_context_remove_class (style_context,
                                        "suggested-action");
        self->priv->operations_button_attention_timeout_id = 0;

        return G_SOURCE_REMOVE;
}
Esempio n. 25
0
static void
on_record_button_toggled (GtkToggleButton *button,
                          gpointer         user_data)
{
  GtkStyleContext *context;

  context = gtk_widget_get_style_context (GTK_WIDGET (button));
  if (gtk_toggle_button_get_active (button))
    gtk_style_context_remove_class (context, "destructive-action");
  else
    gtk_style_context_add_class (context, "destructive-action");
}
Esempio n. 26
0
void
_gtk_text_handle_set_mode (GtkTextHandle     *handle,
                           GtkTextHandleMode  mode)
{
  GtkTextHandlePrivate *priv;
  HandleWindow *start, *end;

  g_return_if_fail (GTK_IS_TEXT_HANDLE (handle));

  priv = handle->priv;

  if (priv->mode == mode)
    return;

  priv->mode = mode;
  start = &priv->windows[GTK_TEXT_HANDLE_POSITION_SELECTION_START];
  end = &priv->windows[GTK_TEXT_HANDLE_POSITION_SELECTION_END];

  switch (mode)
    {
    case GTK_TEXT_HANDLE_MODE_CURSOR:
      start->mode_visible = FALSE;
      /* end = cursor */
      end->mode_visible = TRUE;
      break;
    case GTK_TEXT_HANDLE_MODE_SELECTION:
      start->mode_visible = TRUE;
      end->mode_visible = TRUE;
      break;
    case GTK_TEXT_HANDLE_MODE_NONE:
    default:
      start->mode_visible = FALSE;
      end->mode_visible = FALSE;
      break;
    }

  if (end->widget)
    {
      if (mode == GTK_TEXT_HANDLE_MODE_CURSOR)
        gtk_style_context_add_class (gtk_widget_get_style_context (end->widget), GTK_STYLE_CLASS_INSERTION_CURSOR);
      else
        gtk_style_context_remove_class (gtk_widget_get_style_context (end->widget), GTK_STYLE_CLASS_INSERTION_CURSOR);
    }

  _gtk_text_handle_update (handle, GTK_TEXT_HANDLE_POSITION_SELECTION_START);
  _gtk_text_handle_update (handle, GTK_TEXT_HANDLE_POSITION_SELECTION_END);

  if (start->widget && start->mode_visible)
    gtk_widget_queue_draw (start->widget);
  if (end->widget && end->mode_visible)
    gtk_widget_queue_draw (end->widget);
}
void gldi_dialog_reload (CairoDialog *pDialog)
{
	// re-set the GTK style class (global style may have changed between system / custom)
	GtkStyleContext *ctx = gtk_widget_get_style_context (pDialog->pWidgetLayout);

	gtk_style_context_remove_class (ctx, GTK_STYLE_CLASS_MENUITEM);
	gtk_style_context_remove_class (ctx, "gldimenuitem");

	gtk_style_context_add_class (ctx, myDialogsParam.bUseDefaultColors && myStyleParam.bUseSystemColors ? GTK_STYLE_CLASS_MENUITEM : "gldimenuitem");

	// reload the text buffer (color or font may have changed)
	if (pDialog->cText != NULL)
	{
		gchar *cText = pDialog->cText;
		pDialog->cText = NULL;
		gldi_dialog_set_message (pDialog, cText);
		g_free (cText);
	}

	// reload sizes (radius or linewidth may have changed)
	_compute_dialog_sizes (pDialog);
}
Esempio n. 28
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");
}
Esempio n. 29
0
static void
ide_editor_frame_update_search_position_label (IdeEditorFrame *self)
{
  GtkSourceSearchContext *search_context;
  GtkStyleContext *context;
  GtkTextBuffer *buffer;
  GtkTextIter begin;
  GtkTextIter end;
  const gchar *search_text;
  gchar *text;
  gint count;
  gint pos;

  g_return_if_fail (IDE_IS_EDITOR_FRAME (self));

  buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (self->source_view));
  search_context = ide_source_view_get_search_context (self->source_view);
  gtk_text_buffer_get_selection_bounds (buffer, &begin, &end);
  pos = gtk_source_search_context_get_occurrence_position (search_context, &begin, &end);
  count = gtk_source_search_context_get_occurrences_count (search_context);

  if ((pos == -1) || (count == -1))
    {
      /*
       * We are not yet done scanning the buffer.
       * We will be updated when we know more, so just hide it for now.
       */
      ide_editor_frame_set_position_label (self, NULL);
      return;
    }

  context = gtk_widget_get_style_context (GTK_WIDGET (self->search_entry));
  search_text = gtk_entry_get_text (GTK_ENTRY (self->search_entry));

  /* We use our own error class because we don't want to colide with styling
   * from GTK+ themes.
   */
  if ((count == 0) && !ide_str_empty0 (search_text))
    gtk_style_context_add_class (context, "search-missing");
  else
    gtk_style_context_remove_class (context, "search-missing");

  text = g_strdup_printf (_("%u of %u"), pos, count);
  ide_editor_frame_set_position_label (self, text);
  g_free (text);
}
Esempio n. 30
0
void budgie_media_label_set_playing(BudgieMediaLabel *self,
                                    gboolean playing)
{
        GtkStyleContext *style;

        style = gtk_widget_get_style_context(self->display);
        if (playing) {
                gtk_style_context_remove_class(style, "info-label");
                g_object_set(self->display, "margin-left", 15, NULL);
        } else {
                gtk_style_context_add_class(style, "info-label");
                g_object_set(self->display, "margin-left", 25, NULL);
        }

        gtk_widget_set_visible(self->play_sign, playing);
        self->playing = playing;
}