📄 mainapp.cpp
字号:
/* ***** BEGIN LICENSE BLOCK ***** * Source last modified: $Id: mainapp.cpp,v 1.55.2.19 2004/11/23 00:24:25 rggammon Exp $ * * Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved. * * The contents of this file, and the files included with this file, * are subject to the current version of the RealNetworks Public * Source License (the "RPSL") available at * http://www.helixcommunity.org/content/rpsl unless you have licensed * the file under the current version of the RealNetworks Community * Source License (the "RCSL") available at * http://www.helixcommunity.org/content/rcsl, in which case the RCSL * will apply. You may also obtain the license terms directly from * RealNetworks. You may not use this file except in compliance with * the RPSL or, if you have a valid RCSL with RealNetworks applicable * to this file, the RCSL. Please see the applicable RPSL or RCSL for * the rights, obligations and limitations governing use of the * contents of the file. * * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License Version 2 or later (the * "GPL") in which case the provisions of the GPL are applicable * instead of those above. If you wish to allow use of your version of * this file only under the terms of the GPL, and not to allow others * to use your version of this file under the terms of either the RPSL * or RCSL, indicate your decision by deleting the provisions above * and replace them with the notice and other provisions required by * the GPL. If you do not delete the provisions above, a recipient may * use your version of this file under the terms of any one of the * RPSL, the RCSL or the GPL. * * This file is part of the Helix DNA Technology. RealNetworks is the * developer of the Original Code and owns the copyrights in the * portions it created. * * This file, and the files included with this file, is distributed * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET * ENJOYMENT OR NON-INFRINGEMENT. * * Technology Compatibility Kit Test Suite(s) Location: * http://www.helixcommunity.org/content/tck * * Contributor(s): * * ***** END LICENSE BLOCK ***** *//* This file contains functions with several different prefixes. * They include: * hmw - For (h)xplay (m)ain (w)indow, these functions are designed * to be used as signal handlers that can be used by a glade * window. * * hxwindow - Each top-level window has a hxwindow object associated * with it. * * hpw - For (h)xplayer (p)layer (w)idget, these functions are * designed to work as callbacks to the hx_player_widget. * * no prefix - These functions are "private" supporting functions for * one of the methods above, and are not intended for general * use */#include <gtk/gtk.h>#include <gdk/gdkkeysyms.h>#include <gdk/gdkx.h>#include <X11/Xatom.h>#ifdef USE_GNOME#include <gnome.h>#endif#include <stdlib.h>#include <stdio.h>#include <string.h>#include <errno.h>#include <ctype.h>#include "appver.h"#include "hxplayer-i18n.h"/* Gtk widgt includes */#include "hxplayer.h"#include "hxbin.h"#include "hxplayer.h"#include "hxstatisticsobserver.h"#include "hxgvalue.h"#include "hxgprefs.h"/* Player includes */#include "winutils.h"#include "mainapp.h"#include "commonapp.h"#include "remote.h"#include "hxstatustop.h"#include "hxstatuspositionfield.h"#include "hxstatuspositionslider.h"#include "favorites.h"#include "vidctrls.h"#include "about.h"#include "statistics.h"#include "prefsdialog.h"#include "clipdetails.h"#include "plugins.h"#include "open.h"#include "contextmenu.h"#include "switchboard.h"#include "sysinfo.h"/* Helix includes (currently for viewsrc) */#include "hxcom.h"#include "hxwintyp.h"#include "hxcore.h"#include "hxvsrc.h"#ifdef HELIX_FEATURE_RP_SIGN_IN#include "signin.h"#endif/* Constants and #defines * ====================== */#define REGISTERED_PREF APP_PREFIX_LC "registered"/* Define the size of the empty video widget if no logo is provided, and no content is playing */#define DEFAULT_VIDEO_WIDGET_WIDTH 320#define DEFAULT_VIDEO_WIDGET_HEIGHT 200#define HIDE_CURSOR_TIMEOUT 2 /* Cursor hiding timeout in fullscreen (seconds) *//* some defaults for handling recent urls */#define DEF_NUM_RECENT_URLS 20#define DEF_NUM_FILE_MENU_URLS 8#define MAX_GROUP_TITLE_LENGTH 60/* Data structures * =============== */typedef enum { ON_TOP_NEVER, ON_TOP_WHILE_PLAYING, ON_TOP_ALWAYS} HXMainWindowOnTop;typedef struct _HXMainWindow{ GladeXML* xml; GtkWidget* player; GtkWidget* hxbin; GtkWidget* window; GtkWidget* vbox; GtkWidget* play_button; GtkWidget* stop_button; GtkWidget* pause_button; GtkWidget* previous_button; GtkWidget* next_button; GtkWidget* play_pause_button; GtkWidget* play_pause_image; GtkWidget* seek_scale; GtkWidget* volume_scale; GtkWidget* mute_button; GtkWidget* volume_image; GtkWidget* status_bar; GtkWidget* menu_bar; GtkWidget* controls_hbox; /* menu items of interest */ GtkWidget* play_menu_item; GtkWidget* stop_menu_item; GtkWidget* pause_menu_item; GtkWidget* next_menu_item; GtkWidget* previous_menu_item; GtkWidget* on_top_never_menu_item; GtkWidget* on_top_while_playing_menu_item; GtkWidget* on_top_always_menu_item; GtkWidget* normal_size_menu_item; GtkWidget* double_size_menu_item; GdkPixbuf* play_pixbuf; GdkPixbuf* pause_pixbuf; GdkPixbuf* mute_pixbuf; GdkPixbuf* volume_off_pixbuf; GdkPixbuf* volume_low_pixbuf; GdkPixbuf* volume_mid_pixbuf; GdkPixbuf* volume_high_pixbuf; GtkDialog* video_controls_dialog; GtkDialog* about_dialog; GtkDialog* preferences_dialog; GtkDialog* manage_favorites_dialog; GtkDialog* statistics_dialog; GtkDialog* open_location_dialog; GtkDialog* open_file_dialog; GtkDialog* clip_details_dialog; GtkDialog* plugins_dialog; GtkDialog* import_favorites_dialog; GtkDialog* export_favorites_dialog; HXContextMenu* context_menu; HXMainWindowZoomSize zoom; gint custom_zoom_height, custom_zoom_width; gboolean is_fullscreened; gboolean show_controls_on_unfullscreen; gboolean show_menu_and_caption_on_unfullscreen; gboolean show_status_bar_on_unfullscreen; HXMainWindowZoomSize zoom_on_unfullscreen; HXMainWindowOnTop on_top_on_unfullscreen; gint custom_zoom_height_on_unfullscreen; gint custom_zoom_width_on_unfullscreen; gboolean fullscreen_motion_notify_enabled; gint hxbin_fullscreen_motion_notify_handler; gint player_fullscreen_motion_notify_handler; gboolean fullscreen_hide_cursor_timer_enabled; guint fullscreen_hide_cursor_timer_id; HXMainWindowOnTop on_top; gboolean on_top_while_playing_request_pending; gboolean has_content; /* cache the x and y window positions so that we can save them properly when the window is destroyed */ gint x_pos, y_pos; /* command line switchs */ gboolean quit_on_done; /* Player preferences */ gboolean enable_url_hurling; gchar* media_files_path; gchar* web_browser_path; gchar* last_browsed_directory; /* Real.com declares that these are 7 char's max (+ '\0') */ gchar distcode[8]; /* Code for player distribution method */ gchar origcode[8]; /* The original distcode, before any updates/upgrades */ /* Recently played urls */ GList* recent_urls_list; gboolean enable_recent_urls; gboolean is_seeking;} HXMainWindow;typedef struct { /* Players */ GList* windows_list; /* Favorites */ GList* favorites_list; /* Sign in ("R1") preferences (type HXSignInPref) */ GList* sign_in_preferences_list; } HXMainApp;typedef enum { PLAY_MENU_TYPE_FAVORITE = 0, PLAY_MENU_TYPE_MRU} HXPlayMenuItemType;/* Our global data is stored in an app object. Data that is common between our window and the mozilla plugin embedded window can be found in g_hxcommon_app. */static HXMainApp* g_hx_main_app = NULL;/* Signal handler prototypes * ========================= */extern "C"{/* These can be used as signal callbacks with glade. The widget parameter is (usually) used to locate the toplevel widget via gtk_widget_get_toplevel. The top level widget has an "hxwindow" key set on it which points us at our per window data structure. This datastructure is then used in a call to the corresponding hxwindow_xxx function. */ void hmw_open_location (GtkWidget* widget);void hmw_open_file (GtkWidget* widget);void hmw_quit (GtkWidget* widget);void hmw_close (GtkWidget* widget);void hmw_play (GtkWidget* widget);void hmw_pause (GtkWidget* widget);void hmw_stop (GtkWidget* widget);void hmw_previous (GtkWidget* widget);void hmw_next (GtkWidget* widget);void hmw_play_pause (GtkWidget* widget);void hmw_volume_changed (GtkWidget* widget);void hmw_volume_up (GtkWidget* widget);void hmw_volume_down (GtkWidget* widget);void hmw_mute (GtkWidget* widget);/* These callbacks don't have hxwindow_xxx counterparts (yet) */void hmw_fullscreen (GtkWidget* widget);void hmw_normal_size (GtkWidget* widget);void hmw_double_size (GtkWidget* widget);void hmw_clip_details (GtkWidget* widget);void hmw_statistics (GtkWidget* widget);void hmw_video_controls (GtkWidget* widget);void hmw_show_menu_and_caption (GtkWidget* widget);void hmw_show_controls (GtkWidget* widget);void hmw_show_status_bar (GtkWidget* widget);void hmw_plugins (GtkWidget* widget);void hmw_manage_favorites (GtkWidget* widget);void hmw_add_favorite (GtkWidget* widget);void hmw_export_favorites (GtkWidget* widget);void hmw_import_favorites (GtkWidget* widget);void hmw_intro (GtkWidget* widget);void hmw_release_notes (GtkWidget* widget); void hmw_faq (GtkWidget* widget);void hmw_report_issue (GtkWidget* widget); void hmw_nightly_build (GtkWidget* widget);void hmw_check_for_updates (GtkWidget* widget); void hmw_about (GtkWidget* widget);void hmw_view_source (GtkWidget* widget);void hmw_file_menu_update (GtkWidget* widget);void hmw_favorites_menu_update(GtkWidget* widget);void hmw_player_reset (GtkWidget* widget); #ifdef HELIX_FEATURE_RP_SIGN_INvoid hmw_sign_in (GtkWidget* widget);#endifvoid hmw_on_top_never (GtkWidget *widget);void hmw_on_top_while_playing(GtkWidget *widget);void hmw_on_top_always (GtkWidget *widget);void hmw_play_from_menu_item (GtkWidget* widget, gchar* url);void hmw_play_group (GtkWidget* widget, guint group);/* see prefsdialog.cpp for hmw_preferences */void hmw_preferences (GtkWidget* widget);void hmw_zoom_menu_refresh(GtkWidget* widget); /* Event callbacks, connectable to button_down */gboolean hmw_seek_start (GtkWidget* widget);gboolean hmw_seek_stop (GtkWidget* widget);gboolean hmw_key_press_event (GtkWidget *widget, GdkEventKey *event, gpointer user_data); GtkWidget* hmw_create_hxbin (gchar *widget_name, gchar *string1, gchar *string2, gint int1, gint int2);GtkWidget* hmw_create_status_area(gchar *widget_name, gchar *string1, gchar *string2, gint int1, gint int2);GtkWidget* hmw_create_position_slider(gchar *widget_name, gchar *string1, gchar *string2, gint int1, gint int2);void hmw_realize (GtkWidget* widget, gpointer);gboolean hmw_configure_event(GtkWidget* widget, GdkEventConfigure *event, gpointer);gboolean hmw_window_state_event(GtkWidget *widget, GdkEventWindowState *event, gpointer user_data);gboolean hmw_property_notify_event(GtkWidget *widget, GdkEventProperty *event, gpointer user_data);void hmw_drag_data_received(GtkWidget* widget, GdkDragContext* context, gint x, gint y, GtkSelectionData* selection_data, guint info, guint time); static HXMainWindow* hxwindow_get_from_widget (GtkWidget* widget);static void hxwindow_destroy (HXMainWindow* window);}; // extern "C"/* Recent url management implementation * ==================================== */static voidrecent_urls_menu_unpopulate(HXMainWindow* window){ GtkWidget* separator; GtkWidget* file_menu; GtkWidget* file_menu_item; GtkWidget* child; GList* children_iter; separator = glade_xml_get_widget(window->xml, "hmw_mru_separator"); g_return_if_fail(separator != NULL); file_menu_item = glade_xml_get_widget(window->xml, "hmw_file_menu"); g_return_if_fail(file_menu_item != NULL); file_menu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(file_menu_item)); g_return_if_fail(file_menu != NULL);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -