summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c9b19fc)
raw | patch | inline | side by side (parent: c9b19fc)
author | Eric Wertz <ericdwertz@gmail.com> | |
Thu, 16 Feb 2017 15:50:50 +0000 (10:50 -0500) | ||
committer | Eric Wertz <ericdwertz@gmail.com> | |
Thu, 16 Feb 2017 15:50:50 +0000 (10:50 -0500) |
clock.c | patch | blob | history | |
dock_icon.c | patch | blob | history | |
dock_icon.h | patch | blob | history | |
eric_window.c | patch | blob | history | |
main.c | patch | blob | history | |
pager_item.c | patch | blob | history | |
tooltip_window.c | patch | blob | history |
index 33e61e98abbf3c76651fdab21337585cc69a63c9..94fae5f662e9ea7c622c9e942b027aaac619f2f8 100644 (file)
--- a/clock.c
+++ b/clock.c
struct tm * timeinfo;
timeinfo = localtime ( &rawtime );
- if( timeinfo->tm_sec != oldsec );
+ if( timeinfo->tm_sec != oldsec )
{
gtk_widget_queue_draw( GTK_WIDGET( data ) );
}
//tm_sec tm_min tm_hour
int hour=timeinfo->tm_hour;
int minute=timeinfo->tm_min;
- int second=timeinfo->tm_sec;
//hour+=minute/60;
char ampm[3]="am";
if(hour>=12)
diff --git a/dock_icon.c b/dock_icon.c
index 7099e8426ef3821c412b7ed9df8e276b54134a81..07076e2955d5a33aeece9a53003a899aaa722531 100644 (file)
--- a/dock_icon.c
+++ b/dock_icon.c
#include "ericdock.h"
#include "dock_icon.h"
#include "tooltip_window.h"
+#include "xutils.h"
-dock_icon* dock_icon_create( WnckClassGroup* class_group )
+#include <stdio.h>
+#include <ctype.h>
+#include <glib.h>
+
+dock_icon* dock_icon_create( WnckWindow* window )
{
dock_icon* icon = malloc( sizeof( dock_icon ) );
- icon->class_group = class_group;
- icon->icon_pixbuf = wnck_class_group_get_icon( class_group );
+ 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 ) );
icon->pager_items = NULL;
icon->icon_state = ICON_STATE_NORMAL;
+ printf( "Attempted dock icon get%s \n", wnck_class_group_get_id( icon->class_group ) );
+
icon->width = SCALE_VALUE( BAR_HEIGHT - 6.0 );
icon->height = SCALE_VALUE( BAR_HEIGHT );
dock_icon_activate( icon, time, TRUE );
}
}
+
+gchar* get_icon_from_desktop( const char* name )
+{
+ GKeyFile* key_file = g_key_file_new();
+ gchar file[256];
+
+ sprintf( file, "/usr/share/applications/%s.desktop", name );
+ if( !g_key_file_load_from_file( key_file, file, G_KEY_FILE_NONE, NULL ) )
+ return NULL;
+
+ return g_key_file_get_string( key_file, G_KEY_FILE_DESKTOP_GROUP, "Icon", NULL );
+}
+
+/* Gets the pixbuf from a desktop file's icon name. Based on the same function * from matchbox-desktop
+ */
+GdkPixbuf* get_icon( WnckWindow* window, guint size )
+{
+ static GtkIconTheme* theme = NULL;
+ GdkPixbuf* pixbuf = NULL;
+ gchar* stripped = NULL;
+ const gchar* class_name = wnck_window_get_class_group_name( window );
+ const gchar* instance_name = wnck_window_get_class_instance_name( window );
+ gchar instance_lower[256] = {0};
+ gchar class_lower[256] = {0};
+ gint width, height;
+
+
+ if (theme == NULL) {
+ theme = gtk_icon_theme_get_default();
+ }
+
+ printf( "class: %s\ninstance%s\n",
+ class_name,
+ instance_name );
+ int i;
+ for( i = 0; class_name[i] && i < 256; i++ )
+ class_lower[i] = tolower( class_name[i] );
+ for( i = 0; instance_name[i] && i < 256; i++ )
+ instance_lower[i] = tolower( instance_name[i] );
+
+ //Use the window's icon
+ if( strcmp( class_lower, instance_lower ) != 0 )
+ {
+ pixbuf = wnck_window_get_icon( window );
+ }
+
+ //Check for desktop file entry
+ if( pixbuf == NULL )
+ {
+ gchar* icon_name = get_icon_from_desktop( instance_name );
+ if( icon_name != NULL )
+ pixbuf = gtk_icon_theme_load_icon( theme, icon_name,
+ size, GTK_ICON_LOOKUP_FORCE_SIZE, NULL );
+ }
+
+ /* Always try and send back something */
+ if (pixbuf == NULL)
+ pixbuf = wnck_window_get_icon( window );
+ if (pixbuf == NULL)
+ pixbuf = gtk_icon_theme_load_icon(theme, "application-x-executable",
+ size, 0, NULL);
+
+ width = gdk_pixbuf_get_width(pixbuf);
+ height = gdk_pixbuf_get_height(pixbuf);
+
+ if (width != size || height != size) {
+ GdkPixbuf* temp = pixbuf;
+ pixbuf = gdk_pixbuf_scale_simple(temp,
+ size,
+ size,
+ GDK_INTERP_HYPER);
+ g_object_unref(temp);
+ }
+
+ g_free(stripped);
+
+ return pixbuf;
+}
+
+/* From matchbox-desktop */
+char* strip_extension (const char *file)
+{
+ char *stripped, *p;
+
+ stripped = g_strdup (file);
+
+ p = strrchr (stripped, '.');
+ if (p &&
+ (!strcmp (p, ".png") ||
+ !strcmp (p, ".svg") ||
+ !strcmp (p, ".xpm")))
+ *p = 0;
+
+ return stripped;
+}
+
diff --git a/dock_icon.h b/dock_icon.h
index d0a9fc913109bda6a952dfc17c0fc62004667d5b..59a92f620bc43b9762c4e1bcc8fd6d8c7297b1e4 100644 (file)
--- a/dock_icon.h
+++ b/dock_icon.h
* renders/handles events based on how many pager_items it contains
*/
#include <gtk/gtk.h>
+#include <gdk/gdk.h>
#include <X11/Xlib.h>
#include <time.h>
int icon_state;
int is_active;
int selected_index;
+ gchar* instance_name;
} dock_icon;
-dock_icon* dock_icon_create( WnckClassGroup* class_group );
+dock_icon* dock_icon_create( WnckWindow* window );
pager_item* dock_icon_get_next_pager_item( dock_icon* icon );
void dock_icon_clear_pager_item_state( dock_icon* icon );
void dock_icon_activate( dock_icon* icon, Time time, int from_click );
void dock_icon_mouse_down( dock_icon* icon, double mx, double my, Time time );
+GdkPixbuf* get_icon( WnckWindow* window, guint size );
+char * strip_extension (const char *file);
diff --git a/eric_window.c b/eric_window.c
index 246307d2947d09daeb57942a8e15e12039c17679..1e76486d648121567fffa85391fa744ab3afbbfe 100644 (file)
--- a/eric_window.c
+++ b/eric_window.c
w->draw_callback = NULL;
if( title == NULL )
+ {
title = "eric window";
+ }
w->window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
gtk_window_set_title( GTK_WINDOW( w->window ), title );
index 2af30f04e69e513d51ad2f174b86c94501205a97..29ad61c4047f6aaad4fa0c6d4ebf6e30e27af115 100644 (file)
--- a/main.c
+++ b/main.c
#include "dock_icon.h"
#include "tooltip_window.h"
+#include "xutils.h"
int screen_width;
int screen_height;
dock_icon *icon, *new_dock_icon;
WnckClassGroup* class = wnck_window_get_class_group( window );
+ 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;
- if( icon->class_group == class )
+ if( strcmp( icon->instance_name, instance_name ) == 0 )
{
icon->pager_items = g_list_append( icon->pager_items, pager_item_create( window ) );
found_class_group = 1;
if( !found_class_group )
{
//Add a new dock item
- new_dock_icon = dock_icon_create( class );
+ new_dock_icon = dock_icon_create( window );
new_dock_icon->pager_items = g_list_append(
new_dock_icon->pager_items,
pager_item_create( window )
diff --git a/pager_item.c b/pager_item.c
index 5cd586628d6108494f280957e8378ef7a38c7271..4c9886fdbe1f125579620b47add45b585b202362 100644 (file)
--- a/pager_item.c
+++ b/pager_item.c
#include "ericdock.h"
#include "drawing.h"
+#include "dock_icon.h"
void pager_item_name_changed( WnckWindow* window, pager_item* item )
{
void pager_item_icon_changed( WnckWindow* window, pager_item* item )
{
- item->icon_pixbuf = wnck_window_get_mini_icon( window );
+ item->icon_pixbuf = get_icon( window, (int)SCALE_VALUE( 16.0 ) );
}
void pager_item_state_changed( WnckWindow* window, WnckWindowState changed_mask, WnckWindowState new_state, pager_item* item )
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_pixbuf = get_icon( window, (int)SCALE_VALUE( 16.0 ) );
item->icon_state = ICON_STATE_NORMAL;
g_signal_connect( G_OBJECT( window ), "name-changed", G_CALLBACK( pager_item_name_changed ), (gpointer)item );
diff --git a/tooltip_window.c b/tooltip_window.c
index c89acd7ba2e141b36a7ed360113da82a5d9fb25d..dbc8f8bb051c8e8a0ed63dcbd98c3f54d977c7bc 100644 (file)
--- a/tooltip_window.c
+++ b/tooltip_window.c
@@ -27,13 +27,11 @@ void tooltip_window_mouse_down( GtkWidget* widget, GdkEvent* event, gpointer use
if( e->button != 1 )
return;
- double mx, my;
- double it, ib, il, ir;
- dock_icon* icon;
pager_item* item;
GList* pager_list;
- mx = e->x; my = e->y;
+ double my;
+ my = e->y;
for( pager_list = tooltip_window_icon->pager_items; pager_list != NULL; pager_list = pager_list->next )
{
item = pager_list->data;
gboolean tooltip_window_mouse_move( GtkWidget* widget, GdkEvent* event, gpointer user )
{
double mx, my;
- double it, ib, il, ir;
- int old_state, new_state, state_changed;
- dock_icon* icon;
+ int state_changed;
pager_item* item;
- GList *icon_list, *item_list;
+ GList *item_list;
GdkEventMotion* e = (GdkEventMotion*)event;
mx = e->x;
}
cairo_pattern_destroy( pattern );
+
+ return FALSE;
}
void tooltip_window_show()
{
- int wx, wy;
- int w, h;
-
tooltip_window_update_geometry();
gtk_widget_show_all( tooltip_window->window );
gtk_widget_queue_draw( tooltip_window->window );