Skip to content

Commit

Permalink
Add img/gtkwrite.ico auto-sized:64,32,24,15, finish cleanup of sysdat…
Browse files Browse the repository at this point in the history
…adir handling on win32/win64.
  • Loading branch information
David C. Rankin committed Aug 15, 2017
1 parent 680e28f commit 4cd4d51
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 55 deletions.
3 changes: 3 additions & 0 deletions gtk_appdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ static void context_set_defaults (kwinst *app, char **argv)
#ifndef HAVEMSWIN
app->usrdatadir = g_strdup_printf ("%s/%s", g_get_user_data_dir(), CFGDIR);
app->sysdatadir = g_strdup (NIXSHARE);
app->imgdir = g_strdup_printf ("%s/%s", app->sysdatadir, IMGDIR);
#else
gchar *usrdata = get_posix_filename (g_get_user_data_dir());
app->usrdatadir = g_strdup_printf ("%s/%s", usrdata, CFGDIR);
app->sysdatadir = g_strdup (g_path_get_dirname(argv[0]));
app->imgdir = g_strdup_printf ("%s/%s", app->sysdatadir, IMGDIR);
g_free (usrdata);
#endif
#ifdef DEBUG
Expand Down Expand Up @@ -450,6 +452,7 @@ void context_destroy (kwinst *app)
if (app->exename) g_free (app->exename);
if (app->usrdatadir) g_free (app->usrdatadir);
if (app->sysdatadir) g_free (app->sysdatadir);
if (app->imgdir) g_free (app->imgdir);
if (app->fontname) g_free (app->fontname);

// if (app->appname) g_free (app->appname);
Expand Down
6 changes: 4 additions & 2 deletions gtk_appdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@
#define CFGDIR "gtkwrite"
#define CFGFILE "gtkwrite.cfg"
#define IMGDIR "img"
#define LOGOFILE "gtkwrite.png"
#define LOGO "gtkwrite.png"
#define ICON "gtkwrite.ico"

/* TODO: dynamically strip 'Program Files' from from app->exename
* and replace with progra~1 or progra~2 below to preserve correct
* logo display for 'protable' installs.
Expand Down Expand Up @@ -77,7 +79,7 @@ typedef struct {
const gchar *user; /* current username */
gchar *usrdatadir; /* user data dir */
gchar *sysdatadir; /* system data dir */
gchar *logofile; /* logo file 128px */
gchar *imgdir; /* image directory */

GtkWidget *window; /* main window */
GtkWidget *view; /* text_view */
Expand Down
29 changes: 0 additions & 29 deletions gtk_filemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,32 +250,3 @@ void file_monitor_unblock_changed (gpointer data)

g_signal_handler_unblock (app->filemon, app->mfp_handler);
}

/*
gchar *pn = g_file_get_parse_name (gfile);
g_print ("added watch for '%s' (%s)\n", fn, pn);
// from file_monitor_block_changed and file_monitor_unblock_changed
// if (app->mfp_handler) {
// g_signal_handler_disconnect (G_OBJECT(app->filemon), app->mfp_handler);
// app->mfp_handler = 0;
// }
// file_monitor_cancel (app);
// if (!app->mfp_handler) {
// app->mfp_handler = g_signal_connect (G_OBJECT(app->filemon), "changed",
// G_CALLBACK (file_monitor_on_changed), data);
// }
// file_monitor_add (app);
// general scrps under block/unblock
// g_file_monitor_emit_event (filemon, gfile, NULL,
// G_FILE_MONITOR_EVENT_CHANGED);
// g_file_monitor_emit_event (filemon, gfile, NULL,
// G_FILE_MONITOR_EVENT_DELETED);
*/
26 changes: 3 additions & 23 deletions gtk_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1351,28 +1351,6 @@ void menu_help_about_activate (GtkMenuItem *menuitem, kwinst *app)
* general window functions
*/

gchar *get_logo_filename (kwinst *app)
{
/* check system_data_dir/IMGDIR/LOGOFILE first, e.g /usr/share */
gchar *fn = g_strdup_printf ("%s/%s/%s", app->sysdatadir, IMGDIR, LOGOFILE);
if (g_file_test (fn, G_FILE_TEST_EXISTS))
return fn;

if (fn)
g_free (fn);
fn = NULL;

/* check user_data_dir/IMGDIR/LOGOFILE next (e.g, ~/.local/share */
fn = g_strdup_printf ("%s/%s/%s", app->usrdatadir, IMGDIR, LOGOFILE);
if (g_file_test (fn, G_FILE_TEST_EXISTS))
return fn;

if (fn)
g_free (fn);

return NULL;
}

void help_about (kwinst *app)
{
gchar *buf, *logofn;
Expand All @@ -1390,7 +1368,9 @@ void help_about (kwinst *app)
static const gchar comments[] = APPSTR;

/* create pixbuf from logofn to pass to show_about_dialog */
if ((logofn = get_logo_filename (app))) {
// if ((logofn = get_logo_filename (app))) {
if ((logofn = g_strdup_printf ("%s/%s", app->imgdir, LOGO))) {
// g_print ("logofn : '%s'\n", logofn);
logo = create_pixbuf_from_file (logofn);
g_free (logofn);
}
Expand Down
8 changes: 8 additions & 0 deletions gtk_windef.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ GtkWidget *create_window (kwinst *app)
guint pleft;
guint pright;

gchar *iconfile; /* filename to loading icon */

/* create toplevel window */
if (!(app->window = gtk_window_new (GTK_WINDOW_TOPLEVEL))) {
err_dialog ("create_window() gtk_window_new failure.");
Expand All @@ -36,6 +38,12 @@ GtkWidget *create_window (kwinst *app)
gtk_window_set_default_size (GTK_WINDOW (app->window), app->winwidth, app->winheight);
// gtk_window_move (GTK_WINDOW (app->window), app->winrootx, app->winrooty);

/* create icon filename and set icon */
if ((iconfile = g_strdup_printf ("%s/%s", app->imgdir, ICON))) {
gtk_window_set_icon(GTK_WINDOW(app->window), create_pixbuf_from_file (iconfile));
g_free (iconfile);
}

/* create & attach accelerator group */
mainaccel = gtk_accel_group_new ();
gtk_window_add_accel_group (GTK_WINDOW (app->window), mainaccel);
Expand Down
Binary file added img/gtkwrite.ico
Binary file not shown.
3 changes: 2 additions & 1 deletion styles/gtkwrite_light.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
<!-- Palette -->
<color name="bgblack" value="#06090D"/>
<color name="bgblackhlt" value="#121928"/>
<color name="bgwhitehlt" value="#ecf5f9"/>
<color name="bgwhitehlt" value="#dff2ff"/>
<!-- <color name="bgwhitehlt" value="#ecf5f9"/> -->
<!-- <color name="bgwhitehlt" value="#e6f7ff"/> -->
<!-- <color name="bgwhitehlt" value="#CDEAFF"/> -->
<color name="bgblue" value="#0E141F"/>
Expand Down

0 comments on commit 4cd4d51

Please sign in to comment.