From 5011afaa935530ef65e92efe1a4d3d97fb9f53fd Mon Sep 17 00:00:00 2001 From: EricDWertz Date: Wed, 22 Jun 2016 10:37:40 -0400 Subject: [PATCH 1/1] EricDock first commit... testing styled windows --- .eric_window.h.swp | Bin 0 -> 16384 bytes .main.c.swp | Bin 0 -> 12288 bytes Makefile | 2 + eric_window.h | 123 +++++++++++++++++++++++++++++++++++++++++++++ ericwindow-test | Bin 0 -> 13584 bytes main.c | 13 +++++ 6 files changed, 138 insertions(+) create mode 100644 .eric_window.h.swp create mode 100644 .main.c.swp create mode 100644 Makefile create mode 100644 eric_window.h create mode 100755 ericwindow-test create mode 100644 main.c diff --git a/.eric_window.h.swp b/.eric_window.h.swp new file mode 100644 index 0000000000000000000000000000000000000000..01c892b10c1d365e4de068fe256434d07e58d64e GIT binary patch literal 16384 zcmeI2Uu+yl9ml5$6ijKLiG4J0T?2-2!=g_k0D1St}4RI2({0)Z;ZJ3K_?`5w9>|^}l`sWy~PcnA=&^I>Ux$845Sz$~hL5E)7>Y{j_NP99K z>>2ebia6KAf35bMN)&f`>c$xckrxl^-96LWK&yaN;5HS=Dg=D+bFR1W9=`TqaL zCm4Gdya=v=Ux6QkAA#?J0eBpI6+8+~fCW$op8|)$J>URf;GIK^T?f~|GvEo(0_VYd zcQbYaTnEpB$H7r>Ke!LP{c*ltj zzX30SpM&SXPr*;XN$?Q3AAB18V}`L;z@Nb{K^OSoOJET+z-u36>{ajr_yvf-o#4ht z82b}=23!SCgQvhr@DO0&y*nBEJNP5`1Nb4>1owisKg`%$;CXNjTmXMTzx)6^3%&w2 z0rgc1z7HzkReYTJ8TcOf4p;@p!C%p@Z-O_#5F7^gfP>%;pssH-jw=x|OCmlz#nhwk z^_;}ta-D&jq@v7^4QCg(+)mF=;w$<&UOA-;anit#+z{DCk?2UrbEP|(w9|DXUwEY&UvZX~R##6iEuSmI za4xxFCL9xsS8DwH#_DQ~&*LAJqKeTCL>tGI;*Dax(GFhbr8x2HeiZjb-TaoNK5j8;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I!b?Ah z=fGr4$UO(9UP`=_>Lq(%khng!7je`PqiX5pMao?+6E{l3ETuW!EOg*HvHRk(D|jbM z5(>b5A5WwswW{D%@MC*4hxY#x`{~yK?f>)h{l8(){(JB{@B}ynUcp}dW$6|f3e1*`&A0jq#j;Qvd3+dgXA?=jO< z0aK6qV=qplB8hLhrRCOYYwZ#K+4O4>ogIwNY~J@d);DSqSH&;4y3noS%&ngc@fu`-O~UWU(N1#6s)K(>jG6>b*Fa;2s%di3?W Vt&StBJC5nh$B+CYcOk+l_8*d10-^u_ literal 0 HcmV?d00001 diff --git a/.main.c.swp b/.main.c.swp new file mode 100644 index 0000000000000000000000000000000000000000..cfe3f959c68e9b8cea3b4c2548ee8d407097c9c5 GIT binary patch literal 12288 zcmeI&O)tbi7zgm-K!im&aD0?VSN5gYAlYye5y8RB9z>dIYj^BwH{Dr12)+v+!dZM4 zd9sD*uk&GdFQ42Ly4C!-BZJ(Je&@@FV-f-o=q}Jyr`eU1SX`L5bkVdi zMdM=!-Rm&}0SG_<0uX=z1Rwwb2>d$%Rqqiu{8qi~H%qnqo=<&yhzK(Hv3$`2ij`B@fDp(mRtnk6u_Zy1zu6Qc7 z9<&$ImJ>Tt8l7kArN}@klV+W$>}HbgLQh``87NAYN&2ic?N*#K9aEaO`^vzr OH9en<4~xlF4DkkF`EPds literal 0 HcmV?d00001 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1f3f16d --- /dev/null +++ b/Makefile @@ -0,0 +1,2 @@ +ericwindow-test: main.c + gcc -o ericwindow-test `pkg-config --cflags --libs gtk+-3.0` main.c diff --git a/eric_window.h b/eric_window.h new file mode 100644 index 0000000..8d4065a --- /dev/null +++ b/eric_window.h @@ -0,0 +1,123 @@ +/* + * eric_window.h + * creates a transluscent window using the current theme color + */ + +#pragma once + +#include +#include +#include + +#include +#include + +/* + * TODO: add text color + */ + +typedef struct +{ + GtkWidget* window; + GdkRGBA background_color; + GdkRGBA background_color_old; + GdkRGBA background_color_new; + double background_change_percentage; +} eric_window; + +static void gdk_color_lerp( GdkRGBA* c1, GdkRGBA* c2, double s, GdkRGBA* out ) +{ + out->red = c1->red + ( c2->red - c1->red ) * s; + out->green = c1->green + ( c2->green - c1->green ) * s; + out->blue = c1->blue + ( c2->blue - c1->blue ) * s; + out->alpha = c1->alpha + ( c2->alpha - c1->alpha ) * s; +} + +static gboolean eric_window_animation_timer( eric_window* w ) +{ + w->background_change_percentage += 0.05; + gdk_color_lerp( &w->background_color_old, &w->background_color_new, + w->background_change_percentage, &w->background_color); + gtk_widget_queue_draw( w->window ); + + if( w->background_change_percentage >= 1.0 ) return FALSE; + + return TRUE; +} + +static gboolean eric_window_draw( GtkWidget* widget, cairo_t* cr, eric_window* w ) +{ + cairo_set_operator(cr,CAIRO_OPERATOR_SOURCE); + w->background_color.alpha = 0.75; + gdk_cairo_set_source_rgba( cr, &w->background_color ); + cairo_paint( cr ); + + return FALSE; +} + + +static void eric_window_screen_changed( GtkWidget *widget, GdkScreen *old_screen, gpointer userdata ) +{ + GdkVisual *visual; + + GdkScreen* screen=gtk_widget_get_screen(widget); + if(!screen) return; + + visual = gdk_screen_get_rgba_visual(screen); + if(visual==NULL) visual=gdk_screen_get_system_visual(screen); + + gtk_widget_set_visual(widget,visual); +} + +void eric_window_gsettings_value_changed( GSettings *settings, const gchar *key, eric_window* w ) +{ + if( strcmp( key, "primary-color" ) == 0 ) + { + w->background_color_old = w->background_color; + gdk_rgba_parse( &w->background_color_new, g_settings_get_string( settings, "primary-color" ) ); + + w->background_change_percentage = 0.0; + g_timeout_add( 32, (gpointer)eric_window_animation_timer, w ); + } +} + +eric_window* eric_window_create( int width, int height, char* title ) +{ + eric_window* w = malloc( sizeof( eric_window ) ); + + if( title == NULL ) + title = "eric window"; + + w->window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + gtk_window_set_title( GTK_WINDOW( w->window ), title ); + gtk_window_resize( GTK_WINDOW( w->window ), width, height ); + gtk_widget_add_events( w->window, GDK_STRUCTURE_MASK ); + + gtk_widget_set_app_paintable( w->window, TRUE ); + + g_signal_connect( G_OBJECT( w->window ), "draw", G_CALLBACK(eric_window_draw), &w ); + g_signal_connect( G_OBJECT( w->window ), "screen-changed", G_CALLBACK(eric_window_screen_changed), &w ); + g_signal_connect( G_OBJECT( w->window ), "delete-event", gtk_main_quit, NULL ); + + eric_window_screen_changed( w->window, NULL, NULL ); + + /* GSettings Stuff */ + GSettings* gsettings; + GSettingsSchema* gsettings_schema; + + gsettings_schema = g_settings_schema_source_lookup( g_settings_schema_source_get_default(), + "org.gnome.desktop.background", + TRUE ); + if( gsettings_schema ) + { + g_settings_schema_unref (gsettings_schema); + gsettings_schema = NULL; + gsettings = g_settings_new ( "org.gnome.desktop.background" ); + } + + g_signal_connect_data( gsettings, "changed", G_CALLBACK( eric_window_gsettings_value_changed ), NULL, 0, 0 ); + gdk_rgba_parse( &w->background_color, g_settings_get_string( gsettings, "primary-color" ) ); + printf( "COLOR: %s\n", g_settings_get_string( gsettings, "primary-color" ) ); + + return w; +} diff --git a/ericwindow-test b/ericwindow-test new file mode 100755 index 0000000000000000000000000000000000000000..183d176144ae986dd94fafa57e8104ca453db829 GIT binary patch literal 13584 zcmcgz4RBl4mA9wD_-hWne*SO&<0}sxJM@8f{K0#czq+|~ z|GU3@-wQ>qDGi1flqp>W6_vx^bHP`-*!jps{(k6ya`po*_-!tBo^`=bx!{%ye%7Vl zRu}xcE_l)fzssfGD_rDjU`+gF#--h*pZB@o=UwbS;v&D^1s`|uzsCi?$;HmKF72A@ zB7e{Y-{4~BfJ=Mta*nqM9h?gcWl|%n~0k`LS4P4FpOwlB5tIuP|7k4TeQ4jcPt(gSXrb{8F0x^ zJemlHVyQ&knn1nn1H&aq2z*o}Y@KML>j5)t*^f!kBecLlRYo$_-<9dETdNq4#uBBx zZKMP|TspbU0<2aniN32BN5C?2e@~pyvvBiVc6r)z;Gzd zjUsJy!-`ojJ?xeem@?C`eT-07LY;=W+l*UjwMS4nluR1bRW!$k+d%l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000..2aad11f --- /dev/null +++ b/main.c @@ -0,0 +1,13 @@ +#include "eric_window.h" + +int main( int argc, char* argv[] ) +{ + gtk_init( &argc, &argv ); + + eric_window* w = eric_window_create( 640, 480, "Test Eric Window So Kawaii" ); + + gtk_widget_show_all( w->window ); + gtk_main(); + + return 0; +} -- 2.47.0