aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab+samsung@kernel.org>2018-09-07 08:11:08 -0300
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>2018-09-07 11:42:46 -0300
commite06ec39e8bb61ed04b84516657a0002f40093e45 (patch)
tree7e2eab0b3cfc87ef8340279fd537f432ddf34b8e /src
parent8b059951c00db1e1befa59185e1945ccd181fe09 (diff)
interface.h: rename Gconf2 keys
Using KEY<number> makes harder to identify the meaning of it, as KEY* macros are also used at Linux input/evdev subsystem. Also, when something changes there, we start by having numbers skipped or needing to place stuff out of order. Finally, "PATH" is a terrible name, as it usually means the environment var. So, rename everything inside interface.h, in order to make easier to use them, and clearer that they're related to Gconf2. While here, get rid of "date_format", as it is not used anywhere. Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Diffstat (limited to 'src')
-rw-r--r--src/callbacks.c48
-rw-r--r--src/fileio.c8
-rw-r--r--src/interface.h49
-rw-r--r--src/main.c75
4 files changed, 97 insertions, 83 deletions
diff --git a/src/callbacks.c b/src/callbacks.c
index e4befcc..4fe8020 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -36,13 +36,14 @@ extern const gchar *const protos[];
void ts_func(GtkWidget *rb, cam_t *cam)
{
cam->timestamp = gtk_toggle_button_get_active((GtkToggleButton *) rb);
- gconf_client_set_bool(cam->gc, KEY4, cam->timestamp, NULL);
+ gconf_client_set_bool(cam->gc, GCONF_TIMESTAMP, cam->timestamp, NULL);
}
void customstring_func(GtkWidget *rb, cam_t *cam)
{
cam->usestring = gtk_toggle_button_get_active((GtkToggleButton *) rb);
- gconf_client_set_bool(cam->gc, KEY18, cam->usestring, NULL);
+ gconf_client_set_bool(cam->gc, GCONF_USE_CUSTOM_STRING,
+ cam->usestring, NULL);
gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(cam->xml, "string_entry")),
cam->usestring);
}
@@ -50,40 +51,40 @@ void customstring_func(GtkWidget *rb, cam_t *cam)
void drawdate_func(GtkWidget *rb, cam_t *cam)
{
cam->usedate = gtk_toggle_button_get_active((GtkToggleButton *) rb);
- gconf_client_set_bool(cam->gc, KEY19, cam->usedate, NULL);
+ gconf_client_set_bool(cam->gc, GCONF_DRAWDATE, cam->usedate, NULL);
}
void append_func(GtkWidget *rb, cam_t *cam)
{
cam->timefn = gtk_toggle_button_get_active((GtkToggleButton *) rb);
- gconf_client_set_bool(cam->gc, KEY14, cam->timefn, NULL);
+ gconf_client_set_bool(cam->gc, GCONF_LOCAL_APPEND_TS, cam->timefn, NULL);
}
void rappend_func(GtkWidget *rb, cam_t *cam)
{
cam->rtimefn = gtk_toggle_button_get_active((GtkToggleButton *) rb);
- gconf_client_set_bool(cam->gc, KEY15, cam->rtimefn, NULL);
+ gconf_client_set_bool(cam->gc, GCONF_REMOTE_APPEND_TS, cam->rtimefn, NULL);
}
void jpg_func(GtkWidget *rb, cam_t *cam)
{
cam->savetype = JPEG;
- gconf_client_set_int(cam->gc, KEY3, cam->savetype, NULL);
+ gconf_client_set_int(cam->gc, GCONF_FILE_TYPE, cam->savetype, NULL);
}
void png_func(GtkWidget *rb, cam_t *cam)
{
cam->savetype = PNG;
- gconf_client_set_int(cam->gc, KEY3, cam->savetype, NULL);
+ gconf_client_set_int(cam->gc, GCONF_FILE_TYPE, cam->savetype, NULL);
}
void ppm_func(GtkWidget *rb, cam_t *cam)
{
cam->savetype = PPM;
- gconf_client_set_int(cam->gc, KEY3, cam->savetype, NULL);
+ gconf_client_set_int(cam->gc, GCONF_FILE_TYPE, cam->savetype, NULL);
}
void set_sensitive(cam_t *cam)
@@ -117,7 +118,7 @@ void cap_func(GtkWidget *rb, cam_t *cam)
{
cam->cap = gtk_toggle_button_get_active((GtkToggleButton *) rb);
- gconf_client_set_bool(cam->gc, KEY12, cam->cap, NULL);
+ gconf_client_set_bool(cam->gc, GCONF_LOCAL_CAPTURE, cam->cap, NULL);
set_sensitive(cam);
}
@@ -125,7 +126,7 @@ void rcap_func(GtkWidget *rb, cam_t *cam)
{
cam->rcap = gtk_toggle_button_get_active((GtkToggleButton *) rb);
- gconf_client_set_bool(cam->gc, KEY13, cam->rcap, NULL);
+ gconf_client_set_bool(cam->gc, GCONF_REMOTE_CAPTURE, cam->rcap, NULL);
set_sensitive(cam);
}
@@ -134,7 +135,7 @@ void acap_func(GtkWidget *rb, cam_t *cam)
{
cam->acap = gtk_toggle_button_get_active((GtkToggleButton *) rb);
- gconf_client_set_bool(cam->gc, KEY20, cam->acap, NULL);
+ gconf_client_set_bool(cam->gc, GCONF_AUTO_CAPTURE, cam->acap, NULL);
if (cam->acap == TRUE) {
cam->timeout_id = g_timeout_add(cam->timeout_interval,
@@ -156,7 +157,8 @@ void acap_func(GtkWidget *rb, cam_t *cam)
void interval_change(GtkWidget *sb, cam_t *cam)
{
cam->timeout_interval = gtk_spin_button_get_value((GtkSpinButton *) sb) * 60000;
- gconf_client_set_int(cam->gc, KEY21, cam->timeout_interval, NULL);
+ gconf_client_set_int(cam->gc, GCONF_AUTO_CAPTURE_INTERVAL,
+ cam->timeout_interval, NULL);
if (cam->acap == TRUE) {
if (cam->debug == TRUE) {
printf("interval_change; old timeout_id = %d old interval = %d\n",
@@ -175,26 +177,27 @@ void interval_change(GtkWidget *sb, cam_t *cam)
void rjpg_func(GtkWidget *rb, cam_t *cam)
{
cam->rsavetype = JPEG;
- gconf_client_set_int(cam->gc, KEY10, cam->rsavetype, NULL);
+ gconf_client_set_int(cam->gc, GCONF_REMOTE_FILE_TYPE, cam->rsavetype, NULL);
}
void rpng_func(GtkWidget *rb, cam_t *cam)
{
cam->rsavetype = PNG;
- gconf_client_set_int(cam->gc, KEY10, cam->rsavetype, NULL);
+ gconf_client_set_int(cam->gc, GCONF_REMOTE_FILE_TYPE, cam->rsavetype, NULL);
}
void rppm_func(GtkWidget *rb, cam_t *cam)
{
cam->rsavetype = PPM;
- gconf_client_set_int(cam->gc, KEY10, cam->rsavetype, NULL);
+ gconf_client_set_int(cam->gc, GCONF_REMOTE_FILE_TYPE, cam->rsavetype, NULL);
}
void rts_func(GtkWidget *rb, cam_t *cam)
{
cam->rtimestamp = gtk_toggle_button_get_active((GtkToggleButton *) rb);
- gconf_client_set_bool(cam->gc, KEY11, cam->rtimestamp, NULL);
+ gconf_client_set_bool(cam->gc, GCONF_REMOTE_TIMESTAMP,
+ cam->rtimestamp, NULL);
}
@@ -301,7 +304,7 @@ void prefs_func(GtkWidget *okbutton, cam_t *cam)
{
if (gtk_file_chooser_get_current_folder((GtkFileChooser *) dentry)) {
cam->pixdir = g_strdup(gtk_file_chooser_get_current_folder((GtkFileChooser *) dentry));
- gconf_client_set_string(cam->gc, KEY1, cam->pixdir, NULL);
+ gconf_client_set_string(cam->gc, GCONF_SAVE_DIR, cam->pixdir, NULL);
} else {
if (cam->debug == TRUE)
fprintf(stderr, "null directory\ndirectory unchanged.");
@@ -316,12 +319,14 @@ void prefs_func(GtkWidget *okbutton, cam_t *cam)
*/
if (strlen(gtk_entry_get_text((GtkEntry *) entry2)) > 0) {
cam->capturefile = g_strdup(gtk_entry_get_text((GtkEntry *) entry2));
- gconf_client_set_string(cam->gc, KEY2, cam->capturefile, NULL);
+ gconf_client_set_string(cam->gc, GCONF_SAVE_FILE,
+ cam->capturefile, NULL);
}
if (strlen(gtk_entry_get_text((GtkEntry *) string_entry)) > 0) {
cam->ts_string = g_strdup(gtk_entry_get_text((GtkEntry *) string_entry));
- gconf_client_set_string(cam->gc, KEY16, cam->ts_string, NULL);
+ gconf_client_set_string(cam->gc, GCONF_TIMESTAMP_STRING,
+ cam->ts_string, NULL);
}
if (cam->debug == TRUE) {
fprintf(stderr, "dir now = %s\nfile now = %s\n", cam->pixdir,
@@ -433,7 +438,8 @@ void on_show_adjustments_activate(GtkToggleButton *button, cam_t *cam)
gtk_widget_show(GTK_WIDGET(gtk_builder_get_object(cam->xml, "adjustments_table")));
cam->show_adjustments = TRUE;
}
- gconf_client_set_bool(cam->gc, KEY22, cam->show_adjustments, NULL);
+ gconf_client_set_bool(cam->gc, GCONF_SHOW_ADJUSTMENTS,
+ cam->show_adjustments, NULL);
}
void on_show_effects_activate(GtkMenuItem *menuitem, cam_t *cam)
@@ -450,7 +456,7 @@ void on_show_effects_activate(GtkMenuItem *menuitem, cam_t *cam)
gtk_widget_show(effects);
}
- gconf_client_set_bool(cam->gc, KEY23, cam->show_effects, NULL);
+ gconf_client_set_bool(cam->gc, GCONF_SHOW_EFFECTS, cam->show_effects, NULL);
}
static void about_widget_destroy(GtkWidget *widget)
diff --git a/src/fileio.c b/src/fileio.c
index b587c18..79bd7d4 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -164,10 +164,10 @@ static void mount_cb(GObject *obj, GAsyncResult *res, gpointer user_data)
if (ret) {
cam->rdir_ok = TRUE;
- gconf_client_set_string(cam->gc, KEY5, cam->host, NULL);
- gconf_client_set_string(cam->gc, KEY6, cam->proto, NULL);
- gconf_client_set_string(cam->gc, KEY8, cam->rdir, NULL);
- gconf_client_set_string(cam->gc, KEY9, cam->rcapturefile, NULL);
+ gconf_client_set_string(cam->gc, GCONF_HOSTNAME, cam->host, NULL);
+ gconf_client_set_string(cam->gc, GCONF_REMOTE_PROTO, cam->proto, NULL);
+ gconf_client_set_string(cam->gc, GCONF_REMOTE_SAVE_DIR, cam->rdir, NULL);
+ gconf_client_set_string(cam->gc, GCONF_REMOTE_SAVE_FILE, cam->rcapturefile, NULL);
} else {
gchar *error_message = g_strdup_printf(_("An error occurred mounting %s:%s."),
cam->uri, err->message);
diff --git a/src/interface.h b/src/interface.h
index ed10f06..6c89cd5 100644
--- a/src/interface.h
+++ b/src/interface.h
@@ -1,25 +1,24 @@
-#define PATH "/apps/camorama/preferences"
-#define KEY_DEVICE PATH "/device"
-#define KEY1 "/apps/camorama/preferences/save_dir"
-#define KEY2 "/apps/camorama/preferences/save_file"
-#define KEY3 "/apps/camorama/preferences/file_type"
-#define KEY4 "/apps/camorama/preferences/timestamp"
-#define KEY5 "/apps/camorama/preferences/hostname"
-#define KEY6 "/apps/camorama/preferences/remote_proto"
-/* KEY7 removed */
-#define KEY8 "/apps/camorama/preferences/remote_save_dir"
-#define KEY9 "/apps/camorama/preferences/remote_save_file"
-#define KEY10 "/apps/camorama/preferences/remote_file_type"
-#define KEY11 "/apps/camorama/preferences/remote_timestamp"
-#define KEY12 "/apps/camorama/preferences/local_capture"
-#define KEY13 "/apps/camorama/preferences/remote_capture"
-#define KEY14 "/apps/camorama/preferences/append_ts_to_file"
-#define KEY15 "/apps/camorama/preferences/remote_append_ts_to_file"
-#define KEY16 "/apps/camorama/preferences/timestamp_string"
-#define KEY17 "/apps/camorama/preferences/date_format"
-#define KEY18 "/apps/camorama/preferences/use_custom_string"
-#define KEY19 "/apps/camorama/preferences/drawdate"
-#define KEY20 "/apps/camorama/preferences/auto_capture"
-#define KEY21 "/apps/camorama/preferences/auto_capture_interval"
-#define KEY22 "/apps/camorama/preferences/show_adjustments"
-#define KEY23 "/apps/camorama/preferences/show_effects"
+#define GCONF_PARENT "/apps/camorama/preferences"
+
+#define GCONF_DEVICE GCONF_PARENT "/device"
+#define GCONF_SAVE_DIR GCONF_PARENT "/save_dir"
+#define GCONF_SAVE_FILE GCONF_PARENT "/save_file"
+#define GCONF_FILE_TYPE GCONF_PARENT "/file_type"
+#define GCONF_TIMESTAMP GCONF_PARENT "/timestamp"
+#define GCONF_HOSTNAME GCONF_PARENT "/hostname"
+#define GCONF_REMOTE_PROTO GCONF_PARENT "/remote_proto"
+#define GCONF_REMOTE_SAVE_DIR GCONF_PARENT "/remote_save_dir"
+#define GCONF_REMOTE_SAVE_FILE GCONF_PARENT "/remote_save_file"
+#define GCONF_REMOTE_FILE_TYPE GCONF_PARENT "/remote_file_type"
+#define GCONF_REMOTE_TIMESTAMP GCONF_PARENT "/remote_timestamp"
+#define GCONF_LOCAL_CAPTURE GCONF_PARENT "/local_capture"
+#define GCONF_REMOTE_CAPTURE GCONF_PARENT "/remote_capture"
+#define GCONF_LOCAL_APPEND_TS GCONF_PARENT "/append_ts_to_file"
+#define GCONF_REMOTE_APPEND_TS GCONF_PARENT "/remote_append_ts_to_file"
+#define GCONF_TIMESTAMP_STRING GCONF_PARENT "/timestamp_string"
+#define GCONF_USE_CUSTOM_STRING GCONF_PARENT "/use_custom_string"
+#define GCONF_DRAWDATE GCONF_PARENT "/drawdate"
+#define GCONF_AUTO_CAPTURE GCONF_PARENT "/auto_capture"
+#define GCONF_AUTO_CAPTURE_INTERVAL GCONF_PARENT "/auto_capture_interval"
+#define GCONF_SHOW_ADJUSTMENTS GCONF_PARENT "/show_adjustments"
+#define GCONF_SHOW_EFFECTS GCONF_PARENT "/show_effects"
diff --git a/src/main.c b/src/main.c
index facca97..6447f51 100644
--- a/src/main.c
+++ b/src/main.c
@@ -154,28 +154,28 @@ static void activate(GtkApplication *app)
gc = gconf_client_get_default();
cam->gc = gc;
- gconf_client_add_dir(cam->gc, PATH, GCONF_CLIENT_PRELOAD_NONE, NULL);
- gconf_client_notify_add(cam->gc, KEY1, (void *)gconf_notify_func,
+ gconf_client_add_dir(cam->gc, GCONF_PARENT, GCONF_CLIENT_PRELOAD_NONE, NULL);
+ gconf_client_notify_add(cam->gc, GCONF_SAVE_DIR, (void *)gconf_notify_func,
&cam->pixdir, NULL, NULL);
- gconf_client_notify_add(cam->gc, KEY2, (void *)gconf_notify_func,
+ gconf_client_notify_add(cam->gc, GCONF_SAVE_FILE, (void *)gconf_notify_func,
&cam->capturefile, NULL, NULL);
- gconf_client_notify_add(cam->gc, KEY3,
+ gconf_client_notify_add(cam->gc, GCONF_FILE_TYPE,
(void *)gconf_notify_func_int,
&cam->savetype, NULL, NULL);
- gconf_client_notify_add(cam->gc, KEY4,
+ gconf_client_notify_add(cam->gc, GCONF_TIMESTAMP,
(void *)gconf_notify_func_bool,
&cam->timestamp, NULL, NULL);
- gconf_client_notify_add(cam->gc, KEY5, (void *)gconf_notify_func,
+ gconf_client_notify_add(cam->gc, GCONF_HOSTNAME, (void *)gconf_notify_func,
&cam->host, NULL, NULL);
- gconf_client_notify_add(cam->gc, KEY6, (void *)gconf_notify_func,
+ gconf_client_notify_add(cam->gc, GCONF_REMOTE_PROTO, (void *)gconf_notify_func,
&cam->proto, NULL, NULL);
- gconf_client_notify_add(cam->gc, KEY8, (void *)gconf_notify_func,
+ gconf_client_notify_add(cam->gc, GCONF_REMOTE_SAVE_DIR, (void *)gconf_notify_func,
&cam->rdir, NULL, NULL);
- gconf_client_notify_add(cam->gc, KEY9, (void *)gconf_notify_func,
+ gconf_client_notify_add(cam->gc, GCONF_REMOTE_SAVE_FILE, (void *)gconf_notify_func,
&cam->rcapturefile, NULL, NULL);
if (!poopoo) {
- gchar const *gconf_device = gconf_client_get_string(cam->gc, KEY_DEVICE,
+ gchar const *gconf_device = gconf_client_get_string(cam->gc, GCONF_DEVICE,
NULL);
if (gconf_device)
cam->video_dev = g_strdup(gconf_device);
@@ -190,28 +190,37 @@ static void activate(GtkApplication *app)
cam->date_format = "%Y-%m-%d %H:%M:%S";
#pragma GCC diagnostic pop
- cam->pixdir = gconf_client_get_string(cam->gc, KEY1, NULL);
- cam->capturefile = gconf_client_get_string(cam->gc, KEY2, NULL);
- cam->savetype = gconf_client_get_int(cam->gc, KEY3, NULL);
- cam->host = gconf_client_get_string(cam->gc, KEY5, NULL);
- cam->proto = gconf_client_get_string(cam->gc, KEY6, NULL);
- cam->rdir = gconf_client_get_string(cam->gc, KEY8, NULL);
- cam->rcapturefile = gconf_client_get_string(cam->gc, KEY9, NULL);
- cam->rsavetype = gconf_client_get_int(cam->gc, KEY10, NULL);
- cam->ts_string = gconf_client_get_string(cam->gc, KEY16, NULL);
- cam->timestamp = gconf_client_get_bool(cam->gc, KEY4, NULL);
- cam->rtimestamp = gconf_client_get_bool(cam->gc, KEY11, NULL);
-
- cam->cap = gconf_client_get_bool(cam->gc, KEY12, NULL);
- cam->rcap = gconf_client_get_bool(cam->gc, KEY13, NULL);
- cam->timefn = gconf_client_get_bool(cam->gc, KEY14, NULL);
- cam->rtimefn = gconf_client_get_bool(cam->gc, KEY15, NULL);
- cam->usestring = gconf_client_get_bool(cam->gc, KEY18, NULL);
- cam->usedate = gconf_client_get_bool(cam->gc, KEY19, NULL);
- cam->acap = gconf_client_get_bool(cam->gc, KEY20, NULL);
- cam->timeout_interval = gconf_client_get_int(cam->gc, KEY21, NULL);
- cam->show_adjustments = gconf_client_get_bool(cam->gc, KEY22, NULL);
- cam->show_effects = gconf_client_get_bool(cam->gc, KEY23, NULL);
+ cam->pixdir = gconf_client_get_string(cam->gc, GCONF_SAVE_DIR, NULL);
+ cam->capturefile = gconf_client_get_string(cam->gc, GCONF_SAVE_FILE, NULL);
+ cam->savetype = gconf_client_get_int(cam->gc, GCONF_FILE_TYPE, NULL);
+ cam->host = gconf_client_get_string(cam->gc, GCONF_HOSTNAME, NULL);
+ cam->proto = gconf_client_get_string(cam->gc, GCONF_REMOTE_PROTO, NULL);
+ cam->rdir = gconf_client_get_string(cam->gc, GCONF_REMOTE_SAVE_DIR, NULL);
+ cam->rcapturefile = gconf_client_get_string(cam->gc,
+ GCONF_REMOTE_SAVE_FILE, NULL);
+ cam->rsavetype = gconf_client_get_int(cam->gc,
+ GCONF_REMOTE_FILE_TYPE, NULL);
+ cam->ts_string = gconf_client_get_string(cam->gc,
+ GCONF_TIMESTAMP_STRING, NULL);
+ cam->timestamp = gconf_client_get_bool(cam->gc, GCONF_TIMESTAMP, NULL);
+ cam->rtimestamp = gconf_client_get_bool(cam->gc, GCONF_REMOTE_TIMESTAMP, NULL);
+
+ cam->cap = gconf_client_get_bool(cam->gc, GCONF_LOCAL_CAPTURE, NULL);
+ cam->rcap = gconf_client_get_bool(cam->gc, GCONF_REMOTE_CAPTURE, NULL);
+ cam->timefn = gconf_client_get_bool(cam->gc, GCONF_LOCAL_APPEND_TS, NULL);
+ cam->rtimefn = gconf_client_get_bool(cam->gc,
+ GCONF_REMOTE_APPEND_TS, NULL);
+ cam->usestring = gconf_client_get_bool(cam->gc,
+ GCONF_USE_CUSTOM_STRING, NULL);
+ cam->usedate = gconf_client_get_bool(cam->gc, GCONF_DRAWDATE, NULL);
+ cam->acap = gconf_client_get_bool(cam->gc, GCONF_AUTO_CAPTURE, NULL);
+ cam->timeout_interval = gconf_client_get_int(cam->gc,
+ GCONF_AUTO_CAPTURE_INTERVAL, NULL);
+ cam->show_adjustments = gconf_client_get_bool(cam->gc,
+ GCONF_SHOW_ADJUSTMENTS,
+ NULL);
+ cam->show_effects = gconf_client_get_bool(cam->gc,
+ GCONF_SHOW_EFFECTS, NULL);
if (use_read)
cam->dev = v4l2_open(cam->video_dev, O_RDWR);
@@ -255,7 +264,7 @@ static void activate(GtkApplication *app)
exit(1);
}
- gconf_client_set_string(cam->gc, KEY_DEVICE, cam->video_dev, NULL);
+ gconf_client_set_string(cam->gc, GCONF_DEVICE, cam->video_dev, NULL);
load_interface(cam);

Privacy Policy