Beispiel #1
0
/* Externally accesible functions */
EAPI E_Entry_Dialog *
e_entry_dialog_show(const char *title, const char *icon, const char *text,
                    const char *initial_text,
                    const char *button_text, const char *button2_text,
                    void (*ok_func)(void *data, char *text),
                    void (*cancel_func)(void *data), void *data)
{
   E_Entry_Dialog *ed;
   E_Dialog *dia;
   Evas_Object *o, *ob;
   Evas_Modifier_Mask mask;
   int w, h;

   ed = E_OBJECT_ALLOC(E_Entry_Dialog, E_ENTRY_DIALOG_TYPE, _e_entry_dialog_free);
   ed->ok.func = ok_func;
   ed->ok.data = data;
   ed->cancel.func = cancel_func;
   ed->cancel.data = data;
   if (initial_text)
     ed->text = strdup(initial_text);

   dia = e_dialog_new(e_container_current_get(e_manager_current_get()), "E", "_entry_dialog");
   if (!dia)
     {
        e_object_del(E_OBJECT(ed));
        return NULL;
     }
   dia->data = ed;
   ed->dia = dia;

   mask = 0;
   evas_object_key_ungrab(dia->event_object, "space", mask, ~mask);
   e_object_del_attach_func_set(E_OBJECT(dia), _e_entry_dia_del);
   e_win_delete_callback_set(dia->win, _e_entry_dialog_delete);

   if (title) e_dialog_title_set(dia, title);
   if (icon) e_dialog_icon_set(dia, icon, 64);

   o = e_widget_list_add(dia->win->evas, 0, 0);
   if (text)
     {
        ob = e_widget_label_add(dia->win->evas, text);
        e_widget_list_object_append(o, ob, 1, 0, 0.5);
     }

   ed->entry = e_widget_entry_add(dia->win->evas, &(ed->text), NULL, NULL, NULL);
   evas_object_smart_callback_add(ed->entry, "key_down", _e_entry_cb_key_down, ed);
   e_widget_list_object_append(o, ed->entry, 1, 1, 0.5);
   e_widget_size_min_get(o, &w, &h);
   e_dialog_content_set(dia, o, w, h);

   e_dialog_button_add(dia, !button_text ? _("OK") : button_text, NULL, _e_entry_dialog_ok, ed);
   e_dialog_button_add(dia, !button2_text ? _("Cancel") : button2_text, NULL, _e_entry_dialog_cancel, ed);

   e_win_centered_set(dia->win, 1);
   e_dialog_show(dia);
   e_widget_focus_set(ed->entry, 1);
   e_editable_select_all(e_widget_entry_editable_object_get(ed->entry));
   return ed;
}
/********** externally accesible functions ****************/
EAPI E_Confirm_Dialog *
e_confirm_dialog_show(const char *title, const char *icon, const char *text,
                      const char *button_text, const char *button2_text,
                      void (*func)(void *data), void (*func2)(void *data),
                      void *data, void *data2,
                      void (*del_func)(void *data), void *del_data)
{
    E_Confirm_Dialog *cd;
    E_Dialog *dia;

    cd = E_OBJECT_ALLOC(E_Confirm_Dialog, E_CONFIRM_DIALOG_TYPE, _e_confirm_dialog_free);
    cd->yes.func = func;
    cd->yes.data = data;
    cd->no.func = func2;
    cd->no.data = data2;
    cd->del.func = del_func;
    cd->del.data = del_data;

    dia = e_dialog_new(e_container_current_get(e_manager_current_get()), "E", "_confirm_dialog");
    if (!dia)
    {
        e_object_del(E_OBJECT(cd));
        return NULL;
    }
    dia->data = cd;
    cd->dia = dia;

    e_win_delete_callback_set(dia->win, _e_confirm_dialog_delete);

    if (title) e_dialog_title_set(dia, title);
    if (icon) e_dialog_icon_set(dia, icon, 64);
    if (text) e_dialog_text_set(dia, text);

    e_dialog_button_add(dia, !button_text ? _("Yes") : button_text, NULL, _e_confirm_dialog_yes, cd);
    e_dialog_button_add(dia, !button2_text ? _("No") : button2_text, NULL, _e_confirm_dialog_no, cd);

    e_dialog_button_focus_num(dia, 1);
    e_win_centered_set(dia->win, 1);
    e_dialog_show(dia);

    return cd;
}
/**
 * Create a color selector dialog.
 *
 * @param c compositor to display on
 * @param color color to initialize to (or NULL for black).
 * @param alpha_enabled if set, uses alpha and let user edit it.
 */
E_Color_Dialog *
e_color_dialog_new(E_Comp *c, const E_Color *color, Eina_Bool alpha_enabled)
{
   E_Color_Dialog *dia;
   Evas_Object *o;
   Evas_Coord mw, mh;

   dia = E_OBJECT_ALLOC(E_Color_Dialog, E_COLOR_DIALOG_TYPE, _e_color_dialog_free);
   if (!dia) return NULL;
   dia->dia = e_dialog_new(c, "E", "_color_dialog");
   e_dialog_title_set(dia->dia, _("Color Selector"));

   dia->color = calloc(1, sizeof(E_Color));
   dia->initial = calloc(1, sizeof(E_Color));

   if (color)
     e_color_copy(color, dia->color);

   if ((!color) || (!alpha_enabled))
     dia->color->a = 255;

   e_color_copy(dia->color, dia->initial);

   o = e_widget_csel_add(dia->dia->win->evas, dia->color, alpha_enabled);
   evas_object_show(o);
   e_widget_size_min_get(o, &mw, &mh);
   e_dialog_content_set(dia->dia, o, mw, mh);
   e_widget_on_change_hook_set(o, _e_color_dialog_cb_csel_change, dia);

   /* buttons at the bottom */
   e_dialog_button_add(dia->dia, _("Select"), NULL, _e_color_dialog_button1_click, dia);
   e_dialog_button_add(dia->dia, _("Cancel"), NULL, _e_color_dialog_button2_click, dia);
   e_win_centered_set(dia->dia->win, 1);

   dia->dia->data = dia;
   e_object_del_attach_func_set(E_OBJECT(dia->dia), _e_color_dialog_dia_del);

   return dia;
}
static void
_alarm_snooze(Alarm *al)
{
   E_Dialog *dia;
   Evas_Object *o, *ob;
   Evas *evas;
   char buf[4096];
   int w, h;

   if (al->snooze.dia)
     return;

   dia = e_dialog_new(e_container_current_get(e_manager_current_get()), "Alarm", "_e_modules_alarm_snooze_dialog");
   if (!dia)
     return;
   evas = e_win_evas_get(dia->win);

   snprintf(buf, sizeof(buf), D_("Snooze %s"), al->name);
   e_dialog_title_set(dia, buf);
   
   o = e_widget_list_add(evas, 0, 0);
   ob = e_widget_slider_add(evas, 1, 0, D_("%1.0f hours"), 0.0, 24.0, 1.0, 0,
                            NULL, &(al->snooze.hour), 100);
   e_widget_list_object_append(o, ob, 0, 0, 1.0);
   ob = e_widget_slider_add(evas, 1, 0, D_("%1.0f minutes"), 0.0, 60.0, 1.0, 0,
                            NULL, &(al->snooze.minute), 100);
   e_widget_list_object_append(o, ob, 0, 0, 1.0);

   e_widget_size_min_get(o, &w, &h);
   e_dialog_content_set(dia, o, w, h);

   e_dialog_button_add(dia, D_("Ok"), NULL, _alarm_cb_dialog_snooze_ok, al);
   e_dialog_button_add(dia, D_("Close"), NULL, _alarm_cb_dialog_snooze_cancel, al);

   al->snooze.dia = dia;
   e_win_centered_set(dia->win, 1);
   e_dialog_show(dia);
}
Beispiel #5
0
E_API E_Dialog *
e_util_dialog_internal(const char *title, const char *txt)
{
   E_Dialog *dia;

   dia = e_dialog_new(NULL, "E", "_error_dialog");
   if (!dia) return NULL;
   e_dialog_title_set(dia, title);
   e_dialog_text_set(dia, txt);
   e_dialog_icon_set(dia, "dialog-error", 64);
   e_dialog_button_add(dia, _("OK"), NULL, NULL, NULL);
   e_dialog_button_focus_num(dia, 0);
   elm_win_center(dia->win, 1, 1);
   e_dialog_show(dia);
   return dia;
}
Beispiel #6
0
E_API void
e_int_client_prop(E_Client *ec)
{
   E_Dialog *dia;

   if (ec->border_prop_dialog) return;

   dia = e_dialog_new(NULL, "E", "_window_props");
   e_object_del_attach_func_set(E_OBJECT(dia), _ec_cb_dialog_del);

   _create_data(dia, ec);

   _ec_go(dia, (void *)0);

   e_dialog_button_add(dia, _("Close"), NULL, _ec_cb_dialog_close, dia);
   elm_win_center(dia->win, 1, 1);
   e_dialog_show(dia);
   e_dialog_border_icon_set(dia, "preferences-system-windows");
   evas_object_layer_set(e_win_client_get(dia->win)->frame, ec->layer);
}
Beispiel #7
0
/*
 * Validate the entered configuration. Display and error message
 * if required.
 */
static int parse_config_gui(E_Config_Dialog_Data *cfdata)
{
   E_Dialog *error_popup;
   char error_message[1024];
   int config_ok = 1;
   char *end_pointer;
   float parsed_float;
   const char *text_value;
   regex_t *reg_expression;
   int regex_result;
   char *viewpos_file;
   float lat, lon;

   sprintf(error_message, "The configuration you have entered is invalid:<br>");

   if (cfdata->local_xplanet.source_type == SOURCE_ORIGIN)
      cfdata->local_xplanet.origin = strdup(e_widget_ilist_selected_value_get(cfdata->gui.o_source_ilist));
   else
      cfdata->local_xplanet.projection = strdup(e_widget_ilist_selected_value_get(cfdata->gui.o_source_ilist));

   if (cfdata->local_xplanet.source_type == SOURCE_ORIGIN)
   {
      if (strcmp(cfdata->local_xplanet.body, "random") && !strcmp(cfdata->local_xplanet.body, cfdata->local_xplanet.origin))
      {
         sprintf(error_message + strlen(error_message),
            "<br>* Target and origin cannot be the same.");
         config_ok = 0;
      }
   }

   switch (cfdata->local_xplanet.viewpos_type)
   {
   case VIEWPOS_LATLON:
   {
      end_pointer = (char *)e_widget_entry_text_get(cfdata->gui.o_viewpos_lat);
      if (strlen(end_pointer) == 0)
      {
         sprintf(error_message + strlen(error_message),
               "<br>* You must enter a latitude.");
         config_ok = 0;
      }
      else
      {
         parsed_float = strtof(e_widget_entry_text_get(cfdata->gui.o_viewpos_lat),
               &end_pointer);
         if (*end_pointer != '\0' || parsed_float < -90.0 || parsed_float > 90.0)
         {
            sprintf(error_message + strlen(error_message),
                  "<br>* The entered latitude is invalid - must be in the range -90 to 90.");
            config_ok = 0;
         }
         else cfdata->local_xplanet.viewpos_lat = parsed_float;
      }

      end_pointer = (char *)e_widget_entry_text_get(cfdata->gui.o_viewpos_lon);
      if (strlen(end_pointer) == 0)
      {
         sprintf(error_message + strlen(error_message),
               "<br>* You must enter a longitude.");
         config_ok = 0;
      }
      else
      {
         parsed_float = strtof(e_widget_entry_text_get(cfdata->gui.o_viewpos_lon),
               &end_pointer);
         if (*end_pointer != '\0' || parsed_float < -180.0 || parsed_float > 360.0)
         {
            sprintf(error_message + strlen(error_message),
                  "<br>* The entered longitude is invalid - must be in the range 0 to 360 or -180 to 180");
            config_ok = 0;
         }
         else cfdata->local_xplanet.viewpos_lon = parsed_float;
      }
      break;
   }
   case VIEWPOS_FILE:
   {
      lat = INVALID_COORD;
      lon = INVALID_COORD;

      viewpos_file = (char *)e_widget_entry_text_get(cfdata->gui.o_viewpos_file_val);
      switch(read_viewpos_file(viewpos_file, &lat, &lon))
      {
      case VIEWPOS_FILE_NO_PERM:
      {
         sprintf(error_message + strlen(error_message),
               "<br>* No permissions to read viewing position file");
         config_ok = 0;
         break;
      }
      case VIEWPOS_FILE_NOT_FOUND:
      {
         sprintf(error_message + strlen(error_message),
               "<br>* The viewing position file cannot be found");
         config_ok = 0;
         break;
      }
      case VIEWPOS_FILE_IS_DIR:
      {
         sprintf(error_message + strlen(error_message),
               "<br>* The viewing position file is a directory");
         config_ok = 0;
         break;
      }
      case VIEWPOS_FILE_FORMAT_ERROR:
      {
         sprintf(error_message + strlen(error_message),
               "<br>* The viewing position file is in the wrong format (must be 2 numbers, lat then lon)");
         config_ok = 0;
         break;
      }
      case VIEWPOS_FILE_OK:
         cfdata->local_xplanet.viewpos_file = (char *)eina_stringshare_add(viewpos_file);
         break;
      }
      break;
   }
   default:
      break;
   }

   cfdata->local_xplanet.use_localtime = e_widget_check_checked_get(cfdata->gui.o_use_localtime);
   cfdata->local_xplanet.localtime = cfdata->gui.o_localtime;

   cfdata->local_xplanet.show_label = e_widget_check_checked_get(cfdata->gui.o_show_label);
   cfdata->local_xplanet.label_text = strdup(e_widget_entry_text_get(cfdata->gui.o_label_text));

   text_value = strdup(e_widget_entry_text_get(cfdata->gui.o_label_pos_other_text));
   if (!text_value || strlen(text_value) == 0)
   {
      cfdata->local_xplanet.label_pos_other = "";
      if (cfdata->local_xplanet.label_pos == LABEL_POS_OTHER)
      {
         sprintf(error_message + strlen(error_message),
               "<br>* You have not entered a label position");
         config_ok = 0;
      }
   }
   else
   {
      reg_expression = E_NEW(regex_t, 1);
      regcomp(reg_expression, "^[+-][0-9][0-9]*[+-][0-9][0-9]*$", 0);
      regex_result = regexec(reg_expression, text_value, 0, NULL, 0);
      if (regex_result)
      {
         sprintf(error_message + strlen(error_message),
               "<br>* The entered label position is invalid - must be of the form -15+15");
         config_ok = 0;
      }
      else cfdata->local_xplanet.label_pos_other = text_value;

      regfree(reg_expression);
      free(reg_expression);
   }

   cfdata->local_xplanet.use_config = e_widget_check_checked_get(cfdata->gui.o_config_check);
   cfdata->local_xplanet.config_name = strdup(e_widget_entry_text_get(cfdata->gui.o_config_name));

   cfdata->local_xplanet.extra_options = strdup(e_widget_entry_text_get(cfdata->gui.o_extra_options));

   if (!config_ok)
   {
      error_popup = e_dialog_new(e_container_current_get(
            e_manager_current_get()), "eplanet_error", "eplanet/error");
      e_dialog_title_set(error_popup, "Configuration error");
      e_dialog_text_set(error_popup, (const char *) &error_message);
      e_dialog_button_add(error_popup, D_("OK"), NULL, NULL, NULL);
      e_dialog_show(error_popup);
   }

   return config_ok;
}