Announcement

Collapse
No announcement yet.

MATE with Gtk3 in Ubuntu, hacked for some transparent eye candy

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • MATE with Gtk3 in Ubuntu, hacked for some transparent eye candy

    My ongoing search for a DE that looks like Cinnamon with the GNOME theme but is as light as GNOME 2 has taken me to compiz, the GTK3 version of MATE and some custom css theming. The goal here is to have the entire DE "shell" themable one way, while applications can remain themed another way, as is the case in both Gnome-Shell and Cinnamon. This sort of thing allows MATE to do almost anything Cinnamon can with much lighter code. I've got perhaps 80% of the work done at this point.

    As of now, I've got a DE that looks like what I had using cairo-dock or Cinnamon, but using MATE by itself. The mate-panel is far more responsive than anything else I have seen, blowing not only Cinnamon but cairo-dock as well out of the water for sheer responsiveness and minimal CPU use. My theme is probably very heavy, but using it with this lighter DE more than compensates. MATE with Gtk3 is still buggy, with occasional segfaults in things like the Caja file manager and certain right-click menus opening empty and filling in from the bottom. Also, the "menubar" rather than single button "main menu" must be used because the button menu opens empty from the bottom. Overall, I've got this running in Ubuntu well enough to use but not well enough yet to distribute to my friends.

    First things first, Gtk3 builds of MATE are not offered by any Ubuntu PPA to my knowledge. I ended up taking most of the binaries from the Arch repo http://pkgbuild.com/~flexiondotorg/m...al/1.9/x86_64/ . I just copied over the binaries into debian packages to get started, then hacked and custom built three packages so far. The panel, the old and separate network-manager-gnome package, and Ubuntu's indicator-cpufreq applet all got a line of code added to attach a name to their GtkMenu widgets so they could be singled out for custom theming. For instance, this line went into network-manager-gnome's source code into applet.c as line 1345:

    gtk_widget_set_name(menu, "nm-menu");

    That let me specify .menu#nm-menu in the list of panel widgets to get the transparent black menus with grey borders and round corners, while the application menus remain original UbuntuStudio grey.

    Mate-media is refusing to build for me, yet somehow the Arch folks have built it. I The volume control in it is hardcoded to use the theme background color, perhaps I could fire it up from a script with a separate .css file until this will build so I can modify it. Right now the volume control is the biggest panel widget inconsistancy, along with the battery-status applet from the mate-applets package which I have yet to custom build. The hacked tray applets work and follow their themes in any DE, though when compositing is not used transparency reverts to solid black.

    I've now got the panel menus, most of the right-click menus, and several tray applets all with GNOME style transparent black menus. That has allowed me to stop using cairo-dock for the tray and applets. After weeks of work I finally found the key last night to making popup menus tranparent: in GTK3 css theming, you can specify GtkWindow.popup and theme only those windows with a transparent background! Until then I had either solid color menus with square corners or black edges in many application windows that do not fill their top level windows. The main menubar was the one thing in which transparency was easy, because a special style class was already specified for it.

  • #2
    Do you have a blog where i could follow your progress? I am very interested in your theming efforts and offer my services if you need anything compiled on arch, as i am a big fan of mate on my arch desktop. (I registered for this)

    Comment


    • #3
      I do not have a blog for this

      Originally posted by rootshell View Post
      Do you have a blog where i could follow your progress? I am very interested in your theming efforts and offer my services if you need anything compiled on arch, as i am a big fan of mate on my arch desktop. (I registered for this)
      This has been esentially a project for my own usage, as I have found some of the details of setting up Ubuntu PPA's, getting licensing of multi-contributor things right, and that sort of thing to be beyond me. I did upload a package of an earlier version of my gtk3 theme to archive.org (where my videos go) in the dcdirectactionnews channel. When this gets done a late version of the theme with the menu transparency will go there too. It depends on Gtk3.14 or later, newer versions give transparent black menus for most but not yet all panel items. BTW, the hacked nm-applet and indicator-cpufreq follow the theme in ANY desktop environment. The patches to mate-panel, network-manager-gnome, and indicator-cpufreq are one-liners. I would post a link to the older theme, but that would get this held for moderation from whatI hear.

      I do not have any kind of blog for this. Most of what I do online is political/protest video work, so I stay off of things like Facebook and Google for security reasons. I do not even have accounts with things like Dropbox as I prefer to avoid making accounts on US servers that cooperate with the NSA or harvest personal information for sale. Also have limited bandwidth at home.

      Comment


      • #4
        This is understandable. So i will just wait for a screenshot of your work for my own inspiration. Thank you anyway!

        EDIT: I am unable to find it on archive.org. Would you mind sending me a link via PN?

        Comment


        • #5
          Ok, that message is sent, the same can be sent to anyone else interested

          Originally posted by rootshell View Post
          This is understandable. So i will just wait for a screenshot of your work for my own inspiration. Thank you anyway!

          EDIT: I am unable to find it on archive.org. Would you mind sending me a link via PN?
          Let's see if I can include a link in this, archive named it for one of the jpeg files:

          This is the latest version of my customized UbuntuStudio-Legacy theme with the blue-green and radio button mods and Gtk3.14  compatability. This version...


          Archive also mistook the .deb package for an AAC audio file, it opened fine in Engrampa or Gdebi when I downloaded it for test though. Out of curiosity I tried to open it in Audacious to see if it too would mistake a debian package for an AAC file, it was not fooled and said "no decoder" instead of outputting a bunch of hissing hash and trash.

          Comment


          • #6
            Working around nasty Gtk3.16 bug with good results

            When testing gtk3.16 I ran into an ugly bug: disabled transparency on menus (ALL menus, not just my panel menus) except in GNOME or Mutter. In other words, new difficulties to copy GNOME's own shell them using their owh Gtk toolkit! Though I only use transparent menus with the panel shell I figured sooner or later ubuntu will go to Gtk 3.16 and I had better not expect help from GNOME with MATE. I filed a bug report against compiz for the transparency issues and started on a workaround.

            I had to link the calendar window to a cairo context to force it to use 4 channel RBGA graphics instead of 3 channel RBG graphics, that window is apparently one of the odd widgets Gtk normally won't composite with a desktop. Most-but not all-default to a transparent background if none is set in gtk.css. I figured what worked for the calendar in all GTK3 versions might work for the menus in Gtk3.16, but it has been a bit more difficult. So far though only one thing has beaten me: getting this to work in mate-panel-applet.c, which already has another cairo context in it and can tag the menu for theming but those menus are only transparent in Gtk3.14 so far.

            The code below first labels the menu so the theme can identify it. Next, it loads "toplevel" with the GtkWindow the menu calls when it is set up, without having to go to the code that creates the window beneath a menu. (I think that code is in Gtk itself, not the place I want to have to drop in a hack, then maintain locally.) After that, it sets up the cairo context. Some of the code varies a bit with the exact function being hacked, this example is from my modified version of network-manager-gnome, which gives a transparent black menu from the tray applet when so themed in both gtk3.14 and gtk3.16. Sorry, the site just killed all the indentation, good thing this isn't python!

            At the top of the file, just under the include statements:

            /*HACK*/
            /* initialize variables for transparency functions */
            static void screen_changed(GtkWidget *widget, GdkScreen *old_screen, gpointer user_data);
            static gboolean draw(GtkWidget *widget, cairo_t *new_cr, gpointer user_data);

            /* end initializing variables for transparency functions */



            At the bottom of a function calling the menu in question, just above any "return" statement or the closing curly brace:

            /*HACK-name the menu for theming*/
            gtk_widget_set_name(menu, "nm-menu");
            /*HACK*/
            /*This one is to force transparency when GTK and window managers don't get along but
            RBGA/composited graphics is in fact supported by the window manager-ugly but necessary*/

            GtkWidget *toplevel = gtk_widget_get_toplevel (menu);
            if (gtk_widget_is_toplevel (toplevel))
            {
            /*transparency code added here from alpha demo */

            g_signal_connect(G_OBJECT(toplevel), "draw", G_CALLBACK(draw), NULL);

            screen_changed(toplevel, NULL, NULL);

            /*end transparency code this function */

            }


            /*HACK*/
            /*transparency cairo functions*/

            gboolean supports_alpha = FALSE; /*This must be defined ONCE ONLY, in first affected file to be compiled */
            static void screen_changed(GtkWidget *widget, GdkScreen *old_screen, gpointer userdata)
            {
            /* To check if the display supports alpha channels, get the visual */
            GdkScreen *screen = gtk_widget_get_screen(widget);
            GdkVisual *visual = gdk_screen_get_rgba_visual(screen);


            gtk_widget_set_visual(widget, visual);
            }

            static gboolean draw(GtkWidget *widget, cairo_t *cr, gpointer userdata)
            {
            cairo_t *new_cr = gdk_cairo_create(gtk_widget_get_window(widget));

            {
            cairo_set_source_rgba (new_cr, 0, 0, 0, 0.0); /* transparent */
            }


            /* draw the background */
            cairo_set_operator (new_cr, CAIRO_OPERATOR_SOURCE);
            cairo_paint (new_cr);

            cairo_destroy(new_cr);

            return FALSE;
            }



            /*end transparency cairo functions*/
            Last edited by Luke; 30 March 2015, 12:52 AM.

            Comment


            • #7
              You seem capable, so why didnt you fix the bug in gtk yourself instead of working with hacks?
              Anyway, still a solution to the problem.

              Comment


              • #8
                I've only been working with the C source code a couple weeks

                Originally posted by rootshell View Post
                You seem capable, so why didnt you fix the bug in gtk yourself instead of working with hacks?
                Anyway, still a solution to the problem.
                I've just started at this and know my way around some of the MATE code, this has been basically a matter of cut and paste code from the transparency demo and a lot of time with the Gtk3 documentation. To work on Gtk itself I would have to start over with a new codebase, build and maintain yet anothet piece of code. If I did it the way I am working the MATE panel, ALL Gtk apps would get heaviert menu code using a cairo context needed only for my panel menus. It would be a matter of finding every widget that has transparency issues in Compiz and linking a cairo context to them in Gtk itself. No way in hell upsteam GNOME would use this, they don' t need it as transparency works just fine in Mutter. Thus, they can use what is essentially the same shell theme without issues.

                Also, as a new C programmer I would rather risk introducing a possible exploitable bug to the panel (requiring local access and a deliberately malicious theme) than to all GTK apps including firefox, which is working on Gtk3. I hear over and over about how C can burn a new programmer tis way. Anyone who can boot my machine, switch to a theme that causes a buffer overflow, then drop a terminal launcher onto the panel to trigger it for a root shell is already past all defenses anyway on these single-user boxes.

                Comment


                • #9
                  Patches to support the custom theme now available at https://archive.org/details/CustomTh...-applets1.10.0 along with updated theme version

                  Comment

                  Working...
                  X