]> Eric's Git Repo - ericdock.git/commitdiff
Cleaned up pixbuf handling, still not perfect... made UI_SCALE set from org.gnome...
authorEric Wertz <ericdwertz@gmail.com>
Mon, 20 Feb 2017 20:29:57 +0000 (15:29 -0500)
committerEric Wertz <ericdwertz@gmail.com>
Mon, 20 Feb 2017 20:29:57 +0000 (15:29 -0500)
dock_icon.c
ericdock.h
main.c
pager_item.c

index 07076e2955d5a33aeece9a53003a899aaa722531..ab5bf70274bd0d683464d6c334833d709141e3d8 100644 (file)
@@ -7,7 +7,6 @@
 #include "ericdock.h"
 #include "dock_icon.h"
 #include "tooltip_window.h"
-#include "xutils.h"
 
 #include <stdio.h>
 #include <ctype.h>
@@ -19,6 +18,7 @@ dock_icon* dock_icon_create( WnckWindow* window )
     icon->class_group = wnck_window_get_class_group( window );
     icon->instance_name = wnck_window_get_class_instance_name( window );
     icon->icon_pixbuf = get_icon( window, (int)SCALE_VALUE( 32.0 ) );
+    g_object_ref( icon->icon_pixbuf );
     icon->pager_items = NULL;
     icon->icon_state = ICON_STATE_NORMAL;
 
index 2ced79af569a1220a9601c158a28e346b0a0e2ac..6aabd9c6971adc1aca2179730588cd38b8bb522f 100644 (file)
@@ -10,7 +10,7 @@
 #define ERIC_DOCK_TOOLTIP_SHADOW_RADIUS 16.0
 #define ERIC_DOCK_TOOLTIP_WIDTH ERIC_DOCK_TOOLTIP_SHADOW_RADIUS + 320.0
 #define ERIC_DOCK_TOOLTIP_ITEM_HEIGHT 24.0
-#define UI_SCALE 2.0
+#define UI_SCALE interface_scale
 #define SCALE_VALUE(x) (x)*UI_SCALE
 #define BAR_HEIGHT 48.0
 
@@ -23,4 +23,5 @@ extern GList* dock_icons;
 extern eric_window* dock_window;
 extern eric_window* tooltip_window;
 extern dock_icon* tooltip_window_icon;
+extern double interface_scale;
 
diff --git a/main.c b/main.c
index 29ad61c4047f6aaad4fa0c6d4ebf6e30e27af115..78a442af8679f77d10bfda245151b8bbf097a375 100644 (file)
--- a/main.c
+++ b/main.c
@@ -21,11 +21,11 @@ eric_window* dock_window = NULL;
 #include "dock_icon.h"
 
 #include "tooltip_window.h"
-#include "xutils.h"
 
 int screen_width;
 int screen_height;
 
+double interface_scale;
 
 //Logic to add a window to the pager items.
 //If a matching class group already exists it will be added to that, otherwise create
@@ -36,8 +36,7 @@ void add_window_to_pager( WnckWindow* window )
     int found_class_group = 0;
     dock_icon *icon, *new_dock_icon;
 
-    WnckClassGroup* class = wnck_window_get_class_group( window );
-    gchar* instance_name = wnck_window_get_class_instance_name( window );
+    const gchar* instance_name = wnck_window_get_class_instance_name( window );
     for( icon_list = dock_icons; icon_list != NULL; icon_list = icon_list->next )
     {
         icon = (dock_icon*)icon_list->data;
@@ -315,6 +314,9 @@ static void wnck_window_closed( WnckScreen* screen, WnckWindow* window, gpointer
             item = (pager_item*)pager_list->data;
             if( item->window == window )
             {
+                if( GDK_IS_PIXBUF( item->icon_pixbuf ) )
+                    g_object_unref( item->icon_pixbuf );
+
                 icon->pager_items = g_list_remove( icon->pager_items, item );
                 free( item );
                 printf( "Removed pager item\n" );
@@ -377,9 +379,18 @@ void init_wnck()
     g_signal_connect( screen, "active-window-changed", G_CALLBACK( wnck_active_window_changed ), NULL );
 }
 
+void load_gsettings()
+{
+    GSettings* gsettings = g_settings_new ( "org.gnome.desktop.interface" );
+    interface_scale = (double)g_settings_get_uint( gsettings, "scaling-factor" );
+    if( interface_scale < 1.0 )
+        interface_scale = 1.0;
+}
+
 int main( int argc, char* argv[] )
 {
     gtk_init( &argc, &argv );
+    load_gsettings();
 
     setup_dock_window();
     tooltip_window_create( dock_window->window );
index 4c9886fdbe1f125579620b47add45b585b202362..83afcd363ee6347960b27691408973d62e19b3ac 100644 (file)
@@ -19,7 +19,11 @@ void pager_item_name_changed( WnckWindow* window, pager_item* item )
 
 void pager_item_icon_changed( WnckWindow* window, pager_item* item )
 {
+    if( GDK_IS_PIXBUF( item->icon_pixbuf ) )
+        g_object_unref( item->icon_pixbuf );
+
     item->icon_pixbuf = get_icon( window, (int)SCALE_VALUE( 16.0 ) );
+    g_object_ref( item->icon_pixbuf );
 }
 
 void pager_item_state_changed( WnckWindow* window, WnckWindowState changed_mask, WnckWindowState new_state, pager_item* item )
@@ -33,6 +37,7 @@ pager_item* pager_item_create( WnckWindow* window )
     item->window = window;
     strcpy( item->name, wnck_window_get_name( item->window ) );
     item->icon_pixbuf = get_icon( window, (int)SCALE_VALUE( 16.0 ) );
+    g_object_ref( item->icon_pixbuf );
     item->icon_state = ICON_STATE_NORMAL;
 
     g_signal_connect( G_OBJECT( window ), "name-changed", G_CALLBACK( pager_item_name_changed ), (gpointer)item );