⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainapp.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    HXFavorite* favorite = hx_favorite_new();    favorite->title = g_strdup(favorite_title);    favorite->url = g_strdup(favorite_url);    g_hx_main_app->favorites_list =        g_list_append(g_hx_main_app->favorites_list, favorite);    favorites_menu_refresh(window);}/* hxwindow_* functions  * ============================== * functions to manipulate a HXMainWindow object */GtkWidget*hxwindow_get_player(HXMainWindow* window){    return window->player;}GtkWidget*hxwindow_get_window(HXMainWindow* window){    return window->window;}gbooleanhxwindow_is_fullscreened (HXMainWindow* window){    return window->is_fullscreened;}HXMainWindowZoomSizehxwindow_get_zoom (HXMainWindow* window){    return window->zoom;}GladeXML*hxwindow_get_glade_xml (HXMainWindow* window){    return window->xml;}HXContentStateTypehxwindow_get_content_state(HXMainWindow* window){    return hx_player_get_content_state (HX_PLAYER(window->player));}G_CONST_RETURN gchar*hxwindow_get_distcode (HXMainWindow* window){    return window->distcode;}G_CONST_RETURN gchar*hxwindow_get_origcode (HXMainWindow* window){    return window->origcode;}voidhxwindow_set_quit_on_done(HXMainWindow* window,                          gboolean quit){    window->quit_on_done = quit;}voidhxwindow_change_layout(HXMainWindow* window){    gint ideal_player_width,       ideal_player_height;    gint desired_window_height,    desired_window_width;    gboolean has_visual_content;    GList* children_iter;        HXContentStateType state;    HXMainWindowZoomSize zoom;    if(!window->player)    {        return;    }    has_visual_content = hx_player_has_visual_content(HX_PLAYER(window->player));        if(!has_visual_content &&        !GTK_WIDGET_VISIBLE(window->menu_bar))                         {        /* If the menu has been hidden, the video area must be visible so the           player doesn't disapper. This should only be an issue when playing           a playlist that contains both audio and video clips when all controls           are hidden. */                gtk_widget_show(window->hxbin);        hx_player_get_logo_size(HX_PLAYER(window->player),                                &ideal_player_width,                                &ideal_player_height);    }    else if(hx_player_get_url(HX_PLAYER(window->player)) == NULL)    {        /* No content is set -- player proabably just started, so make us           the default size */        ideal_player_width = DEFAULT_VIDEO_WIDGET_WIDTH;        ideal_player_height = DEFAULT_VIDEO_WIDGET_HEIGHT;    }    else    {        hx_player_get_ideal_size(HX_PLAYER(window->player),                                 &ideal_player_width, &ideal_player_height);    }        state = hx_player_get_content_state(HX_PLAYER(window->player));    if(state == HX_CONTENT_STATE_NOT_LOADED || !has_visual_content)    {        zoom = NORMAL_SIZE;    }    else    {                zoom = window->zoom;    }                   /* Set the menu items based on the zoom setting to be used while       playing */    switch(zoom)    {        case NORMAL_SIZE:            desired_window_width = ideal_player_width;            desired_window_height = ideal_player_height;            break;                    case DOUBLE_SIZE:            desired_window_width = 2 * ideal_player_width;            desired_window_height = 2 * ideal_player_height;            break;                    case CUSTOM_SIZE:        default:            desired_window_height = window->custom_zoom_height;            desired_window_width = window->custom_zoom_width;            break;    }            /* Apply vbox's borders & spacings */    guint border_width, spacing, visible_child_count = 0;    border_width = gtk_container_get_border_width(GTK_CONTAINER(window->vbox));    spacing = gtk_box_get_spacing(GTK_BOX(window->vbox));    desired_window_height += 2 * border_width;    desired_window_width  += 2 * border_width;    /* Add children's allocations */    children_iter = gtk_container_get_children(GTK_CONTAINER(window->vbox));    while(children_iter)    {        GtkWidget* widget = GTK_WIDGET(children_iter->data);        if(GTK_WIDGET_VISIBLE(widget))        {            if(widget != window->hxbin)            {                GtkRequisition child_requisition;                guint padding;                gboolean expand, fill;                                expand = FALSE;                fill = FALSE;                padding = 0;                gtk_box_query_child_packing(GTK_BOX(window->vbox),                                            widget,                                            &expand,                                            &fill,                                            &padding,                                            NULL);                g_assert(!fill);                g_assert(!expand);                g_assert(padding == 0);                            gtk_widget_size_request(widget, &child_requisition);                desired_window_height += child_requisition.height + padding * 2;            }            visible_child_count++;        }        children_iter = g_list_next(children_iter);    }    if(visible_child_count > 0)    {        desired_window_height += (visible_child_count - 1) * spacing;    }        /* Windows have to be at least 1x1 */    if(desired_window_width <= 0)    {        desired_window_width = 1;    }    if(desired_window_height <= 0)    {        desired_window_height = 1;    }    gtk_window_resize(GTK_WINDOW(window->window),                      desired_window_width,                      desired_window_height);}voidhxwindow_update_ui(HXMainWindow* window){    guint current_group, group_count;    populate_clip_list_menu(window);        group_count = hx_player_get_group_count(HX_PLAYER(window->player));    current_group = hx_player_get_current_group(HX_PLAYER(window->player));    if(current_group == 0)    {        gtk_widget_set_sensitive(GTK_WIDGET(window->previous_button), FALSE);        gtk_widget_set_sensitive(GTK_WIDGET(window->previous_menu_item), FALSE);    }    else    {        gtk_widget_set_sensitive(GTK_WIDGET(window->previous_button), TRUE);        gtk_widget_set_sensitive(GTK_WIDGET(window->previous_menu_item), TRUE);    }    if((current_group + 1) < group_count)    {        gtk_widget_set_sensitive(GTK_WIDGET(window->next_button), TRUE);        gtk_widget_set_sensitive(GTK_WIDGET(window->next_menu_item), TRUE);    }    else    {        gtk_widget_set_sensitive(GTK_WIDGET(window->next_button), FALSE);        gtk_widget_set_sensitive(GTK_WIDGET(window->next_menu_item), FALSE);    }}voidhxwindow_set_property(HXMainWindow* window, const gchar* key, GValue* value){    guint uint_val;    gboolean bool_val;        if(strcmp("XPos", key) == 0)    {        if(G_VALUE_HOLDS_STRING(value))        {            uint_val = atoi(g_value_get_string(value));        }        else        {            uint_val = g_value_get_uint(value);        }                   window->x_pos = uint_val;    }    else if(strcmp("YPos", key) == 0)    {        if(G_VALUE_HOLDS_STRING(value))        {            uint_val = atoi(g_value_get_string(value));        }        else        {            uint_val = g_value_get_uint(value);        }        window->y_pos = uint_val;        /* XXXRGG: Hack. fixme */        if(window->x_pos && window->y_pos)        {            gtk_window_move(GTK_WINDOW(window->window), window->x_pos, window->y_pos);        }    }    else if(strcmp("EnableRecentUrlsList", key) == 0)    {        if(G_VALUE_HOLDS_STRING(value))        {            bool_val = atoi(g_value_get_string(value));        }        else        {            bool_val = g_value_get_boolean(value);        }        window->enable_recent_urls = bool_val;    }    else if(strcmp("MediaFilesPath", key) == 0)    {        g_free(window->media_files_path);        window->media_files_path = g_strdup(g_value_get_string(value));    }    else if(strcmp("WebBrowserPath", key) == 0)    {        g_free(window->web_browser_path);        window->web_browser_path = g_strdup(g_value_get_string(value));    }    else if(strcmp("EnableUrlHurling", key) == 0)    {        if(G_VALUE_HOLDS_STRING(value))        {            bool_val = atoi(g_value_get_string(value));        }        else        {            bool_val = g_value_get_boolean(value);        }        window->enable_url_hurling = bool_val;    }    else if(strcmp("LastBrowsedDirectory", key) == 0)    {        g_free(window->last_browsed_directory);        window->last_browsed_directory = g_strdup(g_value_get_string(value));    }        else if(strcmp("DistCode", key) == 0)    {        const gchar* distcode = g_value_get_string(value);        snprintf(window->distcode, sizeof(window->distcode), "%s", distcode);    }        else if(strcmp("OrigCode", key) == 0)    {        const gchar* origcode = g_value_get_string(value);        snprintf(window->origcode, sizeof(window->origcode), "%s", origcode);    }        else    {        g_warning("Unknown property %s in config file", key);    }}gbooleanhxwindow_get_property(HXMainWindow* window,                      const gchar*  key,                      GValue*       value){    gboolean ret = TRUE;        if(strcmp("XPos", key) == 0)    {        g_value_init(value, G_TYPE_UINT);        g_value_set_uint(value, window->x_pos);    }    else if(strcmp("YPos", key) == 0)    {        g_value_init(value, G_TYPE_UINT);        g_value_set_uint(value, window->y_pos);            }    else if(strcmp("EnableRecentUrlsList", key) == 0)    {        g_value_init(value, G_TYPE_BOOLEAN);        g_value_set_boolean(value, window->enable_recent_urls);    }    else if(strcmp("MediaFilesPath", key) == 0)    {        g_value_init(value, G_TYPE_STRING);        g_value_set_string(value, window->media_files_path);    }    else if(strcmp("WebBrowserPath", key) == 0)    {        g_value_init(value, G_TYPE_STRING);        g_value_set_string(value, window->web_browser_path);    }    else if(strcmp("EnableUrlHurling", key) == 0)    {        g_value_init(value, G_TYPE_BOOLEAN);        g_value_set_boolean(value, window->enable_url_hurling);    }    else if(strcmp("LastBrowsedDirectory", key) == 0)    {        g_value_init(value, G_TYPE_STRING);        g_value_set_string(value, window->last_browsed_directory);    }    else if(strcmp("DistCode", key) == 0)    {        g_value_init(value, G_TYPE_STRING);        g_value_set_string(value, window->distcode);    }    else if(strcmp("OrigCode", key) == 0)    {        g_value_init(value, G_TYPE_STRING);        g_value_set_string(value, window->origcode);    }    else    {        g_warning("Unknown property %s in config file", key);        ret = FALSE;    }    return ret;}#ifdef HELIX_FEATURE_RP_SIGN_INvoidhxwindow_set_sign_in_property(HXMainWindow* /* window */,                              const gchar*  key,                              const gchar*  value){    GList* pref_iter = g_hx_main_app->sign_in_preferences_list;    HXSignInPref* pref = NULL;    while(pref_iter)    {        HXSignInPref* cur_pref = (HXSignInPref*)pref_iter->data;        if(strcmp(key, cur_pref->key) == 0)        {            pref = cur_pref;            break;        }                pref_iter = g_list_next(pref_iter);    }    if(!pref)    {        pref = g_new0(HXSignInPref, 1);        pref->key = g_strdup(key);        g_hx_main_app->sign_in_preferences_list = g_list_append(g_hx_main_app->sign_in_preferences_list, pref);    }        g_free(pref->value);    pref->value = g_strdup(value);}G_CONST_RETURN gchar*

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -