Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

gdk issue

Programming languages, Coding, Executables, Package Creation, and Scripting.
Message
Author
rac8006
Posts: 28
Joined: 2016-05-02 15:33

gdk issue

#1 Post by rac8006 »

IS this the correct place to ask this question? I have a program that I wrote on an opensuse system that uses gdk. It puts an icon in the lower corner of the
screen to be able to switch the monitor and keyboard between different computer systems. it works on opensuse and when I run it on my Debian system it also works.
Recently I installed Debian Linux on a new system. When I run the program on the new system it runs. But does not put the icon in the corner o the screen. I don't remember
doing anything special on the first Debian system to make this work. I just copied the program from opensuse to the Debian system and it worked.

Is there anything special that needs to be installed to make a program that uses gdk, run on different systems?

Thanks
RAC

tomazzi
Posts: 730
Joined: 2013-08-02 21:33

Re: gdk issue

#2 Post by tomazzi »

rac8006 wrote:(...) I have a program that I wrote on an opensuse system that uses gdk.
(...)
I just copied the program from opensuse to the Debian system and it worked.
(...)
Is there anything special that needs to be installed to make a program that uses gdk, run on different systems?
It's funny that You're asking why a code written by You doesn't work on some other system.
Maybe it's the right time to start using debugger? :)

Linux-based distributions are not guaranteed to be compatible at the binary level - that's why each distro provides its own precompiled packages. Copying executables from one distro to another is just asking for troubles.

1. You should compile Your code for the target OS.
2. Since You are the author, then it's your responsibility to find out which portion of the code doesn't work, and why there's no warning message about some failed function call.
3. Then, and only then, You can start searching for a problems with external libraries. And only then it would make sense to ask for help, provided that You can show the sources - nobody will/can help You with a closed source software project.

Regards.
Odi profanum vulgus

User avatar
GarryRicketson
Posts: 5644
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: gdk issue

#3 Post by GarryRicketson »

IS this the correct place to ask this question?
It is the correct place.
I am not sure what you mean by " Debian Linux ".
tomazzi explains pretty well, much better then I can, but I will comment:
1. You should compile Your code for the target OS
I have several programs I have written for myself, and have found the easiest way is
compile them on the system I want it to work on, in other words these programs are not "portable", in fact I have a couple, I compiled on a laptop , running Debian wheezy,
later when I installed Debian Wheezy, the exact same version to this Desktop, those programs would not work , I had to re-compile them, for this system.

+1
Linux-based distributions are not guaranteed to be compatible at the binary level - that's why each distro provides its own precompiled packages. Copying executables from one distro to another is just asking for troubles.
rac8006 » I just copied the program from opensuse to the Debian system and it worked.
I am surprised, but yea, sometimes, especially if the program is very simple and basic, that works, but not usually and on larger more complex programs it is impossible.
rac8006 » Is there anything special that needs to be installed to make a program that uses gdk, run on different systems?
I don't know,on that I would try doing a search, perhaps use these key words:
" How do I make my gdk programs completely portable, so they work on any linux system"

Last, but not least, if you can post the source code, or make it available on a storage site, someone might be able to tell you more as to what is wrong.
Just a little Icon, something I never use in any program , is very minor, if the rest of the program works, I can not see any reason to bother. Icons are useless any way.
If you do post some or all of the source code, please use codeboxes.
I am not a good person to try to answer any of this, I stay away from both GTK and GDK, so do not really know about that. My main intention was to say yes this is the right place, "programing", and then, about the source code, nobody can really say much with out seeing that.

rac8006
Posts: 28
Joined: 2016-05-02 15:33

Re: gdk issue

#4 Post by rac8006 »

Actually I may be using the incorrect term icon. This program does what the kvmutility program does on windows. On windows an icon is placed on the task bar. When you click
the icon a window opens that allows you to select which system you want to switch the keyboard and monitor. It also allows you to specify which system the sound will be coming from.
This window also shows which of the 4 computers connected to the KVM switch is currently running. The company that sells this kvmutility does not provide a Linux version of there code.
The icon also shows a number in the icon to tell which system you are currently connected. This cod is written for the trendnet TK-409K KVM switch.

When I run the program no errors are displayed. To recompile I will have to go back and figure out what I had to install to be able to compile the gdk code.

Thanks

RAC

User avatar
stevepusser
Posts: 12930
Joined: 2009-10-06 05:53
Has thanked: 41 times
Been thanked: 71 times

Re: gdk issue

#5 Post by stevepusser »

You could try an "objdump -x" on your existing binary, see what libraries it's using, then install the "-dev" packages for those libraries. The names of the libraries may be a bit hard to track down, and can differ between distros.
MX Linux packager and developer

tomazzi
Posts: 730
Joined: 2013-08-02 21:33

Re: gdk issue

#6 Post by tomazzi »

rac8006 wrote:When I run the program no errors are displayed. To recompile I will have to go back and figure out what I had to install to be able to compile the gdk code.
Perhaps some error messages are printed to stderr -> run it in a terminal ;)

Anyway, since the program is running, then it means that all the required libraries are available, because otherwise the dynamic linker would have aborted the execution.

Unless, the program is using dlopen() - what allows to ignore some unavailable libs/functionalities - but You should already know that.

In any case, You should just check the code responsible for displaying/updating that "icon" - that doesn't need recompiling, and it should be Your first step before starting this thread - because then, You would already know if this is a problem with gdk or with your code (like ignored return value f.e.)

Yet another thing is, that You don't have to post all the source code here - it's sufficient to show only the problematic snippet. It shouldn't be a problem, unless such trivial things like putting some icon on the screen are considered to be some kind of a "secret technology" in Your company :)

Regards.
Odi profanum vulgus

rac8006
Posts: 28
Joined: 2016-05-02 15:33

Re: gdk issue

#7 Post by rac8006 »

Thanks for the reply. This was the first time I ever wrote code using gdk. I wrote this code 2 years ago.
It will take me a little time to verify that I have a good build environment.

RAC

User avatar
stevepusser
Posts: 12930
Joined: 2009-10-06 05:53
Has thanked: 41 times
Been thanked: 71 times

Re: gdk issue

#8 Post by stevepusser »

One thing I see a lot of is code calling out for a specific graphic file/icon that is only provided by certain icon packages, so if that package is not installed, nothing gets displayed.
MX Linux packager and developer

rac8006
Posts: 28
Joined: 2016-05-02 15:33

Re: gdk issue

#9 Post by rac8006 »

I recently built a new system. In the process of building this system I got rid of the oldest system which had the Opensuse 13.1 Linux. I still have
the disks. It took a little while to get it to boot. I now know that I used qt-creator as the build environment. Now it is a case of installing qt-creator
on the Debian system and build the program. At which time I can look at the source and see how the icon was displayed.

Thanks
RAC

rac8006
Posts: 28
Joined: 2016-05-02 15:33

Re: gdk issue

#10 Post by rac8006 »

I now can compile and run the program on openSUSE 13.2. I found the problem with the icon was
that I didn't have the image in the correct location. Once I corrected where the image could be
found it works. But I now realize that I need to correct where the image can be found or put the
image in the executable. Is there a place that icons are stored on disk in linux? Or should the image be
put in the executable? I'm going to research how to store an image in an executable.

RAC

User avatar
stevepusser
Posts: 12930
Joined: 2009-10-06 05:53
Has thanked: 41 times
Been thanked: 71 times

Re: gdk issue

#11 Post by stevepusser »

System icons are in /usr/share/icons. Icons that are for the use of just one program go into /usr/share/program-name/. Usually in subdirectories in those directories. Or you can just include it in the binary, I've seen that, too.
MX Linux packager and developer

rac8006
Posts: 28
Joined: 2016-05-02 15:33

Re: gdk issue

#12 Post by rac8006 »

Thanks for the information. I will make the necessary changes. But I still have the problem on Debian Linux where the tray icon does not show up.
I found that if I press the windows key and the M key the notification bar at the bottom of the screen opens up and my icon is there. On a previous version
of Debian the icon would appear at the bottom of the screen. Not sure what they called the bar at the bottom of the screen. But in the previous version it
was always there. On openSUSE 13.2 the icon appears in the bar at the bottom of the screen. I thought my icon would appear at the top of the screen
with the other items displayed at the top of the screen. Except for the icon not being seen. When you do get the icon to appear the program does what
it should when the icon is clicked on.

RAC

tomazzi
Posts: 730
Joined: 2013-08-02 21:33

Re: gdk issue

#13 Post by tomazzi »

rac8006 wrote:I'm going to research how to store an image in an executable.
This is the general way:
Embedding binary blobs using gcc

But, in case of images, there's much, much simpler method:
Gimp->open_image->export as c header or as c source :)

Regarding the primary part of Your problem: After Your last post, I'm not sure what do You mean by "putting icon on the screen" and what do You mean by "notification bar" -> methods for placing icon on a task bar, in the notification area or directly on the screen are completely diffrent.
First tell us what Desktop Environment You're using.

Regards.
Odi profanum vulgus

rac8006
Posts: 28
Joined: 2016-05-02 15:33

Re: gdk issue

#14 Post by rac8006 »

I'll have to look into what you said about gimp and c header or c source.
As for the last post. When running Debian 7 a bar is across the bottom of the screen similar to the windows task bar. When I run my program
the icon appears in this bar on the bottom. Along with programs that are minimized appear on this bar at the bottom of the screen.

Debian 8 has a bar at the top of the screen. When I open a terminal. The top bar shows an entry for the terminal. When I run my program no icon shows up.
But if I press the windows key and M key a notification bar appears at the bottom of the screen and my icon is there in this notification bar. But if I click on anything
this bar at the bottom of the screen goes away.

My debian 8 system has gnome running.

RAC

tomazzi
Posts: 730
Joined: 2013-08-02 21:33

Re: gdk issue

#15 Post by tomazzi »

I can only guess that You are using so called "application icon", f.e. by calling gtk_window_set_icon_from_file(). Such icons are handled in different ways in gnome2 and gnome3, but even in gnome3 things have changed many times in the last few years.

Anyway it's a nonsense to talk about the code without seeing the code.

Regards.
Odi profanum vulgus

rac8006
Posts: 28
Joined: 2016-05-02 15:33

Re: gdk issue

#16 Post by rac8006 »

The code is below. It works. It may not be the best way to display the icon. The problem is not with the icon it is with the task bar. Ive been googleing missing taskbar and several people are seeing the
same problem. I just can't find a fix. Everything I find does not even exist. They talk about adding a panel. I can't find a way to add a panel. will continue to try.

RAC

static GtkStatusIcon *create_tray_icon() {
GtkStatusIcon *tray_icon;
const gchar *FileName = "/backup/KVMUtility/USBKVM_134.png";

// tray_icon = gtk_status_icon_new();
tray_icon = gtk_status_icon_new_from_file(FileName);
g_signal_connect(G_OBJECT(tray_icon), "activate",
G_CALLBACK(tray_icon_on_click), NULL);
g_signal_connect(G_OBJECT(tray_icon),
"popup-menu",
G_CALLBACK(tray_icon_on_menu), NULL);
// gtk_status_icon_set_from_icon_name(tray_icon,
// GTK_STOCK_MEDIA_STOP);
gtk_status_icon_set_tooltip(tray_icon,
"Trendnet USB_KVM Switcher - 4 Ports");
gtk_status_icon_set_visible(tray_icon, TRUE);

return tray_icon;
}

tomazzi
Posts: 730
Joined: 2013-08-02 21:33

Re: gdk issue

#17 Post by tomazzi »

Ok, so everything is clear now.
gtk_status_icon_new_from_file() is deprecated - this is an old fn, kept only to not break older code.

Everything boils down to reading the documentation - I'm sorry RAC - but it's your job, which You're paid for.

HINT: perhaps You should modify Your code to use DBus notifications or maybe a libnotify interface...

Regards.
Odi profanum vulgus

rac8006
Posts: 28
Joined: 2016-05-02 15:33

Re: gdk issue

#18 Post by rac8006 »

Sorry to disappoint you. But I'm not paid to do this. It is not my job to write this code. I've been retired from programming for almost 12 years. I bought a Trendnet tk-409k KVM. It is used to connect
4 computers to one monitor/keyboard/mouse/audio. Trendnet had a utility that allows one to switch between computers. But the program only works
on windows and mac computers. Since two of my systems are Linux. I spent a lot of time figuring out how to write a program to do what there windows utility
did. I've never written code using gtk functions. Also I probably will never write gtk code again.

When I first wrote this code. I was using a openSUSE system. When the code was completed and run on the openSUSE system. The icon showed up on the task bar at the bottom
of the screen. When I tried the code on Debian 7 it worked the same as it did on openSUSE. That was about 18 months ago. Recently I installed Debian 8 and that is when the icon
didn't show up. The problem is not with gtk or the program. It is because the task bar on longer is displayed at the bottom of the screen.

Thanks for you help. I will get it working. The hardest part of this program was figuring out how to communicate with the KVM. Trendnet would give no information.

RAC

tomazzi
Posts: 730
Joined: 2013-08-02 21:33

Re: gdk issue

#19 Post by tomazzi »

Man, I can tolerate many stupid things, but You have beaten all the records: the truth is, that You have completely no idea on how to write even a basic GTK-based project. I've just wasted my time...

The only good question which is left here is: do You have any idea about what You're dealing with? maybe You should just use a VirualBox?

Regards.
Odi profanum vulgus

rac8006
Posts: 28
Joined: 2016-05-02 15:33

Re: gdk issue

#20 Post by rac8006 »

What is your frigging problem. I told you this was the first gtk program I ever wrote. I'm 73 years old. Why is it that people on these forums only want people to write perfect code.
After 40 years of working on operating systems. I've never seen perfect code. If you people wrote perfect code. I would have been out of a job. I spent 40 years traveling around the country
fixing bugs in code written by people like you. You look at my code and tell me that I'm using the wrong function. But you seem to ignore the fact that this program is talking to a usb device that has
has no specs. It can switch the keyboard/monitor/mouse between 4 systems. It can switch the audio between 4 systems or it can force the audio to stay on one of 4 systems.

But thanks for your help. Now you can go back to witting your perfect code.

RAC

Post Reply