sinek/src osd.c,1.18,1.19
[email protected] Thu, 16 Jan 2003 23:39:08 -0800
| Newsgroups | gmane.comp.video.sinek.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/sinek/sinek/src
In directory sc8-pr-cvs1:/tmp/cvs-serv4749
Modified Files:
osd.c
Log Message:
I'll fix this later, I promise (maybe even pango-ize it?). For now, just get it compiling and displaying basic text.
Index: osd.c
===================================================================
RCS file: /cvsroot/sinek/sinek/src/osd.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- osd.c 4 Jan 2003 09:24:11 -0000 1.18
+++ osd.c 17 Jan 2003 07:39:06 -0000 1.19
@@ -9,14 +9,9 @@
*/
#include "common.h"
+#include "gtkxine.h"
-#include <gdk/gdkx.h>
-
-static xine_osd_t *osd;
-static GC gc;
-static Pixmap px;
-static XImage *ximg;
-static GdkFont *gdkfont;
+static char *font = NULL;
static int osd_h, osd_w, osd_x, osd_y, osd_pos;
static char *placetext[] =
@@ -37,11 +32,8 @@
wm_build(fontsel_build);
- osd_pos = xine_config_register_range(sinek.xine, "sinek.subtitle_pos", 85, 0, 99, NULL, NULL, 0, NULL, NULL);
- osd = xine_osd_new(sinek.stream, 0, 0, 400, 100);
-
- gc = XCreateGC(sinek.display, sinek.video_win, 0, NULL);
- px = XCreatePixmap(sinek.display, sinek.video_win, 400, 100, sinek.depth);
+ osd_pos = gtk_xine_config_register_range(GTK_XINE(sinek.xine), "sinek.subtitle_pos", 85, 0, 99);
+ gtk_xine_osd_reset(GTK_XINE(sinek.xine), 0, 0, 400, 100, "sans", 20, GTK_XINE_PALETTE_WHITE_NONE_TRANSPARENT);
}
@@ -63,68 +55,36 @@
{
int i, j, tw = 0, th = 0, len;
- XSetBackground(sinek.display, gc, 0);
- XSetForeground(sinek.display, gc, 0);
- XFillRectangle(sinek.display, px, gc, 0, 0, 400, 100);
- XSetForeground(sinek.display, gc, 15);
- if(gdkfont)
- {
- int w, h;
- XSetFont(sinek.display, gc, gdk_font_id(gdkfont));
- for(i = 0; text[i]; i++)
- {
- len = strlen(text[i]);
- h = gdk_text_height(gdkfont, text[i], len);
- w = gdk_text_width(gdkfont, text[i], len);
- XDrawString(sinek.display, px, gc, 10, th + h + 2, text[i], len);
- th = th + h + 2;
- if(w > tw) tw = w;
- }
- th += 10;
- tw += 15;
- }
- if(tw > 398) tw = 398;
- if(th > 98) th = 98;
- osd_w = tw;
- osd_h = th;
- ximg = XGetImage(sinek.display, px, 0, 0, 400, 100, sinek.depth, 1);
- xine_osd_clear(osd);
- xine_osd_draw_rect(osd, 10, 2, tw, th, 3, 1);
- for(i = 0; i < th; i++)
- {
- for(j = 0; j < tw; j++)
- {
- if(XGetPixel(ximg, j, i))
- {
- xine_osd_draw_line(osd, j, i, j+1, i+1, 10);
- }
- }
+ if (font) {
+ /* recently changed, reset */
+ gtk_xine_osd_reset(GTK_XINE(sinek.xine), 0, 0, 400, 100, font, 20, GTK_XINE_PALETTE_WHITE_NONE_TRANSPARENT);
+ g_free(font);
+ font = NULL;
}
- xine_osd_draw_line(osd, 0, 0, 1, 1, 0);
- osd_x = (sinek.vid_w - osd_w) / 2;
+
+ osd_x = (sinek.vid_w - 100) / 2;
osd_y = sinek.vid_h * osd_pos / 100;
- if(osd_y + osd_h > sinek.vid_h) osd_y = sinek.vid_h - osd_y;
- xine_osd_set_position(osd, osd_x, osd_y);
- XDestroyImage(ximg);
+ if (osd_y + osd_h > sinek.vid_h)
+ osd_y = sinek.vid_h - osd_y;
+ gtk_xine_osd_set_position(GTK_XINE(sinek.xine), osd_x, osd_y);
+ /* TODO: actually display the entire paragraph of text.. */
+ gtk_xine_osd_draw_text(GTK_XINE(sinek.xine), text[0], 0, 0);
}
-
static void show_subtitle(char **title)
{
static int show = 0;
if(title)
{
- if(show) xine_osd_hide(osd, 0);
osd_display(title);
- xine_osd_show(osd, 0);
show = 1;
}
else
{
if(show)
{
- xine_osd_hide(osd, 0);
+ gtk_xine_osd_hide(GTK_XINE(sinek.xine), 0);
show = 0;
}
}
@@ -136,7 +96,7 @@
static char **old = NULL;
subtitle_t *sub;
char **cur;
- int x, y, pos;
+ int pos;
if(sinek.osd_place)
{
@@ -147,7 +107,7 @@
}
return;
}
- if (sinek.osd_subtitles && xine_get_pos_length(sinek.stream, &x, &pos, &y))
+ if (sinek.osd_subtitles && (pos = gtk_xine_get_current_time(GTK_XINE(sinek.xine))))
{
sub = subtitle_find(pos * 100);
if (sub) {
@@ -174,9 +134,7 @@
void osd_position(int x, int y)
{
- xine_cfg_entry_t entry;
-
- xine_osd_hide(osd, 0);
+ gtk_xine_osd_hide(GTK_XINE(sinek.xine), 0);
if (sinek.vid_h)
osd_pos = y * 100 / sinek.vid_h;
else
@@ -184,12 +142,10 @@
osd_y = sinek.vid_h * osd_pos / 100;
if (osd_y + osd_h > sinek.vid_h)
osd_y = sinek.vid_h - osd_y;
- xine_osd_set_position(osd, osd_x, osd_y);
- xine_osd_show(osd, 0);
+ gtk_xine_osd_set_position(GTK_XINE(sinek.xine), osd_x, osd_y);
+ gtk_xine_osd_show(GTK_XINE(sinek.xine), 0);
- xine_config_lookup_entry(sinek.xine, "sinek.subtitle_pos", &entry);
- entry.num_value = osd_pos;
- xine_config_update_entry(sinek.xine, &entry);
+ gtk_xine_config_set(GTK_XINE(sinek.xine), "sinek.subtitle_pos", (void *) osd_pos);
}
@@ -203,16 +159,15 @@
static void cb_font(GtkWidget *w, GtkFontSelectionDialog *fsd)
{
- GdkFont *font;
- xine_cfg_entry_t entry;
+ GdkFont *gdkfont;
+ char *x;
- font = gtk_font_selection_dialog_get_font(fsd);
- if(font && gdk_font_id(font))
+ gdkfont = gtk_font_selection_dialog_get_font(fsd);
+ if (gdkfont && gdk_font_id(gdkfont))
{
- gdkfont = font;
- xine_config_lookup_entry(sinek.xine, "sinek.subtitle_font_name", &entry);
- entry.str_value = gtk_font_selection_dialog_get_font_name(fsd);
- xine_config_update_entry(sinek.xine, &entry);
+ x = gtk_font_selection_dialog_get_font_name(fsd);
+ font = g_strdup(x);
+ gtk_xine_config_set(GTK_XINE(sinek.xine), "sinek.subtitle_font_name", x);
}
gtk_widget_hide(GTK_WIDGET(fsd));
}
@@ -243,9 +198,9 @@
GTK_WIDGET_SET_FLAGS(but, GTK_CAN_DEFAULT);
g_signal_connect_swapped(G_OBJECT(but), "clicked", G_CALLBACK(gtk_widget_hide), GTK_OBJECT(fontreq));
- font = xine_config_register_string(sinek.xine, "sinek.subtitle_font_name", "Sans 12", NULL, NULL, 0, NULL, NULL);
+ font = g_strdup(gtk_xine_config_register_string(GTK_XINE(sinek.xine), "sinek.subtitle_font_name", "Sans 12"));
gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(fontreq), font);
- gdkfont = gtk_font_selection_dialog_get_font(GTK_FONT_SELECTION_DIALOG(fontreq));
+ //gdkfont = gtk_font_selection_dialog_get_font(GTK_FONT_SELECTION_DIALOG(fontreq));
*win = fontreq;
return WM_AUTOHIDE;
-------------------------------------------------------
This SF.NET email is sponsored by: Thawte.com
Understand how to protect your customers personal information by implementing
SSL on your Apache Web Server. Click here to get our FREE Thawte Apache
Guide: http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0029en