Пример #1
0
/**
 * nma_utils_menu_to_secret_flags:
 * @passwd_entry: password #GtkEntry which the password icon/menu is attached to
 *
 * Returns secret flags corresponding to the selected password storage menu
 * in the attached icon
 *
 * Returns: secret flags corresponding to the active item in password menu
 */
NMSettingSecretFlags
nma_utils_menu_to_secret_flags (GtkWidget *passwd_entry)
{
    GList *menu_list, *iter;
    GtkWidget *menu = NULL;
    NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE;

    menu_list = gtk_menu_get_for_attach_widget (passwd_entry);
    for (iter = menu_list; iter; iter = g_list_next (iter)) {
        if (g_object_get_data (G_OBJECT (iter->data), PASSWORD_STORAGE_MENU_TAG)) {
            menu = iter->data;
            break;
        }
    }

    /* Translate password popup menu to secret flags */
    if (menu) {
        MenuItem idx = 0;
        GList *list;
        int i, length;

        list = gtk_container_get_children (GTK_CONTAINER (menu));
        length = g_list_length (list);
        for (i = 0; i < length; i++) {
            if (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (list->data))) {
                idx =  (MenuItem) i;
                break;
            }
            list = g_list_next (list);
        }

        flags = menu_item_to_secret_flags (idx);
    }
    return flags;
}
Пример #2
0
void PlatformWebView::dismissAllPopupMenus()
{
    // gtk_menu_popdown doesn't modify the GList of attached menus, so it should
    // be safe to walk this list while calling it.
    GList* attachedMenusList = gtk_menu_get_for_attach_widget(GTK_WIDGET(m_view));
    g_list_foreach(attachedMenusList, [] (void* data, void*) {
        ASSERT(data);
        gtk_menu_popdown(GTK_MENU(data));
    }, nullptr);
}
Пример #3
0
/**
 * nma_utils_update_password_storage:
 * @passwd_entry: #GtkEntry with the password
 * @secret_flags: secret flags to set
 * @setting: #NMSetting containing the password, or NULL
 * @password_flags_name: name of the secret flags (like psk-flags), or NULL
 *
 * Updates secret flags in the password storage popup menu and also
 * in the @setting (if @setting and @password_flags_name are not NULL).
 *
 */
void
nma_utils_update_password_storage (GtkWidget *passwd_entry,
                                   NMSettingSecretFlags secret_flags,
                                   NMSetting *setting,
                                   const char *password_flags_name)
{
    GList *menu_list, *iter;
    GtkWidget *menu = NULL;

    /* Update secret flags (WEP_KEY_FLAGS, PSK_FLAGS, ...) in the security setting */
    if (setting && password_flags_name)
        nm_setting_set_secret_flags (setting, password_flags_name, secret_flags, NULL);

    /* Update password-storage popup menu to reflect secret flags */
    menu_list = gtk_menu_get_for_attach_widget (passwd_entry);
    for (iter = menu_list; iter; iter = g_list_next (iter)) {
        if (g_object_get_data (G_OBJECT (iter->data), PASSWORD_STORAGE_MENU_TAG)) {
            menu = iter->data;
            break;
        }
    }

    if (menu) {
        GtkRadioMenuItem *item;
        MenuItem idx;
        GSList *group;
        gboolean with_not_required;
        int i, last;

        /* radio menu group list contains the menu items in reverse order */
        item = (GtkRadioMenuItem *) gtk_menu_get_active (GTK_MENU (menu));
        group = gtk_radio_menu_item_get_group (item);
        with_not_required = !!g_object_get_data (G_OBJECT (menu), MENU_WITH_NOT_REQUIRED_TAG);

        idx = secret_flags_to_menu_item (secret_flags, with_not_required);
        last = g_slist_length (group) - idx - 1;
        for (i = 0; i < last; i++)
            group = g_slist_next (group);

        gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (group->data), TRUE);
        change_password_storage_icon (passwd_entry, idx);
    }
}
Пример #4
0
int
clip_GTK_MENUGETFORATTACHWIDGET(ClipMachine * ClipMachineMemory)
{
   C_widget *cwid = _fetch_cw_arg(ClipMachineMemory);

   ClipVar  *cv = RETPTR(ClipMachineMemory);

   GList    *list;

   long      l;

   CHECKCWID(cwid, GTK_IS_WIDGET);

   list = gtk_menu_get_for_attach_widget(GTK_WIDGET(cwid->widget));
   l = g_list_length(list);
   _clip_array(ClipMachineMemory, cv, 1, &l);
   for (l = 0; list; list = g_list_next(list), l++)
    {
       C_widget *cmnu;

       GtkMenu  *menu;

       menu = GTK_MENU(list->data);

       if (menu)
	{
	   cmnu = _list_get_cwidget(ClipMachineMemory, menu);
	   if (!cmnu)
	      cmnu = _register_widget(ClipMachineMemory, GTK_WIDGET(menu), NULL);
	   if (cmnu)
	      _clip_aset(ClipMachineMemory, cv, &cmnu->obj, 1, &l);
	}
    }
   return 0;
 err:
   return 1;
}
Пример #5
0
static VALUE
rg_s_get_for_attach_widget(G_GNUC_UNUSED VALUE self, VALUE widget)
{
    /* Owned by GTK+ */
    return GLIST2ARY(gtk_menu_get_for_attach_widget(GTK_WIDGET(RVAL2GOBJ(widget))));
}