From: Eric Wertz Date: Mon, 5 Dec 2016 14:29:03 +0000 (-0500) Subject: Broke apart files, should actually compile now X-Git-Url: https://ericdwertz.com/git/?a=commitdiff_plain;h=8bbb1066d3d3d890bd9a8cc9a9356cc2b8efdd73;p=ericdock.git Broke apart files, should actually compile now --- diff --git a/.main.c.swp b/.main.c.swp deleted file mode 100644 index a4c15ba..0000000 Binary files a/.main.c.swp and /dev/null differ diff --git a/Makefile b/Makefile index 049e73e..4092528 100644 --- a/Makefile +++ b/Makefile @@ -1,2 +1,11 @@ -ericdock: main.c - gcc -o ericdock -lm -lX11 `pkg-config --cflags --libs gtk+-3.0 libwnck-3.0` main.c +CC = gcc +CFLAGS = -std=gnu++98 -Wall -lm -lX11 `pkg-config --cflags gtk+-3.0 libwnck-3.0` +LDFLAGS = `pkg-config --libs gtk+-3.0 libwnck-3.0` +DEPS = dock_icon.h ericdock.h clock.h drawing.h eric_window.h pager_item.h tooltip_window.h +OBJ = dock_icon.o tooltip_window.o eric_window.o clock.o main.o pager_item.o drawing.o + +%.o: %.c $(DEPS) + $(CC) $(CFLAGS) -c -o $@ $< + +ericdock: $(OBJ) + gcc $(LDFLAGS) $(CFLAGS) -o $@ $^ diff --git a/clock.c b/clock.c index 40a8256..33e61e9 100644 --- a/clock.c +++ b/clock.c @@ -9,7 +9,7 @@ #include "clock.h" double clock_alpha = 0.75; -double clock_height = 0.18; +double clock_height = 18.0; int displaymode=0; @@ -49,7 +49,9 @@ gboolean clock_refresh(gpointer data) timeinfo = localtime ( &rawtime ); if( timeinfo->tm_sec != oldsec ); + { gtk_widget_queue_draw( GTK_WIDGET( data ) ); + } return TRUE; } diff --git a/clock.h b/clock.h index 3a2bd0d..221c327 100644 --- a/clock.h +++ b/clock.h @@ -6,12 +6,6 @@ #include "eric_window.h" -extern double clock_alpha; -extern double clock_height; -extern int displaymode; -extern char* weekday_names[7]; -extern char* month_names[12]; - gboolean clock_refresh(gpointer data); void clock_init( gpointer window ); void clock_draw_timestring(cairo_t* cr, double x, double y, int blurpass); diff --git a/dock_icon.c b/dock_icon.c index c48f4d0..7099e84 100644 --- a/dock_icon.c +++ b/dock_icon.c @@ -4,12 +4,10 @@ * * renders/handles events based on how many pager_items it contains */ +#include "ericdock.h" #include "dock_icon.h" #include "tooltip_window.h" -eric_window* tooltip_window = NULL; -dock_icon* tooltip_window_icon = NULL; - dock_icon* dock_icon_create( WnckClassGroup* class_group ) { dock_icon* icon = malloc( sizeof( dock_icon ) ); diff --git a/dock_icon.h b/dock_icon.h index a97c4b4..d0a9fc9 100644 --- a/dock_icon.h +++ b/dock_icon.h @@ -7,13 +7,11 @@ */ #include #include +#include #define WNCK_I_KNOW_THIS_IS_UNSTABLE #include -#include - -#include "ericdock.h" #include "pager_item.h" typedef struct diff --git a/drawing.c b/drawing.c new file mode 100644 index 0000000..beedc96 --- /dev/null +++ b/drawing.c @@ -0,0 +1,17 @@ +#include "drawing.h" +#include + +void draw_rounded_rect(cairo_t* cr,double x,double y,double w,double h,double r) +{ + cairo_move_to(cr,x+r,y); + cairo_line_to(cr,x+w-r*2,y); + cairo_arc(cr,x+w-r,y+r,r,-M_PI/2.0,0); + cairo_line_to(cr,x+w,y+h-r*2); + cairo_arc(cr,x+w-r,y+h-r,r,0,M_PI/2.0); + cairo_line_to(cr, x+r,y+h); + cairo_arc(cr,x+r,y+h-r,r,M_PI/2.0,M_PI); + cairo_line_to(cr, x, y+r); + cairo_arc(cr,x+r,y+r,r,M_PI,-M_PI/2.0); + cairo_close_path(cr); +} + diff --git a/drawing.h b/drawing.h index ced8af9..55dfffc 100644 --- a/drawing.h +++ b/drawing.h @@ -3,19 +3,5 @@ * Drawing functions! */ #include -#include - -void draw_rounded_rect(cairo_t* cr,double x,double y,double w,double h,double r) -{ - cairo_move_to(cr,x+r,y); - cairo_line_to(cr,x+w-r*2,y); - cairo_arc(cr,x+w-r,y+r,r,-M_PI/2.0,0); - cairo_line_to(cr,x+w,y+h-r*2); - cairo_arc(cr,x+w-r,y+h-r,r,0,M_PI/2.0); - cairo_line_to(cr, x+r,y+h); - cairo_arc(cr,x+r,y+h-r,r,M_PI/2.0,M_PI); - cairo_line_to(cr, x, y+r); - cairo_arc(cr,x+r,y+r,r,M_PI,-M_PI/2.0); - cairo_close_path(cr); -} +void draw_rounded_rect(cairo_t* cr,double x,double y,double w,double h,double r); diff --git a/eric_window.h b/eric_window.h index 8cb667a..47e9e64 100644 --- a/eric_window.h +++ b/eric_window.h @@ -11,10 +11,6 @@ #include #include -/* - * TODO: add text color - */ - typedef struct eric_window eric_window; struct eric_window { diff --git a/ericdock.h b/ericdock.h index 0a7f87a..08bf440 100644 --- a/ericdock.h +++ b/ericdock.h @@ -4,6 +4,7 @@ */ #include "eric_window.h" +#include "dock_icon.h" #define ERIC_DOCK_FONT "Source Sans Pro Regular" #define ERIC_DOCK_TOOLTIP_SHADOW_RADIUS 16.0 @@ -20,3 +21,6 @@ extern GList* dock_icons; extern eric_window* dock_window; +extern eric_window* tooltip_window; +extern dock_icon* tooltip_window_icon; + diff --git a/ericwindow-test b/ericwindow-test index 0d67b54..76efba7 100755 Binary files a/ericwindow-test and b/ericwindow-test differ diff --git a/pager_item.c b/pager_item.c new file mode 100644 index 0000000..5cd5866 --- /dev/null +++ b/pager_item.c @@ -0,0 +1,91 @@ +/* + * pager_item - held by the dock_icon object + */ + +#include "pager_item.h" + +#include +#include +#include + +#include "ericdock.h" +#include "drawing.h" + +void pager_item_name_changed( WnckWindow* window, pager_item* item ) +{ + strcpy( item->name, wnck_window_get_name( window ) ); +} + +void pager_item_icon_changed( WnckWindow* window, pager_item* item ) +{ + item->icon_pixbuf = wnck_window_get_mini_icon( window ); +} + +void pager_item_state_changed( WnckWindow* window, WnckWindowState changed_mask, WnckWindowState new_state, pager_item* item ) +{ + //item->icon_pixbuf = wnck_window_get_mini_icon( window ); +} + +pager_item* pager_item_create( WnckWindow* window ) +{ + pager_item* item = malloc( sizeof( pager_item ) ); + item->window = window; + strcpy( item->name, wnck_window_get_name( item->window ) ); + item->icon_pixbuf = wnck_window_get_mini_icon( item->window ); + item->icon_state = ICON_STATE_NORMAL; + + g_signal_connect( G_OBJECT( window ), "name-changed", G_CALLBACK( pager_item_name_changed ), (gpointer)item ); + g_signal_connect( G_OBJECT( window ), "icon-changed", G_CALLBACK( pager_item_icon_changed ), (gpointer)item ); + g_signal_connect( G_OBJECT( window ), "state-changed", G_CALLBACK( pager_item_state_changed ), (gpointer)item ); + + item->width = SCALE_VALUE( 320 ); + item->height = SCALE_VALUE( 24.0 ); + item->text_height = SCALE_VALUE( 16.0 ); + + return item; +} + +/* Returns bool if state has changed */ +int pager_item_mouse_move( pager_item* item, double mx, double my ) +{ + double it, ib, il, ir; + int old_state; + + old_state = item->icon_state; + + il = item->x; ir = item->x + item->width; + it = item->y; ib = item->y + item->height; + + if( il < mx && mx < ir && it < my && my < ib ) + { + item->icon_state = ICON_STATE_HOVER; + } + else + { + item->icon_state = ICON_STATE_NORMAL; + } + + return old_state != item->icon_state; +} + +void pager_item_draw( pager_item* item, cairo_t* cr, eric_window* w, cairo_pattern_t* pattern ) +{ + if( item->icon_state == ICON_STATE_HOVER ) + { + w->text_color.alpha = 0.25; + gdk_cairo_set_source_rgba( cr, &w->text_color ); + draw_rounded_rect( cr, item->x, item->y, + item->width, item->height, SCALE_VALUE( 2.0 ) ); + cairo_fill( cr ); + } + + gdk_cairo_set_source_pixbuf( cr, item->icon_pixbuf, item->x, item->y + SCALE_VALUE( 6.0 ) ); + cairo_paint( cr ); + + cairo_set_source( cr, pattern ); + cairo_move_to( cr, item->x + SCALE_VALUE( 20.0 ), item->y + item->text_height ); + cairo_text_path( cr, item->name ); + + cairo_fill( cr ); + +} diff --git a/pager_item.h b/pager_item.h index ebee6ad..dba3115 100644 --- a/pager_item.h +++ b/pager_item.h @@ -3,8 +3,6 @@ * pager_item - held by the dock_icon object */ -#include -#include #include #define WNCK_I_KNOW_THIS_IS_UNSTABLE @@ -25,81 +23,9 @@ typedef struct int icon_state; } pager_item; -void pager_item_name_changed( WnckWindow* window, pager_item* item ) -{ - strcpy( item->name, wnck_window_get_name( window ) ); -} - -void pager_item_icon_changed( WnckWindow* window, pager_item* item ) -{ - item->icon_pixbuf = wnck_window_get_mini_icon( window ); -} - -void pager_item_state_changed( WnckWindow* window, WnckWindowState changed_mask, WnckWindowState new_state, pager_item* item ) -{ - //item->icon_pixbuf = wnck_window_get_mini_icon( window ); -} - -pager_item* pager_item_create( WnckWindow* window ) -{ - pager_item* item = malloc( sizeof( pager_item ) ); - item->window = window; - strcpy( item->name, wnck_window_get_name( item->window ) ); - item->icon_pixbuf = wnck_window_get_mini_icon( item->window ); - item->icon_state = ICON_STATE_NORMAL; - - g_signal_connect( G_OBJECT( window ), "name-changed", G_CALLBACK( pager_item_name_changed ), (gpointer)item ); - g_signal_connect( G_OBJECT( window ), "icon-changed", G_CALLBACK( pager_item_icon_changed ), (gpointer)item ); - g_signal_connect( G_OBJECT( window ), "state-changed", G_CALLBACK( pager_item_state_changed ), (gpointer)item ); - - item->width = SCALE_VALUE( 320 ); - item->height = SCALE_VALUE( 24.0 ); - item->text_height = SCALE_VALUE( 16.0 ); - - return item; -} - -/* Returns bool if state has changed */ -int pager_item_mouse_move( pager_item* item, double mx, double my ) -{ - double it, ib, il, ir; - int old_state; - - old_state = item->icon_state; - - il = item->x; ir = item->x + item->width; - it = item->y; ib = item->y + item->height; - - if( il < mx && mx < ir && it < my && my < ib ) - { - item->icon_state = ICON_STATE_HOVER; - } - else - { - item->icon_state = ICON_STATE_NORMAL; - } - - return old_state != item->icon_state; -} - -void pager_item_draw( pager_item* item, cairo_t* cr, eric_window* w, cairo_pattern_t* pattern ) -{ - if( item->icon_state == ICON_STATE_HOVER ) - { - w->text_color.alpha = 0.25; - gdk_cairo_set_source_rgba( cr, &w->text_color ); - draw_rounded_rect( cr, item->x, item->y, - item->width, item->height, SCALE_VALUE( 2.0 ) ); - cairo_fill( cr ); - } - - gdk_cairo_set_source_pixbuf( cr, item->icon_pixbuf, item->x, item->y + SCALE_VALUE( 6.0 ) ); - cairo_paint( cr ); - - cairo_set_source( cr, pattern ); - cairo_move_to( cr, item->x + SCALE_VALUE( 20.0 ), item->y + item->text_height ); - cairo_text_path( cr, item->name ); - - cairo_fill( cr ); - -} +void pager_item_name_changed( WnckWindow* window, pager_item* item ); +void pager_item_icon_changed( WnckWindow* window, pager_item* item ); +void pager_item_state_changed( WnckWindow* window, WnckWindowState changed_mask, WnckWindowState new_state, pager_item* item ); +pager_item* pager_item_create( WnckWindow* window ); +int pager_item_mouse_move( pager_item* item, double mx, double my ); +void pager_item_draw( pager_item* item, cairo_t* cr, eric_window* w, cairo_pattern_t* pattern ); diff --git a/tooltip_window.c b/tooltip_window.c index 0fcad92..c89acd7 100644 --- a/tooltip_window.c +++ b/tooltip_window.c @@ -1,10 +1,9 @@ -#include "tooltip_window.h" #include "ericdock.h" #define WNCK_I_KNOW_THIS_IS_UNSTABLE #include -#include "dock_icon.h" +#include "tooltip_window.h" #include "drawing.h" eric_window* tooltip_window = NULL; diff --git a/tooltip_window.h b/tooltip_window.h index b4bd52f..edf40cb 100644 --- a/tooltip_window.h +++ b/tooltip_window.h @@ -2,10 +2,6 @@ #include #include "eric_window.h" -#include "dock_icon.h" - -extern eric_window* tooltip_window; -extern dock_icon* tooltip_window_icon; void tooltip_window_hide(); gboolean tooltip_window_lose_focus( GtkWidget* widget, GdkEvent* event, gpointer user );