Skip to content

Commit 3d61e24

Browse files
committed
Fixed #14 + random fixes
1 parent 31cefe5 commit 3d61e24

6 files changed

Lines changed: 93 additions & 30 deletions

File tree

src/functions.c renamed to src/connect.c

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -115,24 +115,7 @@ void connectRDP() {
115115
system(connectString);
116116
}
117117
allowConnect = 0;
118+
} else {
119+
printf("Please enter a vailid IP and port.\n");
118120
}
119121
}
120-
121-
void openDialog() {
122-
gtk_widget_show(dialog);
123-
}
124-
125-
void closeDialog() {
126-
gtk_widget_hide(dialog);
127-
}
128-
129-
void rdExists() {
130-
if(access(rdPath, R_OK) == -1) {
131-
printf("Could not find rdesktop, make sure you have it installed and have permission to run it.\n");
132-
gtk_widget_show(rdesktopError);
133-
}
134-
}
135-
136-
void closeRdesktopError() {
137-
gtk_widget_hide(rdesktopError);
138-
}

src/gresource.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
<file alias="glade_file" preprocess="xml-stripblanks">src/rdg.glade</file>
55
<file>src/icon.png</file>
66
</gresource>
7-
</gresources>
7+
</gresources>

src/main.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@
44
*/
55

66
#include "vars.h"
7-
#include "functions.c"
7+
#include "connect.c"
8+
#include "window.c"
89
#include "resources.c"
910

1011
int main(int argc, char *argv[])
11-
{
12+
{
1213
if(!DEV && argc == 1) {
13-
system("./rdg -start & disown");
14+
startRDG();
15+
char startString[PATH_MAX];
16+
sprintf(startString, "%s -start & disown", rdgPath);
17+
system(startString);
1418
exit(1);
1519
}
1620

src/rdg.glade

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<!-- Generated with glade 3.20.1
2+
<!-- Generated with glade 3.20.2
33
44
Copyright (C) olback
55
https://github.com/olback/rdg-linux
@@ -626,16 +626,19 @@ The special value `none' can be used instead of a keyboard map. In this case, rd
626626
</object>
627627
<object class="GtkWindow" id="rdesktopError">
628628
<property name="width_request">330</property>
629-
<property name="height_request">150</property>
629+
<property name="height_request">210</property>
630630
<property name="can_focus">False</property>
631631
<property name="title" translatable="yes">rdesktop not found</property>
632+
<property name="resizable">False</property>
632633
<property name="modal">True</property>
633634
<property name="window_position">center</property>
634635
<property name="default_width">330</property>
635636
<property name="default_height">150</property>
636637
<property name="icon_name">dialog-error</property>
637638
<property name="type_hint">dialog</property>
639+
<property name="skip_taskbar_hint">True</property>
638640
<property name="skip_pager_hint">True</property>
641+
<property name="urgency_hint">True</property>
639642
<property name="gravity">center</property>
640643
<child>
641644
<object class="GtkFixed">
@@ -653,7 +656,7 @@ The special value `none' can be used instead of a keyboard map. In this case, rd
653656
</object>
654657
<packing>
655658
<property name="x">115</property>
656-
<property name="y">110</property>
659+
<property name="y">165</property>
657660
</packing>
658661
</child>
659662
<child>
@@ -673,7 +676,7 @@ The special value `none' can be used instead of a keyboard map. In this case, rd
673676
</child>
674677
<child>
675678
<object class="GtkLabel">
676-
<property name="width_request">100</property>
679+
<property name="width_request">221</property>
677680
<property name="height_request">80</property>
678681
<property name="visible">True</property>
679682
<property name="can_focus">False</property>
@@ -686,9 +689,41 @@ installed and permission to run it.</property>
686689
<property name="y">15</property>
687690
</packing>
688691
</child>
692+
<child>
693+
<object class="GtkLinkButton" id="rdesktopErrorLabel">
694+
<property name="label" translatable="yes">here</property>
695+
<property name="width_request">55</property>
696+
<property name="height_request">28</property>
697+
<property name="visible">True</property>
698+
<property name="can_focus">True</property>
699+
<property name="receives_default">True</property>
700+
<property name="tooltip_text" translatable="yes">hello?</property>
701+
<property name="relief">none</property>
702+
<property name="uri">https://github.com/olback/rdg-linux/issues</property>
703+
</object>
704+
<packing>
705+
<property name="x">160</property>
706+
<property name="y">127</property>
707+
</packing>
708+
</child>
709+
<child>
710+
<object class="GtkLabel">
711+
<property name="width_request">197</property>
712+
<property name="height_request">60</property>
713+
<property name="visible">True</property>
714+
<property name="can_focus">False</property>
715+
<property name="label" translatable="yes">Do you have rdesktop installed
716+
but still get this error? Please
717+
open a ticket</property>
718+
</object>
719+
<packing>
720+
<property name="x">87</property>
721+
<property name="y">92</property>
722+
</packing>
723+
</child>
689724
</object>
690725
</child>
691-
<child>
726+
<child type="titlebar">
692727
<placeholder/>
693728
</child>
694729
</object>

src/vars.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
* github.com/olback/rdg-linux
44
*/
55

6-
#define DEV FALSE
6+
#define DEV FALSE // TRUE/FALSE
77

88
#include <stdio.h>
99
#include <stdlib.h>
1010
#include <string.h>
1111
#include <unistd.h>
1212
#include <gtk/gtk.h>
1313

14-
char title[64] = "rDesktop GUI 1.2";
14+
char title[64] = "rDesktop GUI 1.3";
1515
const char rdPath[] = "/usr/bin/rdesktop";
1616

1717
// Global variables bla bla don't care.
@@ -28,6 +28,7 @@ char extraRDA[512];
2828

2929
int allowConnect = 0;
3030
char connectString[2048];
31+
char rdgPath[PATH_MAX];
3132

3233
GtkBuilder *builder;
3334

src/window.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* olback.net © 2017
3+
* github.com/olback/rdg-linux
4+
*/
5+
6+
void openDialog() {
7+
gtk_widget_show(dialog);
8+
}
9+
10+
void closeDialog() {
11+
gtk_widget_hide(dialog);
12+
}
13+
14+
void rdExists() {
15+
if(access(rdPath, R_OK) == -1) {
16+
printf("Could not find rdesktop, make sure you have it installed.\n");
17+
gtk_widget_show(rdesktopError);
18+
}
19+
}
20+
21+
void closeRdesktopError() {
22+
gtk_widget_hide(rdesktopError);
23+
}
24+
25+
void startRDG() {
26+
27+
char path[PATH_MAX];
28+
char dest[PATH_MAX];
29+
memset(dest, 0, sizeof(dest)); // readlink does not null terminate!
30+
struct stat;
31+
pid_t pid = getpid();
32+
sprintf(path, "/proc/%d/exe", pid);
33+
if(readlink(path, dest, PATH_MAX) == -1){
34+
perror("readlink");
35+
} else {
36+
//printf("%s\n", dest);
37+
sprintf(rdgPath, "%s", dest);
38+
}
39+
40+
}

0 commit comments

Comments
 (0)