Commit cc8bb12e authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

Add the standard cli arguments to the gtk helpers.

parent a1953566
......@@ -26,6 +26,17 @@
#include <stdlib.h>
#include <sys/inotify.h>
#include <string.h>
void printHelp(const char* bin)
{
printf(
"%s <args>\n"
" -h|--help\tShows this help\n"
" -v|--version\tPrints the program version\n"
" <winid>\t Creates a window that can be embedded using XEmbed\n", bin
);
}
static void on_dlg_response(GtkDialog* dlg, int res, gpointer user_data)
{
......@@ -41,9 +52,18 @@ int main(int argc, char **argv)
GError *error = NULL;
unsigned long wid=0;
gtk_init( &argc, &argv );
int i;
for(i=0; i<argc; i++) {
if(strcmp("-h", argv[i])==0 || strcmp("--help", argv[i])==0) {
printHelp(argv[0]);
return 0;
}
else if(strcmp("-v", argv[i])==0 || strcmp("--version", argv[i])==0)
printf("%s version 1.0\n", argv[0]);
else
sscanf(argv[1], "%ld", &wid);
}
if(argc==2)
sscanf(argv[1], "%ld", &wid);
const char* ui_file = DATA_DIR "/preview.ui";
GtkBuilder *builder = gtk_builder_new();
......
......@@ -23,6 +23,7 @@
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
static void on_dlg_response(GtkDialog* dlg, int res, gpointer user_data)
{
......@@ -47,14 +48,32 @@ void reloadstyle(GFileMonitor *monitor,
fprintf(stderr, "settings changed!!\n");
}
void printHelp(const char* bin)
{
printf(
"%s <args>\n"
" -h|--help\tShows this help\n"
" -v|--version\tPrints the program version\n"
" <winid>\t Creates a window that can be embedded using XEmbed\n", bin
);
}
int main(int argc, char **argv)
{
GError *error = NULL;
unsigned long wid=0;
if(argc==2)
sscanf(argv[1], "%ld", &wid);
/* fprintf(stderr, "holaaa %ld %s\n", argc, argv[1]);*/
gtk_init( &argc, &argv );
int i;
for(i=0; i<argc; i++) {
if(strcmp("-h", argv[i])==0 || strcmp("--help", argv[i])==0) {
printHelp(argv[0]);
return 0;
}
else if(strcmp("-v", argv[i])==0 || strcmp("--version", argv[i])==0)
printf("%s version 1.0\n", argv[0]);
else
sscanf(argv[1], "%ld", &wid);
}
const char* ui_file = DATA_DIR "/preview.ui";
GtkBuilder *builder = gtk_builder_new();
......
......@@ -22,7 +22,17 @@
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
#include <stdio.h>
#include <string.h>
void printHelp(const char* bin)
{
printf(
"%s <args>\n"
" -h|--help\tShows this help\n"
" -v|--version\tPrints the program version\n"
" <winid>\t Creates a window that can be embedded using XEmbed\n", bin
);
}
GdkEventClient createEvent()
{
GdkEventClient event;
......@@ -38,16 +48,17 @@ GdkEventClient createEvent()
int main(int argc, char** argv)
{
gtk_init(&argc, &argv);
int winid=0;
if(argc==2)
sscanf(argv[1], "%d", &winid);
int i;
for(i=0; i<argc; i++) {
if(strcmp("-h", argv[i])==0 || strcmp("--help", argv[i])==0) {
printHelp(argv[0]);
return 0;
}
else if(strcmp("-v", argv[i])==0 || strcmp("--version", argv[i])==0)
printf("%s version 1.0\n", argv[0]);
}
GdkEventClient event = createEvent();
printf("Reload all apps!!!! %d\n", winid);
/* NOTE: not working for some reason...
if(winid)
gdk_event_send_client_message((GdkEvent *)&event, winid);*/
gdk_event_send_clientmessage_toall((GdkEvent *)&event);
return 0;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment