~ubuntu-branches/ubuntu/utopic/synaptic/utopic-proposed

« back to all changes in this revision

Viewing changes to gtk/rgpreferenceswindow.cc

  • Committer: Package Import Robot
  • Author(s): Michael Vogt
  • Date: 2013-09-10 11:24:31 UTC
  • Revision ID: package-import@ubuntu.com-20130910112431-95gxdsf3h1gfz7u0
Tags: 0.80.3
* gtk/rgmainwindow.cc, gtk/gtkbuilder/window_main.ui:
  - workaround "Gtk-WARNING **: GtkNotebook 0x998580 is mapped but visible 
    child GtkLabel 0x9ac140 is not mapped" by setting "show_tabs=True" in
    the GtkBuilder file and then setting it in buildInterface() again
    (closes: #721539)
  - fix warning" Gtk-CRITICAL **: gtk_tree_row_reference_new_proxy:
    assertion `path->depth > 0' failed" (closes: #721539)
* gtk/rgpreferenceswindow.{cc,h}:
  - make button colored in the preferencess window again, this broke 
    because gtk3 and gtk_widget_override_background() does not work
    (see gtk bug https://bugzilla.gnome.org/show_bug.cgi?id=656461)

Show diffs side-by-side

added added

removed removed

Lines of Context:
571
571
void RGPreferencesWindow::readColors()
572
572
{
573
573
   GdkColor *color;
574
 
   gchar *color_button;
 
574
   gchar *color_button = NULL;
575
575
   GtkWidget *button = NULL;
576
576
 
577
577
   // Color packages by their status
580
580
                                               true));
581
581
 
582
582
   // color buttons
 
583
   GString *custom_css = g_string_new("");
583
584
   for (int i = 0; i < RGPackageStatus::N_STATUS_COUNT; i++) {
584
585
      color_button =
585
586
         g_strdup_printf("button_%s_color",
587
588
                         getShortStatusString(RGPackageStatus::PkgStatus(i)));
588
589
      button = GTK_WIDGET(gtk_builder_get_object(_builder, color_button));
589
590
      assert(button);
 
591
      gtk_widget_set_name(button, color_button);
590
592
      if (RGPackageStatus::pkgStatus.getColor(i) != NULL) {
591
593
         color = RGPackageStatus::pkgStatus.getColor(i);
592
 
         gtk_widget_modify_bg(button, GTK_STATE_PRELIGHT, color);
593
 
         gtk_widget_modify_bg(button, GTK_STATE_NORMAL, color);
 
594
         // I whish I could just use gtk_widget_change_background_color
 
595
         // but see gtk bug https://bugzilla.gnome.org/show_bug.cgi?id=656461
 
596
         g_string_append_printf(custom_css,
 
597
            "GtkButton#%s { "
 
598
            " background:none; "
 
599
            " background-color:#%02x%02x%02x; "
 
600
            "} ", 
 
601
            color_button, 
 
602
            color->red / 256, 
 
603
            color->green / 256, 
 
604
            color->blue / 256);
594
605
      }
 
606
      gtk_css_provider_load_from_data(_css_provider, custom_css->str, -1, NULL);
595
607
      g_free(color_button);
596
608
   }
597
 
 
 
609
   g_string_free(custom_css, TRUE);
598
610
}
599
611
 
600
612
void RGPreferencesWindow::readFiles()
969
981
   GtkListStore *comboStore;
970
982
   GtkTreeIter comboIter;
971
983
 
 
984
   _css_provider = gtk_css_provider_new ();   
972
985
   _optionShowAllPkgInfoInMain = GTK_WIDGET(gtk_builder_get_object
973
986
                                            (_builder,
974
987
                                             "check_show_all_pkg_info"));
1187
1200
                         getShortStatusString(RGPackageStatus::PkgStatus(i)));
1188
1201
      button = GTK_WIDGET(gtk_builder_get_object(_builder, color_button));
1189
1202
      assert(button);
 
1203
      gtk_style_context_add_provider(
 
1204
         gtk_widget_get_style_context (button),
 
1205
         GTK_STYLE_PROVIDER (_css_provider), 
 
1206
         GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
1190
1207
      g_object_set_data(G_OBJECT(button), "me", this);
1191
1208
      g_signal_connect(G_OBJECT(button), "clicked",
1192
1209
                       G_CALLBACK(colorClicked), GINT_TO_POINTER(i));
1197
1214
   setTitle(_("Preferences"));
1198
1215
}
1199
1216
 
 
1217
RGPreferencesWindow::~RGPreferencesWindow()
 
1218
{
 
1219
   g_object_unref(_css_provider);
 
1220
}
 
1221
 
1200
1222
void 
1201
1223
RGPreferencesWindow::buttonAuthenticationClicked(GtkWidget *self, void *data)
1202
1224
{