New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default icon #310

Closed
nimday opened this Issue Apr 18, 2016 · 13 comments

Comments

Projects
None yet
5 participants
@nimday

nimday commented Apr 18, 2016

The default icon for a window is square not x anymore,is possible to add custom icon as alternative ?
Many of my apps(fltk) don't have icon and i want to use my own if possible.
Thanks.

@Israel-D

This comment has been minimized.

Show comment
Hide comment
@Israel-D

Israel-D Apr 18, 2016

Contributor

@nimday Are they apps you have written? if so you can add icons to fltk apps (not entirely as easily as one would hope), but it is doable.

#include <X11/xpm.h>
#include <FL/x.H>
char* YourCLASS::Get_Fl_Icon(const char** pIcon){
    static Pixmap p= 0;
    // static store of assigned icon
    static Pixmap mask;
    if (!p && pIcon){
        // assign icon once
        fl_open_display();
        XpmCreatePixmapFromData(fl_display, DefaultRootWindow(fl_display),
(char**) pIcon, &p, &mask, 0);
    }
    return (char*) p;
}

Just make sure your icon is xpm and structured like

static const char* icon_name[] = {
/*whatever*/
}

You can probably figure out the rest yeah?

Contributor

Israel-D commented Apr 18, 2016

@nimday Are they apps you have written? if so you can add icons to fltk apps (not entirely as easily as one would hope), but it is doable.

#include <X11/xpm.h>
#include <FL/x.H>
char* YourCLASS::Get_Fl_Icon(const char** pIcon){
    static Pixmap p= 0;
    // static store of assigned icon
    static Pixmap mask;
    if (!p && pIcon){
        // assign icon once
        fl_open_display();
        XpmCreatePixmapFromData(fl_display, DefaultRootWindow(fl_display),
(char**) pIcon, &p, &mask, 0);
    }
    return (char*) p;
}

Just make sure your icon is xpm and structured like

static const char* icon_name[] = {
/*whatever*/
}

You can probably figure out the rest yeah?

@nimday

This comment has been minimized.

Show comment
Hide comment
@nimday

nimday Apr 18, 2016

Thanks for the code i'll try that,the apps mostly made by the notorious tiny core team and the editor from fltk test folder :)
I can change x.xpm with my own but not anymore.

nimday commented Apr 18, 2016

Thanks for the code i'll try that,the apps mostly made by the notorious tiny core team and the editor from fltk test folder :)
I can change x.xpm with my own but not anymore.

@technosaurus

This comment has been minimized.

Show comment
Hide comment
@technosaurus

technosaurus Apr 18, 2016

Contributor

IIRC you can just put an icon (or symlink to one) with the same name as your executable in your icon path.

Contributor

technosaurus commented Apr 18, 2016

IIRC you can just put an icon (or symlink to one) with the same name as your executable in your icon path.

@Israel-D

This comment has been minimized.

Show comment
Hide comment
@Israel-D

Israel-D Apr 18, 2016

Contributor

@technosaurus that worked in JWM for a short while, however something was changed to make everything better. FLTK recently added something easier, IIRC but it might not be available in @nimday distro's repos.
So unfortunately the apps have to tell the window manager what icon to use, though for menus you are correct @technosaurus
@nimday can you point me a link to those apps? I like tiny FLTK apps a lot, it is my toolkit preference for many things.

Contributor

Israel-D commented Apr 18, 2016

@technosaurus that worked in JWM for a short while, however something was changed to make everything better. FLTK recently added something easier, IIRC but it might not be available in @nimday distro's repos.
So unfortunately the apps have to tell the window manager what icon to use, though for menus you are correct @technosaurus
@nimday can you point me a link to those apps? I like tiny FLTK apps a lot, it is my toolkit preference for many things.

@nimday

This comment has been minimized.

Show comment
Hide comment
@nimday

nimday Apr 18, 2016

@technosaurus , i think @israel is right,that only for the menu and taskbar not for the titlebar
Below screenshots from my old jwm from tcl repo,2.3.5 and 2.3.2 from @Miteam

http://s5.postimg.org/kkjblbgmf/screenshot_0419020319.png
http://s5.postimg.org/q9zk5mmsn/screenshot_0419021829.png
http://s5.postimg.org/iiiu72inb/screenshot_0419023408.png

No icon from the taskbar from 2.3.5 except from @Miteam , i even tried 2.3.6
If this for good reason no problem but if possible to add this manually for my own personal use please let me know :)

@israel this is the link for Tcl source
http://git.tinycorelinux.net/index.cgi?url=fltk_projects/

nimday commented Apr 18, 2016

@technosaurus , i think @israel is right,that only for the menu and taskbar not for the titlebar
Below screenshots from my old jwm from tcl repo,2.3.5 and 2.3.2 from @Miteam

http://s5.postimg.org/kkjblbgmf/screenshot_0419020319.png
http://s5.postimg.org/q9zk5mmsn/screenshot_0419021829.png
http://s5.postimg.org/iiiu72inb/screenshot_0419023408.png

No icon from the taskbar from 2.3.5 except from @Miteam , i even tried 2.3.6
If this for good reason no problem but if possible to add this manually for my own personal use please let me know :)

@israel this is the link for Tcl source
http://git.tinycorelinux.net/index.cgi?url=fltk_projects/

@Israel-D

This comment has been minimized.

Show comment
Hide comment
@Israel-D

Israel-D Apr 18, 2016

Contributor

@nimday I tried a few of them. Most are extremely tinycore oriented, and wont 'just work'
The run dialog is nice, but does not work for commands.
It is a simple modification to do that.
You can manually add the function I sent you, but you do not need to make a class... install fluid and open the fl file. Add a function, include the xpm you make (up top in the #include portion)
and call the function when the main window is drawn, with the icon_name from inside the xpm icon.
That is how I do it for my apps anyways.

Contributor

Israel-D commented Apr 18, 2016

@nimday I tried a few of them. Most are extremely tinycore oriented, and wont 'just work'
The run dialog is nice, but does not work for commands.
It is a simple modification to do that.
You can manually add the function I sent you, but you do not need to make a class... install fluid and open the fl file. Add a function, include the xpm you make (up top in the #include portion)
and call the function when the main window is drawn, with the icon_name from inside the xpm icon.
That is how I do it for my apps anyways.

@nimday

This comment has been minimized.

Show comment
Hide comment
@nimday

nimday Apr 19, 2016

@israel,can you create 1 or 2 dummy app with fltk without icon and test it with jwm 2.3.5 or the latest.
I can see the default square icon from the panel from 2.3.3 but not the latest.
If the same result like me maybe @joewing can check.

For change the default icon with custom forget it,i can create app with icon as suggested by @israel
Or small modification to GetDefaultIcon from icon.c

/* Check if this icon has already been loaded */
   result = FindIcon(name);
   if(result) {
      return result;
   }
   //mod
   image = LoadImageFromData(x_xpm);
   if(image) {
      result = CreateIcon(image);
      if(result){
        result->name = CopyString(name);
        result->images = image;
        InsertIcon(result);
        return result;
      }
   }
   /* Allocate image data. *

nimday commented Apr 19, 2016

@israel,can you create 1 or 2 dummy app with fltk without icon and test it with jwm 2.3.5 or the latest.
I can see the default square icon from the panel from 2.3.3 but not the latest.
If the same result like me maybe @joewing can check.

For change the default icon with custom forget it,i can create app with icon as suggested by @israel
Or small modification to GetDefaultIcon from icon.c

/* Check if this icon has already been loaded */
   result = FindIcon(name);
   if(result) {
      return result;
   }
   //mod
   image = LoadImageFromData(x_xpm);
   if(image) {
      result = CreateIcon(image);
      if(result){
        result->name = CopyString(name);
        result->images = image;
        InsertIcon(result);
        return result;
      }
   }
   /* Allocate image data. *
@Israel-D

This comment has been minimized.

Show comment
Hide comment
@Israel-D

Israel-D Apr 19, 2016

Contributor

@nimday I just thought of another slightly more complicated/simple idea
Your programs could be wrapped in a script that uses wmctrl to set the icon.

APP & wmctrl -r "APP Window Title" -I "Icon"
you can do complicated things to get the window, something like

#!/bin/bash
APP="$1"
ICON="$2"
[[ -n "$1 ]] && exit 1
[[ -n "$2 ]] && exit 1
$APP &
pid=$(pgrep -n $APP)
wid=
while [ "$wid" == "" ]
do
  wid=$(wmctrl -lp | grep "$pid" | cut -d' ' -f1)
done
 wmctrl -r "$wid" -I "$Icon" 

then run the script with app name and icon for your exec

Contributor

Israel-D commented Apr 19, 2016

@nimday I just thought of another slightly more complicated/simple idea
Your programs could be wrapped in a script that uses wmctrl to set the icon.

APP & wmctrl -r "APP Window Title" -I "Icon"
you can do complicated things to get the window, something like

#!/bin/bash
APP="$1"
ICON="$2"
[[ -n "$1 ]] && exit 1
[[ -n "$2 ]] && exit 1
$APP &
pid=$(pgrep -n $APP)
wid=
while [ "$wid" == "" ]
do
  wid=$(wmctrl -lp | grep "$pid" | cut -d' ' -f1)
done
 wmctrl -r "$wid" -I "$Icon" 

then run the script with app name and icon for your exec

@israel

This comment has been minimized.

Show comment
Hide comment
@israel

israel Apr 19, 2016

You've got the wrong user -:)
On Tue, 19 Apr 2016 at 19:38 Israel notifications@github.com wrote:

@nimday https://github.com/nimday I just thought of another slightly
more complicated/simple idea
Your programs could be wrapped in a script that uses wmctrl to set the
icon.

APP &
wmctrl -r "APP Window Title" -I "Icon"

you can do complicated things to get the window, something like

#!/bin/bash
APP="$1"
ICON="$2"
[[ -n "$1 ]] && exit 1
[[ -n "$2 ]] && exit 1
$APP &
pid=$(pgrep -n $APP)
wid=
while [ "$wid" == "" ]
do
wid=$(wmctrl -lp | grep "$pid" | cut -d' ' -f1)
done
wmctrl -r "$wid" -I "$Icon"

then run the script with app name and icon for your exec


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#310 (comment)

israel commented Apr 19, 2016

You've got the wrong user -:)
On Tue, 19 Apr 2016 at 19:38 Israel notifications@github.com wrote:

@nimday https://github.com/nimday I just thought of another slightly
more complicated/simple idea
Your programs could be wrapped in a script that uses wmctrl to set the
icon.

APP &
wmctrl -r "APP Window Title" -I "Icon"

you can do complicated things to get the window, something like

#!/bin/bash
APP="$1"
ICON="$2"
[[ -n "$1 ]] && exit 1
[[ -n "$2 ]] && exit 1
$APP &
pid=$(pgrep -n $APP)
wid=
while [ "$wid" == "" ]
do
wid=$(wmctrl -lp | grep "$pid" | cut -d' ' -f1)
done
wmctrl -r "$wid" -I "$Icon"

then run the script with app name and icon for your exec


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#310 (comment)

@nimday

This comment has been minimized.

Show comment
Hide comment
@nimday

nimday Apr 19, 2016

@israel ,thanks again l'll try that and who is Israel Klein ?
I tried with 2.3.4 and the default icon is displayed from the panel so the problem is started from 2.3.5 and so on
Btw i pressed fork button by accident,how to remove that ?
@joewing that's all

@israel this is your working code

#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/x.H>
#include <X11/xpm.h>
#include "x.xpm"
char* Get_Fl_Icon(char** pIcon){
    static Pixmap p= 0;
    // static store of assigned icon
    static Pixmap mask;
    if (!p && pIcon){
        // assign icon once
        fl_open_display();
        XpmCreatePixmapFromData(fl_display, DefaultRootWindow(fl_display),
       (char**) pIcon, &p, &mask, 0);
    }
    return (char*) p;
}
int main(){
   Fl_Window win(200, 200,"Icon");
   win.icon(Get_Fl_Icon(x_xpm));
   win.show();
   return Fl::run();
}

nimday commented Apr 19, 2016

@israel ,thanks again l'll try that and who is Israel Klein ?
I tried with 2.3.4 and the default icon is displayed from the panel so the problem is started from 2.3.5 and so on
Btw i pressed fork button by accident,how to remove that ?
@joewing that's all

@israel this is your working code

#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/x.H>
#include <X11/xpm.h>
#include "x.xpm"
char* Get_Fl_Icon(char** pIcon){
    static Pixmap p= 0;
    // static store of assigned icon
    static Pixmap mask;
    if (!p && pIcon){
        // assign icon once
        fl_open_display();
        XpmCreatePixmapFromData(fl_display, DefaultRootWindow(fl_display),
       (char**) pIcon, &p, &mask, 0);
    }
    return (char*) p;
}
int main(){
   Fl_Window win(200, 200,"Icon");
   win.icon(Get_Fl_Icon(x_xpm));
   win.show();
   return Fl::run();
}

joewing added a commit that referenced this issue Apr 21, 2016

@joewing

This comment has been minimized.

Show comment
Hide comment
@joewing

joewing Apr 21, 2016

Owner

Sorry for not getting to this sooner. I think setting a default is probably useful (and easy to implement), so I added the ability to set a default icon (available in snapshot 1507). To set the default, use something like:

<DefaultIcon>myicon</DefaultIcon>

I also fixed the issue where the icon wasn't showing up in the task list for windows without icons.

Please let me know if that works for you.

Owner

joewing commented Apr 21, 2016

Sorry for not getting to this sooner. I think setting a default is probably useful (and easy to implement), so I added the ability to set a default icon (available in snapshot 1507). To set the default, use something like:

<DefaultIcon>myicon</DefaultIcon>

I also fixed the issue where the icon wasn't showing up in the task list for windows without icons.

Please let me know if that works for you.

@joewing joewing added the enhancement label Apr 21, 2016

@nimday

This comment has been minimized.

Show comment
Hide comment
@nimday

nimday Apr 21, 2016

Thanks a lot it's working :)

nimday commented Apr 21, 2016

Thanks a lot it's working :)

@Israel-D

This comment has been minimized.

Show comment
Hide comment
@Israel-D

Israel-D Apr 22, 2016

Contributor

@joewing Yeah I notice things working much better here too! Great improvement!!

Contributor

Israel-D commented Apr 22, 2016

@joewing Yeah I notice things working much better here too! Great improvement!!

@joewing joewing added this to the Version 2.3.6 milestone Apr 22, 2016

@joewing joewing closed this Apr 23, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment