changeset 2279:90d9e13d2e18

Add missing files.
author William Pitcock <nenolod@atheme.org>
date Tue, 01 Jan 2008 16:13:51 -0600
parents 614f7b9838fb
children cc31a9aed84c
files src/lirc/callbacks.c src/lirc/interface.c src/lirc/lirc_cfg.c
diffstat 3 files changed, 186 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lirc/callbacks.c	Tue Jan 01 16:13:51 2008 -0600
@@ -0,0 +1,33 @@
+#include <config.h>
+
+#include <gtk/gtk.h>
+
+#include "common.h"
+
+void
+on_reconnectcheck_toggled              (GtkToggleButton *togglebutton,
+                                        GtkWidget       *reconnectspin)
+{
+  gtk_widget_set_sensitive(reconnectspin, gtk_toggle_button_get_active(togglebutton));
+}
+
+
+void
+on_cancelbutton1_clicked               (GtkButton       *button,
+                                        gpointer         user_data)
+{
+  gtk_widget_destroy(lirc_cfg);
+  lirc_cfg=NULL;
+}
+
+
+void
+on_okbutton1_clicked                   (GtkButton       *button,
+                                        gpointer         user_data)
+{
+  b_enable_reconnect=(gint)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(g_object_get_data(G_OBJECT(lirc_cfg), "reconnectcheck")));
+  reconnect_timeout=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(g_object_get_data(G_OBJECT(lirc_cfg), "reconnectspin")));
+  save_cfg();
+  gtk_widget_destroy(lirc_cfg);
+  lirc_cfg=NULL;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lirc/interface.c	Tue Jan 01 16:13:51 2008 -0600
@@ -0,0 +1,109 @@
+#include <config.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdio.h>
+
+#include <gdk/gdkkeysyms.h>
+#include <gtk/gtk.h>
+
+#include <audacious/i18n.h>
+
+#include "common.h"
+
+GtkWidget*
+create_lirc_cfg (void)
+{
+  GtkWidget *dialog_vbox1;
+  GtkWidget *notebook1;
+  GtkWidget *vbox2;
+  GtkWidget *frame1;
+  GtkWidget *alignment1;
+  GtkWidget *vbox3;
+  GtkWidget *hbox1;
+  GtkWidget *label3;
+  GtkWidget *reconnectcheck;
+  GtkWidget *reconnectspin;
+  GtkObject *reconnectspin_adj;
+  GtkWidget *label2;
+  GtkWidget *label1;
+  GtkWidget *dialog_action_area1;
+  GtkWidget *cancelbutton1;
+  GtkWidget *okbutton1;
+
+  lirc_cfg = gtk_dialog_new ();
+  gtk_window_set_title (GTK_WINDOW (lirc_cfg), _("LIRC plugin settings"));
+  gtk_window_set_position (GTK_WINDOW (lirc_cfg), GTK_WIN_POS_CENTER_ON_PARENT);
+  gtk_window_set_resizable (GTK_WINDOW (lirc_cfg), FALSE);
+  gtk_window_set_type_hint (GTK_WINDOW (lirc_cfg), GDK_WINDOW_TYPE_HINT_DIALOG);
+  g_signal_connect(G_OBJECT(lirc_cfg),"destroy", G_CALLBACK(gtk_widget_destroyed), &lirc_cfg);
+
+  dialog_vbox1 = GTK_DIALOG (lirc_cfg)->vbox;
+
+  notebook1 = gtk_notebook_new ();
+  gtk_box_pack_start (GTK_BOX (dialog_vbox1), notebook1, TRUE, TRUE, 0);
+
+  vbox2 = gtk_vbox_new (FALSE, 0);
+  gtk_container_add (GTK_CONTAINER (notebook1), vbox2);
+
+  frame1 = gtk_frame_new (NULL);
+  gtk_box_pack_start (GTK_BOX (vbox2), frame1, TRUE, TRUE, 0);
+
+  alignment1 = gtk_alignment_new (0.5, 0.5, 1, 1);
+  gtk_container_add (GTK_CONTAINER (frame1), alignment1);
+  gtk_alignment_set_padding (GTK_ALIGNMENT (alignment1), 0, 0, 12, 0);
+
+  vbox3 = gtk_vbox_new (FALSE, 0);
+  gtk_container_add (GTK_CONTAINER (alignment1), vbox3);
+
+  reconnectcheck = gtk_check_button_new_with_mnemonic (_("Reconnect to LIRC server"));
+  gtk_box_pack_start (GTK_BOX (vbox3), reconnectcheck, FALSE, FALSE, 0);
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (reconnectcheck), (gboolean)b_enable_reconnect);
+
+  hbox1 = gtk_hbox_new (FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (vbox3), hbox1, TRUE, TRUE, 0);
+
+  label3 = gtk_label_new (_("Timeout before reconnecting (seconds): "));
+  gtk_box_pack_start (GTK_BOX (hbox1), label3, FALSE, FALSE, 17);
+
+  reconnectspin_adj = gtk_adjustment_new (reconnect_timeout, 1, 100, 1, 10, 10);
+  reconnectspin = gtk_spin_button_new (GTK_ADJUSTMENT (reconnectspin_adj), 1, 0);
+  gtk_box_pack_start (GTK_BOX (hbox1), reconnectspin, TRUE, TRUE, 15);
+
+  label2 = gtk_label_new (_("Reconnect"));
+  gtk_frame_set_label_widget (GTK_FRAME (frame1), label2);
+  gtk_label_set_use_markup (GTK_LABEL (label2), TRUE);
+
+  label1 = gtk_label_new (_("Connection"));
+  gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook1), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook1), 0), label1);
+
+  dialog_action_area1 = GTK_DIALOG (lirc_cfg)->action_area;
+  gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END);
+
+  cancelbutton1 = gtk_button_new_from_stock ("gtk-cancel");
+  gtk_dialog_add_action_widget (GTK_DIALOG (lirc_cfg), cancelbutton1, GTK_RESPONSE_CANCEL);
+  GTK_WIDGET_SET_FLAGS (cancelbutton1, GTK_CAN_DEFAULT);
+
+  okbutton1 = gtk_button_new_from_stock ("gtk-ok");
+  gtk_dialog_add_action_widget (GTK_DIALOG (lirc_cfg), okbutton1, GTK_RESPONSE_OK);
+  GTK_WIDGET_SET_FLAGS (okbutton1, GTK_CAN_DEFAULT);
+
+  g_signal_connect (G_OBJECT (reconnectcheck), "toggled",
+                    G_CALLBACK (on_reconnectcheck_toggled),
+                    G_OBJECT (reconnectspin));
+  g_signal_connect (G_OBJECT (cancelbutton1), "clicked",
+                    G_CALLBACK (on_cancelbutton1_clicked),
+                    NULL);
+  g_signal_connect (G_OBJECT (okbutton1), "clicked",
+                    G_CALLBACK (on_okbutton1_clicked),
+                    NULL);
+  gtk_widget_set_sensitive(reconnectspin, (gboolean)b_enable_reconnect);
+
+  g_object_set_data(G_OBJECT(lirc_cfg), "reconnectcheck", G_OBJECT(reconnectcheck));
+  g_object_set_data(G_OBJECT(lirc_cfg), "reconnectspin", G_OBJECT(reconnectspin));
+
+  return lirc_cfg;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lirc/lirc_cfg.c	Tue Jan 01 16:13:51 2008 -0600
@@ -0,0 +1,44 @@
+#include <config.h>
+
+#include <gtk/gtk.h>
+#include <audacious/i18n.h>
+#include <audacious/plugin.h>
+#include <audacious/configdb.h>
+
+#include "common.h"
+
+GtkWidget *lirc_cfg = NULL;
+
+gint b_enable_reconnect;
+gint reconnect_timeout;
+
+void load_cfg(void)
+{
+  ConfigDb *db;
+  db = aud_cfg_db_open();
+  aud_cfg_db_get_int(db, "lirc", "enable_reconnect", &b_enable_reconnect);
+  aud_cfg_db_get_int(db, "lirc", "reconnect_timeout", &reconnect_timeout);
+  if (!reconnect_timeout) reconnect_timeout = 5;
+  aud_cfg_db_close(db);
+}
+
+void save_cfg(void)
+{
+  ConfigDb *db;
+  db = aud_cfg_db_open();
+  aud_cfg_db_set_int(db, "lirc", "enable_reconnect", b_enable_reconnect);
+  aud_cfg_db_set_int(db, "lirc", "reconnect_timeout", reconnect_timeout);
+  aud_cfg_db_close(db);
+}
+
+void configure(void)
+{
+  if (lirc_cfg)
+  {
+    gtk_window_present(GTK_WINDOW(lirc_cfg));
+    return;
+  }
+  load_cfg();
+  lirc_cfg = create_lirc_cfg();
+  gtk_widget_show_all(lirc_cfg);
+}