~ayatana-scrollbar-team/overlay-scrollbar/trunk

« back to all changes in this revision

Viewing changes to os/os-bar.c

  • Committer: CI Train Bot
  • Author(s): Iain Lane
  • Date: 2015-06-04 09:44:43 UTC
  • mfrom: (391.1.14 overlay-scrollbar)
  • Revision ID: ci-train-bot@canonical.com-20150604094443-3m60mjecozbjb5cd
Drop overlay-scrollbar-gtk3 - gtk 3.16 has a replacement
Approved by: Lars Uebernickel, PS Jenkins bot

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
static void
63
63
draw_bar (OsBar *bar)
64
64
{
65
 
#ifdef USE_GTK3
66
 
  GdkRGBA c1, c2, color;
67
 
  GtkStyleContext *style_context;
68
 
#else
69
65
  GdkColor color;
70
66
  GtkStyle *style;
71
 
#endif
72
67
  OsBarPrivate *priv;
73
68
  gfloat weight;
74
69
 
76
71
 
77
72
  weight = priv->weight;
78
73
 
79
 
#ifdef USE_GTK3
80
 
  style_context = gtk_widget_get_style_context (priv->parent);
81
 
 
82
 
  if (priv->active == FALSE)
83
 
    {
84
 
      gtk_style_context_get_background_color (style_context, GTK_STATE_FLAG_INSENSITIVE, &c1);
85
 
      gtk_style_context_get_background_color (style_context, GTK_STATE_FLAG_SELECTED, &c2);
86
 
    }
87
 
  else
88
 
    {
89
 
      gtk_style_context_get_background_color (style_context, GTK_STATE_FLAG_SELECTED, &c1);
90
 
      gtk_style_context_get_background_color (style_context, GTK_STATE_FLAG_INSENSITIVE, &c2);
91
 
    }
92
 
 
93
 
  color.red   = weight * c1.red   + (1.0 - weight) * c2.red;
94
 
  color.green = weight * c1.green + (1.0 - weight) * c2.green;
95
 
  color.blue  = weight * c1.blue  + (1.0 - weight) * c2.blue;
96
 
  color.alpha = 1.0;
97
 
 
98
 
  gdk_window_set_background_rgba (priv->bar_window, &color);
99
 
#else
100
74
  style = gtk_widget_get_style (priv->parent);
101
75
 
102
76
  color = style->bg[GTK_STATE_SELECTED];
104
78
  gdk_colormap_alloc_color (gdk_drawable_get_colormap (priv->bar_window), &color, FALSE, TRUE);
105
79
 
106
80
  gdk_window_set_background (priv->bar_window, &color);
107
 
#endif
108
81
 
109
82
  gdk_window_invalidate_rect (gtk_widget_get_window (priv->parent), &priv->allocation, TRUE);
110
83
}
113
86
static void
114
87
draw_tail (OsBar *bar)
115
88
{
116
 
#ifdef USE_GTK3
117
 
  GdkRGBA color;
118
 
  GtkStyleContext *style_context;
119
 
#else
120
89
  GdkColor color;
121
90
  GtkStyle *style;
122
 
#endif
123
91
  OsBarPrivate *priv;
124
92
 
125
93
  priv = bar->priv;
126
94
 
127
 
#ifdef USE_GTK3
128
 
  style_context = gtk_widget_get_style_context (priv->parent);
129
 
 
130
 
  gtk_style_context_get_background_color (style_context, GTK_STATE_FLAG_ACTIVE, &color);
131
 
 
132
 
  color.alpha = 1.0;
133
 
 
134
 
  gdk_window_set_background_rgba (priv->tail_window, &color);
135
 
#else
136
95
  style = gtk_widget_get_style (priv->parent);
137
96
 
138
97
  color = style->bg[GTK_STATE_ACTIVE];
140
99
  gdk_colormap_alloc_color (gdk_drawable_get_colormap (priv->tail_window), &color, FALSE, TRUE);
141
100
 
142
101
  gdk_window_set_background (priv->tail_window, &color);
143
 
#endif
144
102
 
145
103
  gdk_window_invalidate_rect (gtk_widget_get_window (priv->parent), &priv->allocation, TRUE);
146
104
}
222
180
                                    gint                 offset_x,
223
181
                                    gint                 offset_y)
224
182
{
225
 
#ifdef USE_GTK3
226
 
 
227
 
  cairo_region_t * shape_region = cairo_region_create_rectangle (shape_rect);
228
 
  gdk_window_shape_combine_region (window, shape_region, offset_x, offset_y);
229
 
  cairo_region_destroy (shape_region);
230
 
 
231
 
#else
232
 
 
233
183
  GdkRegion * shape_region = gdk_region_rectangle (shape_rect);
234
184
  gdk_window_shape_combine_region (window, shape_region, offset_x, offset_y);
235
185
  gdk_region_destroy (shape_region);
236
 
 
237
 
#endif
238
186
}
239
187
 
240
188
/* Callback called by the retract-tail animation. */
545
493
}
546
494
 
547
495
/**
548
 
 * os_bar_set_active:
549
 
 * @bar: a #OsBar
550
 
 * @active: whether is active or not
551
 
 * @animate: whether animate it or not
552
 
 *
553
 
 * Changes the activity state of @bar.
554
 
 **/
555
 
void
556
 
os_bar_set_active (OsBar   *bar,
557
 
                   gboolean active,
558
 
                   gboolean animate)
559
 
{
560
 
#ifdef USE_GTK3
561
 
  OsBarPrivate *priv;
562
 
 
563
 
  g_return_if_fail (OS_IS_BAR (bar));
564
 
 
565
 
  priv = bar->priv;
566
 
 
567
 
  /* Set the state and draw even if there's a state_animation running, that is
568
 
   * (!animate && os_animation_is_running (priv->state_animation)). */
569
 
  if ((priv->active != active) ||
570
 
      (!animate && os_animation_is_running (priv->state_animation)))
571
 
    {
572
 
      gboolean visible;
573
 
 
574
 
      priv->active = active;
575
 
 
576
 
      if (priv->parent == NULL)
577
 
        return;
578
 
 
579
 
      visible = gdk_window_is_visible (priv->bar_window);
580
 
 
581
 
      if (visible)
582
 
        os_animation_stop (priv->state_animation, NULL);
583
 
 
584
 
      if (visible && animate)
585
 
        {
586
 
          os_animation_set_duration (priv->state_animation, priv->active ? DURATION_FADE_IN :
587
 
                                                                           DURATION_FADE_OUT);
588
 
          os_animation_start (priv->state_animation);
589
 
        }
590
 
 
591
 
      if (!visible || !animate)
592
 
        {
593
 
          priv->weight = 1.0f;
594
 
 
595
 
          draw_bar (bar);
596
 
        }
597
 
    }
598
 
#endif
599
 
}
600
 
 
601
 
/**
602
496
 * os_bar_set_detached:
603
497
 * @bar: a #OsBar
604
498
 * @detached: whether the bar is detached or not
702
596
  attributes.wclass = GDK_INPUT_OUTPUT;
703
597
  attributes.window_type = GDK_WINDOW_CHILD;
704
598
  attributes.visual = gtk_widget_get_visual (priv->parent);
705
 
#ifndef USE_GTK3
706
599
  attributes.colormap = gtk_widget_get_colormap (priv->parent);
707
 
#endif
708
600
 
709
601
  /* tail_window. */
710
602
  priv->tail_window = gdk_window_new (gtk_widget_get_window (priv->parent),
711
603
                                            &attributes,
712
 
#ifdef USE_GTK3
713
 
                                            GDK_WA_VISUAL);
714
 
#else
715
604
                                            GDK_WA_VISUAL | GDK_WA_COLORMAP);
716
 
#endif
717
 
 
718
 
#ifdef USE_GTK3
719
 
  gdk_window_ensure_native (priv->tail_window);
720
 
  gtk_widget_register_window (priv->parent, priv->tail_window);
721
 
#endif
722
605
 
723
606
  g_object_ref_sink (priv->tail_window);
724
607
 
727
610
 
728
611
  /* FIXME(Cimi) maybe this is not required with 0 as event mask. */
729
612
  gdk_window_input_shape_combine_region (priv->tail_window,
730
 
#ifdef USE_GTK3
731
 
                                         cairo_region_create (),
732
 
#else
733
613
                                         gdk_region_new (),
734
 
#endif
735
614
                                         0, 0);
736
615
 
737
616
  /* bar_window. */
738
617
  priv->bar_window = gdk_window_new (gtk_widget_get_window (priv->parent),
739
618
                                     &attributes,
740
 
#ifdef USE_GTK3
741
 
                                     GDK_WA_VISUAL);
742
 
#else
743
619
                                     GDK_WA_VISUAL | GDK_WA_COLORMAP);
744
 
#endif 
745
 
 
746
 
#ifdef USE_GTK3
747
 
  gdk_window_ensure_native (priv->bar_window);
748
 
  gtk_widget_register_window (priv->parent, priv->bar_window);
749
 
#endif
750
620
 
751
621
  g_object_ref_sink (priv->bar_window);
752
622
 
755
625
 
756
626
  /* FIXME(Cimi) maybe this is not required with 0 as event mask. */
757
627
  gdk_window_input_shape_combine_region (priv->bar_window,
758
 
#ifdef USE_GTK3
759
 
                                         cairo_region_create (),
760
 
#else
761
628
                                         gdk_region_new (),
762
 
#endif
763
629
                                         0, 0);
764
630
 
765
631
  mask_tail (bar);