~ubuntu-branches/ubuntu/maverick/zapping/maverick

« back to all changes in this revision

Viewing changes to src/remote.h

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2005-03-08 23:19:08 UTC
  • mfrom: (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050308231908-oip7rfv6lcmo8c0e
Tags: 0.9.2-2ubuntu1
Rebuilt for Python transition (2.3 -> 2.4)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Zapping (TV viewer for the Gnome Desktop)
2
 
 * Copyright (C) 2000 I�aki Garc�a Etxebarria
3
 
 *
4
 
 * This program is free software; you can redistribute it and/or modify
5
 
 * it under the terms of the GNU General Public License as published by
6
 
 * the Free Software Foundation; either version 2 of the License, or
7
 
 * (at your option) any later version.
8
 
 *
9
 
 * This program is distributed in the hope that it will be useful,
10
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 
 * GNU General Public License for more details.
13
 
 *
14
 
 * You should have received a copy of the GNU General Public License
15
 
 * along with this program; if not, write to the Free Software
16
 
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
 
 */
18
 
 
19
 
/*
20
 
 * Generic command implementation. This is mostly useful for plugins,
21
 
 * that can use this routines for executing arbitrary functions in a
22
 
 * clean way.
23
 
 */
24
1
#ifndef __REMOTE_H__
25
2
#define __REMOTE_H__
26
3
 
27
 
#include <glib.h>
28
 
 
29
 
/* The meaning of arg and the returned gpointer value depend on the
30
 
   function you call. The command checking isn't case sensitive */
31
 
gpointer remote_command(gchar *command, gpointer arg);
32
 
 
33
4
/**
34
 
 * Parses the given command and calls old_remote_command appropiately.
35
 
 * Command is a set of lines containing a single command each, or many
36
 
 * commands separated by ";"
37
 
 * Example > set_channel 5;
38
 
 */
39
 
void run_command(const gchar *command);
40
 
 
41
 
/*
42
 
  Implemented commands and description
43
 
  ------------------------------------
44
 
  - command="quit", arg=ignored, returns=NULL
45
 
  Quits the program, just like if the user had pressed the delete
46
 
  button in the window.
47
 
 
48
 
  - command="switch_mode", arg=GINT_TO_POINTER(enum tveng_capture_mode
49
 
  new_mode), returns=GINT_TO_POINTER(-1 on error, 0 on success)
50
 
  Switchs between different running modes. See tveng.h for valid
51
 
  capture mode values.
52
 
 
53
 
  - command="get_mode".
54
 
  Not implemented, use the current_mode field in
55
 
  your copy of the tveng_device_info * struct.
56
 
 
57
 
  - command="get_cur_channel", arg=ignored,
58
 
  returns=GINT_TO_POINTER(current_channel).
59
 
  Returns the currently selected station in Zapping.
60
 
 
61
 
  - command="get_channel_info", arg=index
62
 
  returns=tveng_tuned_channel* channel, or NULL if not found.
63
 
  Info about the given channel. Use tveng_clear_tuned_channel(result)
64
 
  when not longer needed.
65
 
 
66
 
  - command="get_num_channels", arg=ignored,
67
 
  returns=GINT_TO_POINTER(number_of_channels).
68
 
  Number of channels in the channel list.
69
 
 
70
 
  - command="set_channel", arg=GINT_TO_POINTER(channel_index),
71
 
  returns=NULL
72
 
  Sets a given channel in the Channel list. The given value is clipped
73
 
  to the nearest valid values.
74
 
 
75
 
  - commmand="channel_up", command="channel_down", arg=ignored,
76
 
  returns=NULL.
77
 
  Go to the previous/next channel in the channel list.
78
 
 
79
 
  - command="set_vbi_mode", arg=GINT_TO_POINTER(gboolean init_vbi),
80
 
  returns=NULL.
81
 
  Starts/stops Teletext, depending on the value of arg. If arg is
82
 
  TRUE, then teletext is started. Please note that if you stop
83
 
  Teletext, it doesn't restore the previous capture mode, you need to
84
 
  do that by hand.
85
 
 
86
 
  - command="load_page", arg=GINT_TO_POINTER((page<<16)+subpage)
87
 
  Loads the given page in the main window, tries to start TTX if it
88
 
  isn't already on (i.e., if info->current_mode != TVENG_CAPTURE_NONE).
89
 
  Loading all subpages of a page is done by giving the value
90
 
  ANY_SUB to subpage. Example: load_page((100<<16)+ANY_SUB)
91
 
*/
92
 
 
93
 
/*
94
 
 *  Zapping commands Mk II
95
 
 */
96
 
 
97
 
typedef gboolean (cmd_func)     (GtkWidget *    widget,
98
 
                                 gint           argc,
99
 
                                 gchar **       argv,
100
 
                                 gpointer       user_data);
101
 
 
102
 
extern void                     startup_remote          (void);
103
 
extern void                     shutdown_remote         (void);
104
 
 
105
 
extern void                     cmd_register            (const gchar *  name,
106
 
                                                         cmd_func *     func,
107
 
                                                         gpointer       user_data);
108
 
extern void                     cmd_remove              (const gchar *  name);
109
 
 
110
 
extern GList *                  cmd_list                (void);
111
 
 
112
 
extern gboolean                 cmd_execute             (GtkWidget *    widget,
113
 
                                                         const gchar *  command_string);
114
 
extern gboolean                 cmd_execute_printf      (GtkWidget *    widget,
115
 
                                                         const gchar *  templ,
116
 
                                                         ...);
117
 
extern void                     on_remote_command1      (GtkWidget *    widget,
118
 
                                                         gpointer       user_data);
119
 
extern void                     on_remote_command2      (GtkWidget *    widget,
120
 
                                                         gpointer       ignored,
121
 
                                                         gpointer       user_data);
122
 
 
123
 
extern gboolean                 on_remote_command_blocked;
124
 
 
125
 
#define ORC_BLOCK(_func)                                                \
126
 
(on_remote_command_blocked = TRUE, _func, on_remote_command_blocked = FALSE)
127
 
 
128
 
/*
129
 
({
130
 
  GtkObject object = GTK_OBJECT (_object);
131
 
  GtkHandler *handler0 = gtk_object_get_data_by_id (object, gtk_handler_quark);
132
 
  GtkHandler *handler;
133
 
  typeof (_func) temp;
134
 
 
135
 
  for (handler = handler0; handler; handler = handler->next)
136
 
    if (handler->id > 0 && handler->func == on_remote_command)
137
 
      handler->blocked += 1;
138
 
 
139
 
  temp = _func;
140
 
 
141
 
  for (handler = handler0; handler; handler = handler->next)
142
 
    if (handler->id > 0 && handler->func == on_remote_command)
143
 
      handler->blocked -= 1;
144
 
 
145
 
  temp;
146
 
})
147
 
*/
148
 
 
149
 
extern void                     cmd_return              (const gchar *  command_return_value);
150
 
 
151
 
#endif /* remote.h */
 
5
 * This provides a Python interface to the internal Zapping routines.
 
6
 */
 
7
 
 
8
#ifdef _POSIX_C_SOURCE
 
9
  /* python 2.3 redefines. ugh. */
 
10
#  undef _POSIX_C_SOURCE
 
11
#  include <Python.h>
 
12
#  ifndef _POSIX_C_SOURCE
 
13
#    define _POSIX_C_SOURCE 199506L
 
14
#  endif
 
15
#else
 
16
#  include <Python.h>
 
17
#endif
 
18
 
 
19
#include <gtk/gtk.h>
 
20
 
 
21
extern int
 
22
ParseTuple                      (PyObject *             args,
 
23
                                 const char *           format,
 
24
                                 ...);
 
25
 
 
26
/* The zapping dictionary in case you want to add things
 
27
   manually. To register functions use cmd_register() instead. */
 
28
extern PyObject *       dict;
 
29
 
 
30
extern void
 
31
on_python_command1              (GtkWidget *            widget,
 
32
                                 const gchar *          cmd);
 
33
extern void
 
34
on_python_command2              (GtkWidget *            widget,
 
35
                                 gpointer               unused,
 
36
                                 const gchar *          cmd);
 
37
extern void
 
38
on_python_command3              (GtkWidget *            widget,
 
39
                                 gpointer               unused1,
 
40
                                 gpointer               unused2,
 
41
                                 const gchar *          cmd);
 
42
 
 
43
#define python_command(widget, cmd) on_python_command1 (widget, cmd)
 
44
 
 
45
extern void
 
46
python_command_printf           (GtkWidget *            widget,
 
47
                                 const gchar *          fmt,
 
48
                                 ...);
 
49
extern GtkWidget *
 
50
python_command_widget           (void);
 
51
 
 
52
extern GList *
 
53
cmd_list                        (void);
 
54
extern const gchar *
 
55
cmd_action_from_cmd             (const gchar *          cmd);
 
56
extern const gchar *
 
57
cmd_action_to_cmd               (const gchar *          action);
 
58
extern GtkMenu *
 
59
cmd_action_menu                 (void);
 
60
extern gchar *
 
61
cmd_compatibility               (const gchar *          cmd);
 
62
extern void
 
63
_cmd_register                   (const gchar *          name,
 
64
                                 PyCFunction            cfunc,
 
65
                                 int                    flags,
 
66
                                 ...);
 
67
#define cmd_register(name, cfunc, flags, args...)                       \
 
68
  _cmd_register (name, cfunc, flags ,##args , 0)
 
69
extern void
 
70
shutdown_remote                 (void);
 
71
extern void
 
72
startup_remote                  (void);
 
73
 
 
74
/* The following macros simplify writing the python wrappers. */
 
75
#define py_return_none                                                  \
 
76
do {                                                                    \
 
77
  Py_INCREF(Py_None);                                                   \
 
78
  return Py_None;                                                       \
 
79
} while (0)
 
80
 
 
81
#define py_return_true return PyInt_FromLong (TRUE)
 
82
#define py_return_false return PyInt_FromLong (FALSE)
 
83
 
 
84
#endif /* __REMOTE_H__ */