diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/idoapplicationmenuitem.c | 2 | ||||
-rw-r--r-- | src/idobasicmenuitem.c | 21 | ||||
-rw-r--r-- | src/idomediaplayermenuitem.c | 8 | ||||
-rw-r--r-- | src/idomessagedialog.c | 12 | ||||
-rw-r--r-- | src/idoplaybackmenuitem.c | 105 | ||||
-rw-r--r-- | src/idosourcemenuitem.c | 7 | ||||
-rw-r--r-- | src/idousermenuitem.c | 10 |
7 files changed, 73 insertions, 92 deletions
diff --git a/src/idoapplicationmenuitem.c b/src/idoapplicationmenuitem.c index 9ca6d87..ba177bd 100644 --- a/src/idoapplicationmenuitem.c +++ b/src/idoapplicationmenuitem.c @@ -45,7 +45,7 @@ ido_application_menu_item_constructed (GObject *object) item->icon = g_object_ref (gtk_image_new ()); gtk_image_set_pixel_size (GTK_IMAGE (item->icon), icon_height); - gtk_widget_set_margin_right (item->icon, 6); + gtk_widget_set_margin_end(item->icon, 6); item->label = g_object_ref (gtk_label_new ("")); diff --git a/src/idobasicmenuitem.c b/src/idobasicmenuitem.c index cf57e7c..ab3ce87 100644 --- a/src/idobasicmenuitem.c +++ b/src/idobasicmenuitem.c @@ -4,16 +4,16 @@ * Authors: * Charles Kerr <charles.kerr@canonical.com> * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3, as published + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranties of - * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along + * You should have received a copy of the GNU General Public License along * with this program. If not, see <http://www.gnu.org/licenses/>. */ @@ -230,11 +230,14 @@ ido_basic_menu_item_init (IdoBasicMenuItem *self) IdoBasicMenuItemPrivate *p = ido_basic_menu_item_get_instance_private(self); p->image = gtk_image_new (); - gtk_misc_set_alignment(GTK_MISC(p->image), 0.0, 0.0); + gtk_widget_set_halign(p->image, GTK_ALIGN_START); + gtk_widget_set_valign(p->image, GTK_ALIGN_START); p->label = gtk_label_new (""); - gtk_misc_set_alignment (GTK_MISC(p->label), 0.0, 0.5); + gtk_widget_set_halign(p->label, GTK_ALIGN_START); + gtk_widget_set_valign(p->label, GTK_ALIGN_CENTER); p->secondary_label = gtk_label_new (""); - gtk_misc_set_alignment (GTK_MISC(p->secondary_label), 1.0, 0.5); + gtk_widget_set_halign(p->secondary_label, GTK_ALIGN_END); + gtk_widget_set_valign(p->secondary_label, GTK_ALIGN_CENTER); w = gtk_grid_new (); grid = GTK_GRID (w); diff --git a/src/idomediaplayermenuitem.c b/src/idomediaplayermenuitem.c index 232ad0e..ef1b2aa 100644 --- a/src/idomediaplayermenuitem.c +++ b/src/idomediaplayermenuitem.c @@ -120,8 +120,8 @@ track_info_label_new () label = gtk_label_new (NULL); gtk_label_set_width_chars (GTK_LABEL (label), 25); gtk_label_set_max_width_chars (GTK_LABEL (label), 25); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_widget_set_halign (label, GTK_ALIGN_START); + gtk_widget_set_halign(label, GTK_ALIGN_START); + gtk_widget_set_valign(label, GTK_ALIGN_CENTER); gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_MIDDLE); return label; @@ -135,7 +135,7 @@ ido_media_player_menu_item_init (IdoMediaPlayerMenuItem *self) self->cancellable = g_cancellable_new (); self->player_icon = gtk_image_new(); - gtk_widget_set_margin_right (self->player_icon, 6); + gtk_widget_set_margin_end(self->player_icon, 6); gtk_widget_set_halign (self->player_icon, GTK_ALIGN_START); self->player_label = gtk_label_new (NULL); @@ -144,7 +144,7 @@ ido_media_player_menu_item_init (IdoMediaPlayerMenuItem *self) self->album_art = gtk_image_new(); gtk_widget_set_size_request (self->album_art, ALBUM_ART_SIZE, ALBUM_ART_SIZE); - gtk_widget_set_margin_right (self->album_art, 8); + gtk_widget_set_margin_end(self->album_art, 8); self->artist_label = track_info_label_new (); self->piece_label = track_info_label_new (); diff --git a/src/idomessagedialog.c b/src/idomessagedialog.c index ef5f148..4a264be 100644 --- a/src/idomessagedialog.c +++ b/src/idomessagedialog.c @@ -209,7 +209,11 @@ ido_message_dialog_constructed (GObject *object) gtk_widget_show (event_box); vbox = gtk_dialog_get_content_area (GTK_DIALOG (object)); + + //I dare you to find a better way! + G_GNUC_BEGIN_IGNORE_DEPRECATIONS; priv->action_area = gtk_dialog_get_action_area (GTK_DIALOG (object)); + G_GNUC_END_IGNORE_DEPRECATIONS; g_object_ref (G_OBJECT (vbox)); gtk_container_remove (GTK_CONTAINER (object), vbox); @@ -380,11 +384,11 @@ ido_message_dialog_get_label (IdoMessageDialog *dialog, gboolean primary) { if (G_TYPE_FROM_INSTANCE (list->data) == GTK_TYPE_BOX && gtk_orientable_get_orientation (list->data) == GTK_ORIENTATION_HORIZONTAL) { - GList *hchildren; + GList *hchildren; GList *hlist; GtkWidget *hbox = GTK_WIDGET (list->data); - hchildren = gtk_container_get_children (GTK_CONTAINER (hbox)); + hchildren = gtk_container_get_children (GTK_CONTAINER (hbox)); for (hlist = hchildren; hlist != NULL; hlist = hlist->next) { @@ -392,9 +396,9 @@ ido_message_dialog_get_label (IdoMessageDialog *dialog, gboolean primary) { GList *vlist; GtkWidget *vbox = GTK_WIDGET (hlist->data); - GList *vchildren; + GList *vchildren; - vchildren = gtk_container_get_children (GTK_CONTAINER (vbox)); + vchildren = gtk_container_get_children (GTK_CONTAINER (vbox)); for (vlist = vchildren; vlist != NULL; vlist = vlist->next) { diff --git a/src/idoplaybackmenuitem.c b/src/idoplaybackmenuitem.c index d45acd0..6deada1 100644 --- a/src/idoplaybackmenuitem.c +++ b/src/idoplaybackmenuitem.c @@ -473,13 +473,6 @@ ido_playback_menu_item_new_from_model (GMenuItem *item, * Drawing */ -typedef struct -{ - double r; - double g; - double b; -} CairoColorRGB; - static void draw_gradient (cairo_t* cr, double x, @@ -898,22 +891,21 @@ _color_hls_to_rgb (gdouble *h, } } -static void -_color_shade (const CairoColorRGB *a, float k, CairoColorRGB *b) +static void _color_shade(const GdkRGBA *a, float k, GdkRGBA *b) { double red; double green; double blue; - red = a->r; - green = a->g; - blue = a->b; + red = a->red; + green = a->green; + blue = a->blue; if (k == 1.0) { - b->r = red; - b->g = green; - b->b = blue; + b->red = red; + b->green = green; + b->blue = blue; return; } @@ -933,9 +925,9 @@ _color_shade (const CairoColorRGB *a, float k, CairoColorRGB *b) _color_hls_to_rgb (&red, &green, &blue); - b->r = red; - b->g = green; - b->b = blue; + b->red = red; + b->green = green; + b->blue = blue; } static inline void @@ -1161,39 +1153,20 @@ ido_playback_menu_item_draw (GtkWidget* button, cairo_t *cr) cairo_surface_t* surf = NULL; cairo_t* cr_surf = NULL; - GtkStyle *style; + GtkStyleContext *pStyleContext; - CairoColorRGB bg_color, fg_color, bg_selected, bg_prelight; - CairoColorRGB color_middle[2], color_middle_prelight[2], color_outer[2], color_outer_prelight[2], + GdkRGBA bg_color, fg_color, bg_selected, bg_prelight; + GdkRGBA color_middle[2], color_middle_prelight[2], color_outer[2], color_outer_prelight[2], color_play_outer[2], color_play_outer_prelight[2], color_button[4], color_button_shadow, color_inner[2], color_inner_compressed[2]; - /* Use the menu's style instead of that of the menuitem ('button' is a - * menuitem that is packed in a menu directly). The menuitem's style - * can't be used due to a change in light-themes (lp #1130183). - * Menuitems now have a transparent background, which confuses - * GtkStyle. - * - * This is a workaround until this code gets refactored to use - * GtkStyleContext. - */ - style = gtk_widget_get_style (gtk_widget_get_parent (button)); - - bg_color.r = style->bg[0].red/65535.0; - bg_color.g = style->bg[0].green/65535.0; - bg_color.b = style->bg[0].blue/65535.0; - - bg_prelight.r = style->bg[GTK_STATE_PRELIGHT].red/65535.0; - bg_prelight.g = style->bg[GTK_STATE_PRELIGHT].green/65535.0; - bg_prelight.b = style->bg[GTK_STATE_PRELIGHT].blue/65535.0; - - bg_selected.r = style->bg[GTK_STATE_SELECTED].red/65535.0; - bg_selected.g = style->bg[GTK_STATE_SELECTED].green/65535.0; - bg_selected.b = style->bg[GTK_STATE_SELECTED].blue/65535.0; - - fg_color.r = style->fg[0].red/65535.0; - fg_color.g = style->fg[0].green/65535.0; - fg_color.b = style->fg[0].blue/65535.0; + pStyleContext = gtk_widget_get_style_context(gtk_widget_get_parent(button)); + // Some buggy themes don't define a fallback "background-color" - let's make this a button, then + gtk_style_context_add_class(pStyleContext, GTK_STYLE_CLASS_BUTTON); + gtk_style_context_get(pStyleContext, GTK_STATE_FLAG_NORMAL, GTK_STYLE_PROPERTY_BACKGROUND_COLOR, &bg_color, NULL); + gtk_style_context_get(pStyleContext, GTK_STATE_FLAG_PRELIGHT, GTK_STYLE_PROPERTY_BACKGROUND_COLOR, &bg_prelight, NULL); + gtk_style_context_get(pStyleContext, GTK_STATE_FLAG_SELECTED, GTK_STYLE_PROPERTY_BACKGROUND_COLOR, &bg_selected, NULL); + gtk_style_context_get(pStyleContext, GTK_STATE_FLAG_NORMAL, GTK_STYLE_PROPERTY_COLOR, &fg_color, NULL); _color_shade (&bg_color, MIDDLE_START_SHADE, &color_middle[0]); _color_shade (&bg_color, MIDDLE_END_SHADE, &color_middle[1]); @@ -1217,25 +1190,25 @@ ido_playback_menu_item_draw (GtkWidget* button, cairo_t *cr) _color_shade (&bg_color, INNER_COMPRESSED_START_SHADE, &color_inner_compressed[0]); _color_shade (&bg_color, INNER_COMPRESSED_END_SHADE, &color_inner_compressed[1]); - double MIDDLE_END[] = {color_middle[0].r, color_middle[0].g, color_middle[0].b, 1.0f}; - double MIDDLE_START[] = {color_middle[1].r, color_middle[1].g, color_middle[1].b, 1.0f}; - double MIDDLE_END_PRELIGHT[] = {color_middle_prelight[0].r, color_middle_prelight[0].g, color_middle_prelight[0].b, 1.0f}; - double MIDDLE_START_PRELIGHT[] = {color_middle_prelight[1].r, color_middle_prelight[1].g, color_middle_prelight[1].b, 1.0f}; - double OUTER_END[] = {color_outer[0].r, color_outer[0].g, color_outer[0].b, 1.0f}; - double OUTER_START[] = {color_outer[1].r, color_outer[1].g, color_outer[1].b, 1.0f}; - double OUTER_END_PRELIGHT[] = {color_outer_prelight[0].r, color_outer_prelight[0].g, color_outer_prelight[0].b, 1.0f}; - double OUTER_START_PRELIGHT[] = {color_outer_prelight[1].r, color_outer_prelight[1].g, color_outer_prelight[1].b, 1.0f}; - double SHADOW_BUTTON[] = {color_button_shadow.r, color_button_shadow.g, color_button_shadow.b, 0.3f}; - double OUTER_PLAY_END[] = {color_play_outer[0].r, color_play_outer[0].g, color_play_outer[0].b, 1.0f}; - double OUTER_PLAY_START[] = {color_play_outer[1].r, color_play_outer[1].g, color_play_outer[1].b, 1.0f}; - double OUTER_PLAY_END_PRELIGHT[] = {color_play_outer_prelight[0].r, color_play_outer_prelight[0].g, color_play_outer_prelight[0].b, 1.0f}; - double OUTER_PLAY_START_PRELIGHT[] = {color_play_outer_prelight[1].r, color_play_outer_prelight[1].g, color_play_outer_prelight[1].b, 1.0f}; - double BUTTON_END[] = {color_button[0].r, color_button[0].g, color_button[0].b, 1.0f}; - double BUTTON_START[] = {color_button[1].r, color_button[1].g, color_button[1].b, 1.0f}; - double BUTTON_SHADOW[] = {color_button[2].r, color_button[2].g, color_button[2].b, 0.75f}; - double BUTTON_SHADOW_FOCUS[] = {color_button[3].r, color_button[3].g, color_button[3].b, 1.0f}; - double INNER_COMPRESSED_END[] = {color_inner_compressed[1].r, color_inner_compressed[1].g, color_inner_compressed[1].b, 1.0f}; - double INNER_COMPRESSED_START[] = {color_inner_compressed[0].r, color_inner_compressed[0].g, color_inner_compressed[0].b, 1.0f}; + double MIDDLE_END[] = {color_middle[0].red, color_middle[0].green, color_middle[0].blue, 1.0f}; + double MIDDLE_START[] = {color_middle[1].red, color_middle[1].green, color_middle[1].blue, 1.0f}; + double MIDDLE_END_PRELIGHT[] = {color_middle_prelight[0].red, color_middle_prelight[0].green, color_middle_prelight[0].blue, 1.0f}; + double MIDDLE_START_PRELIGHT[] = {color_middle_prelight[1].red, color_middle_prelight[1].green, color_middle_prelight[1].blue, 1.0f}; + double OUTER_END[] = {color_outer[0].red, color_outer[0].green, color_outer[0].blue, 1.0f}; + double OUTER_START[] = {color_outer[1].red, color_outer[1].green, color_outer[1].blue, 1.0f}; + double OUTER_END_PRELIGHT[] = {color_outer_prelight[0].red, color_outer_prelight[0].green, color_outer_prelight[0].blue, 1.0f}; + double OUTER_START_PRELIGHT[] = {color_outer_prelight[1].red, color_outer_prelight[1].green, color_outer_prelight[1].blue, 1.0f}; + double SHADOW_BUTTON[] = {color_button_shadow.red, color_button_shadow.green, color_button_shadow.blue, 0.3f}; + double OUTER_PLAY_END[] = {color_play_outer[0].red, color_play_outer[0].green, color_play_outer[0].blue, 1.0f}; + double OUTER_PLAY_START[] = {color_play_outer[1].red, color_play_outer[1].green, color_play_outer[1].blue, 1.0f}; + double OUTER_PLAY_END_PRELIGHT[] = {color_play_outer_prelight[0].red, color_play_outer_prelight[0].green, color_play_outer_prelight[0].blue, 1.0f}; + double OUTER_PLAY_START_PRELIGHT[] = {color_play_outer_prelight[1].red, color_play_outer_prelight[1].green, color_play_outer_prelight[1].blue, 1.0f}; + double BUTTON_END[] = {color_button[0].red, color_button[0].green, color_button[0].blue, 1.0f}; + double BUTTON_START[] = {color_button[1].red, color_button[1].green, color_button[1].blue, 1.0f}; + double BUTTON_SHADOW[] = {color_button[2].red, color_button[2].green, color_button[2].blue, 0.75f}; + double BUTTON_SHADOW_FOCUS[] = {color_button[3].red, color_button[3].green, color_button[3].blue, 1.0f}; + double INNER_COMPRESSED_END[] = {color_inner_compressed[1].red, color_inner_compressed[1].green, color_inner_compressed[1].blue, 1.0f}; + double INNER_COMPRESSED_START[] = {color_inner_compressed[0].red, color_inner_compressed[0].green, color_inner_compressed[0].blue, 1.0f}; gtk_widget_get_allocation (button, &alloc); X = alloc.x + (alloc.width - RECT_WIDTH) / 2 + OUTER_RADIUS; diff --git a/src/idosourcemenuitem.c b/src/idosourcemenuitem.c index 79455da..44ddf6f 100644 --- a/src/idosourcemenuitem.c +++ b/src/idosourcemenuitem.c @@ -49,13 +49,14 @@ ido_source_menu_item_constructed (GObject *object) gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &icon_width, NULL); item->icon = g_object_ref (gtk_image_new ()); - gtk_widget_set_margin_left (item->icon, icon_width); - gtk_widget_set_margin_right (item->icon, 6); + gtk_widget_set_margin_start(item->icon, icon_width); + gtk_widget_set_margin_end(item->icon, 6); item->label = g_object_ref (gtk_label_new ("")); gtk_label_set_max_width_chars (GTK_LABEL (item->label), 40); gtk_label_set_ellipsize (GTK_LABEL (item->label), PANGO_ELLIPSIZE_END); - gtk_misc_set_alignment (GTK_MISC (item->label), 0.0, 0.5); + gtk_widget_set_halign(item->label, GTK_ALIGN_START); + gtk_widget_set_valign(item->label, GTK_ALIGN_CENTER); item->detail = g_object_ref (ido_detail_label_new ("")); gtk_widget_set_halign (item->detail, GTK_ALIGN_END); diff --git a/src/idousermenuitem.c b/src/idousermenuitem.c index f4e146b..c8ddc5e 100644 --- a/src/idousermenuitem.c +++ b/src/idousermenuitem.c @@ -212,7 +212,9 @@ ido_user_menu_item_init (IdoUserMenuItem *self) priv->tick_icon = gtk_image_new_from_icon_name ("account-logged-in", GTK_ICON_SIZE_MENU); - gtk_misc_set_alignment(GTK_MISC(priv->tick_icon), 1.0, 0.5); + + gtk_widget_set_halign(priv->tick_icon, GTK_ALIGN_END); + gtk_widget_set_valign(priv->tick_icon, GTK_ALIGN_CENTER); // Pack it together gtk_box_pack_start (GTK_BOX (priv->container), @@ -303,10 +305,8 @@ ido_user_menu_item_set_icon_from_file_icon (IdoUserMenuItem *self, file = g_file_icon_get_file (G_FILE_ICON (icon)); path = g_file_get_path (file); - /* width and height will always be set by this function */ - gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (GTK_WIDGET (self)), - GTK_ICON_SIZE_MENU, - &width, &height); + /* width and height will always be set by this function */ + gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height); pixbuf = gdk_pixbuf_new_from_file_at_scale (path, width, height, TRUE, NULL); g_free (path); |